yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/huawei/client/manager/manager.go (about) 1 // Copyright 2019 Yunion 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package manager 16 17 import ( 18 "yunion.io/x/jsonutils" 19 20 "yunion.io/x/cloudmux/pkg/multicloud/huawei/client/auth" 21 "yunion.io/x/cloudmux/pkg/multicloud/huawei/client/responses" 22 ) 23 24 type IManagerContext interface { 25 GetPath() string 26 } 27 28 type IBaseManager interface { 29 Version() string 30 KeyString() string 31 ServiceType() string 32 GetColumns() []string 33 } 34 35 type IManager interface { 36 IBaseManager 37 // 获取资源列表 GET <base_url>/cloudservers/?<queries> 38 List(queries map[string]string) (*responses.ListResult, error) 39 // 根据上文获取资源列表 GET <base_url>/cloudservers/<cloudserver_id>/nics?<queries> 40 ListInContext(ctx IManagerContext, queries map[string]string) (*responses.ListResult, error) 41 ListInContextWithSpec(ctx IManagerContext, spec string, queries map[string]string, responseKey string) (*responses.ListResult, error) 42 43 // 查询单个资源 GET <base_url>/cloudservers/<cloudserver_id>?<queries> 44 Get(id string, queries map[string]string) (jsonutils.JSONObject, error) 45 // 根据上文获取资源查询单个资源 GET <base_url>/cloudservers/<cloudserver_id>/nics/<nic_id>?<queries> 46 GetInContext(ctx IManagerContext, id string, queries map[string]string) (jsonutils.JSONObject, error) 47 48 // 创建单个资源 POST <base_url>/cloudservers 49 Create(params jsonutils.JSONObject) (jsonutils.JSONObject, error) 50 // 根据上文创建单个资源 POST <base_url>/cloudservers/<cloudserver_id>/nics/<nic_id> 51 CreateInContext(ctx IManagerContext, params jsonutils.JSONObject) (jsonutils.JSONObject, error) 52 // 异步任务创建 POST <base_url>/cloudservers. 返回异步任务 job_id。 todo:// 后续考虑返回一个task对象 53 AsyncCreate(params jsonutils.JSONObject) (string, error) 54 55 // 更新单个资源 PUT <base_url>/cloudservers/<cloudserver_id> 56 Update(id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) 57 // 根据上文更新单个资源 PUT <base_url>/cloudservers/<cloudserver_id>/nics/<nic_id> 58 UpdateInContext(ctx IManagerContext, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) 59 // 根据上文和spec更新单个资源 PUT /v2.1/{project_id}/servers/{server_id}/os-reset-password 60 UpdateInContextWithSpec(ctx IManagerContext, id string, spec string, params jsonutils.JSONObject, responseKey string) (jsonutils.JSONObject, error) 61 62 // 删除单个资源 DELETE <base_url>/cloudservers/<cloudserver_id> 63 Delete(id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) 64 // 根据上文删除单个资源 DELETE <base_url>/cloudservers/<cloudserver_id>/nics/<nic_id> 65 DeleteInContext(ctx IManagerContext, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) 66 // 根据上文和spec删除单个资源 67 DeleteInContextWithSpec(ctx IManagerContext, id string, spec string, queries map[string]string, params jsonutils.JSONObject, responseKey string) (jsonutils.JSONObject, error) 68 // 批量执行操作 POST <base_url>/cloudservers/<action> 69 // BatchPerformAction(action string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) 70 // 执行操作 POST <base_url>/cloudservers/<cloudserver_id>/<action> 71 PerformAction(action string, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) 72 } 73 74 type IManagerConfig interface { 75 GetSigner() auth.Signer 76 GetEndpoint() string 77 GetRegionId() string 78 GetDomainId() string 79 GetProjectId() string 80 GetDebug() bool 81 }