阅读本文,您可以获取 Go SDK 服务管理的接口调用示例,实现快速开发。
调用接口前,请先完成 Go SDK 的安装及初始化操作。
本节为您介绍服务管理相关接口的功能和调用示例。
您可以调用 CreateImageService 接口创建一个 veImageX 服务。详细的参数说明可参见 CreateImageService 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_CreateImageService(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.CreateImageServiceBody{} resp, err := instance.CreateImageService(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 DeleteImageService 接口删除指定的 veImageX 服务。详细的参数说明可参见 DeleteImageService 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_DeleteImageService(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.DeleteImageServiceQuery{} resp, err := instance.DeleteImageService(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 UpdateImageAuthKey 接口指定服务 ID 以及新的主备鉴权,来修改鉴权信息。详细的参数说明可参见 UpdateImageAuthKey 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_UpdateImageAuthKey(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.UpdateImageAuthKeyReq{ UpdateImageAuthKeyQuery: &imagex.UpdateImageAuthKeyQuery{}, UpdateImageAuthKeyBody: &imagex.UpdateImageAuthKeyBody{}, } resp, err := instance.UpdateImageAuthKey(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 GetImageAuthKey 接口指定服务 ID 获取服务的主备鉴权信息。详细的参数说明可参见 GetImageAuthKey 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_GetImageAuthKey(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.GetImageAuthKeyQuery{} resp, err := instance.GetImageAuthKey(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 GetImageService 接口指定服务 ID 获取对应服务的详情。详细的参数说明可参见 GetImageService 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_GetImageService(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.GetImageServiceQuery{} resp, err := instance.GetImageService(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 GetAllImageServices 接口获取当前火山账号下创建的所有 veImageX 图片服务信息。详细的参数说明可参见 GetAllImageServices 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_GetAllImageServices(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.GetAllImageServicesQuery{} resp, err := instance.GetAllImageServices(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 UpdateImageObjectAccess 接口更新指定服务下的源地址访问配置。详细的参数说明可参见 UpdateImageObjectAccess 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_UpdateImageObjectAccess(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.UpdateImageObjectAccessReq{ UpdateImageObjectAccessQuery: &imagex.UpdateImageObjectAccessQuery{}, UpdateImageObjectAccessBody: &imagex.UpdateImageObjectAccessBody{}, } resp, err := instance.UpdateImageObjectAccess(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 UpdateImageMirrorConf 接口更新指定服务下的镜像回源配置。详细的参数说明可参见 UpdateImageMirrorConf 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_UpdateImageMirrorConf(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.UpdateImageMirrorConfReq{ UpdateImageMirrorConfQuery: &imagex.UpdateImageMirrorConfQuery{}, UpdateImageMirrorConfBody: &imagex.UpdateImageMirrorConfBody{}, } resp, err := instance.UpdateImageMirrorConf(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 UpdateServiceName 接口更新指定服务的服务名称。详细的参数说明可参见 UpdateServiceName 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_UpdateServiceName(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.UpdateServiceNameReq{ UpdateServiceNameQuery: &imagex.UpdateServiceNameQuery{}, UpdateServiceNameBody: &imagex.UpdateServiceNameBody{}, } resp, err := instance.UpdateServiceName(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }