yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/hcso/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/cloudprovider"
    21  	"yunion.io/x/cloudmux/pkg/multicloud/hcso/client/auth"
    22  	"yunion.io/x/cloudmux/pkg/multicloud/hcso/client/responses"
    23  )
    24  
    25  type IManagerContext interface {
    26  	GetPath() string
    27  }
    28  
    29  type IBaseManager interface {
    30  	Version() string
    31  	KeyString() string
    32  	ServiceType() string
    33  	GetColumns() []string
    34  }
    35  
    36  type IManager interface {
    37  	IBaseManager
    38  	// 获取资源列表 GET <base_url>/cloudservers/?<queries>
    39  	List(queries map[string]string) (*responses.ListResult, error)
    40  	// 根据上文获取资源列表 GET <base_url>/cloudservers/<cloudserver_id>/nics?<queries>
    41  	ListInContext(ctx IManagerContext, queries map[string]string) (*responses.ListResult, error)
    42  	ListInContextWithSpec(ctx IManagerContext, spec string, queries map[string]string, responseKey string) (*responses.ListResult, error)
    43  
    44  	// 查询单个资源 GET <base_url>/cloudservers/<cloudserver_id>?<queries>
    45  	Get(id string, queries map[string]string) (jsonutils.JSONObject, error)
    46  	// 根据上文获取资源查询单个资源 GET <base_url>/cloudservers/<cloudserver_id>/nics/<nic_id>?<queries>
    47  	GetInContext(ctx IManagerContext, id string, queries map[string]string) (jsonutils.JSONObject, error)
    48  
    49  	// 创建单个资源 POST <base_url>/cloudservers
    50  	Create(params jsonutils.JSONObject) (jsonutils.JSONObject, error)
    51  	// 根据上文创建单个资源 POST <base_url>/cloudservers/<cloudserver_id>/nics/<nic_id>
    52  	CreateInContext(ctx IManagerContext, params jsonutils.JSONObject) (jsonutils.JSONObject, error)
    53  	// 异步任务创建 POST <base_url>/cloudservers. 返回异步任务 job_id。 todo:// 后续考虑返回一个task对象
    54  	AsyncCreate(params jsonutils.JSONObject) (string, error)
    55  
    56  	// 更新单个资源 PUT <base_url>/cloudservers/<cloudserver_id>
    57  	Update(id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error)
    58  	// 根据上文更新单个资源 PUT <base_url>/cloudservers/<cloudserver_id>/nics/<nic_id>
    59  	UpdateInContext(ctx IManagerContext, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error)
    60  	// 根据上文和spec更新单个资源 PUT /v2.1/{project_id}/servers/{server_id}/os-reset-password
    61  	UpdateInContextWithSpec(ctx IManagerContext, id string, spec string, params jsonutils.JSONObject, responseKey string) (jsonutils.JSONObject, error)
    62  
    63  	// 删除单个资源  DELETE <base_url>/cloudservers/<cloudserver_id>
    64  	Delete(id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error)
    65  	// 根据上文删除单个资源 DELETE <base_url>/cloudservers/<cloudserver_id>/nics/<nic_id>
    66  	DeleteInContext(ctx IManagerContext, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error)
    67  	// 根据上文和spec删除单个资源
    68  	DeleteInContextWithSpec(ctx IManagerContext, id string, spec string, queries map[string]string, params jsonutils.JSONObject, responseKey string) (jsonutils.JSONObject, error)
    69  	// 批量执行操作 POST <base_url>/cloudservers/<action>
    70  	// BatchPerformAction(action string, params jsonutils.JSONObject) (jsonutils.JSONObject, error)
    71  	// 执行操作 POST <base_url>/cloudservers/<cloudserver_id>/<action>
    72  	PerformAction(action string, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error)
    73  }
    74  
    75  type IManagerConfig interface {
    76  	GetSigner() auth.Signer
    77  	GetEndpoints() *cloudprovider.SHCSOEndpoints
    78  	GetRegionId() string
    79  	GetDomainId() string
    80  	GetProjectId() string
    81  	GetDebug() bool
    82  
    83  	GetDefaultRegion() string
    84  }