From 9fff05f6160954c44624be3b3db9247342d3d841 Mon Sep 17 00:00:00 2001 From: rriski Date: Wed, 27 Nov 2024 08:37:41 +0000 Subject: [PATCH] feat: move AlloyDB Omni APIs to separate module (#193) --- client_generated.go | 4 ++ config.yaml | 7 +- handler/alloydbomni/alloydbomni.go | 103 +++++++++++++++++++++++++++++ handler/service/service.go | 77 --------------------- 4 files changed, 111 insertions(+), 80 deletions(-) create mode 100644 handler/alloydbomni/alloydbomni.go diff --git a/client_generated.go b/client_generated.go index deb8db7..6ee2612 100644 --- a/client_generated.go +++ b/client_generated.go @@ -9,6 +9,7 @@ import ( accountauthentication "github.com/aiven/go-client-codegen/handler/accountauthentication" accountteam "github.com/aiven/go-client-codegen/handler/accountteam" accountteammember "github.com/aiven/go-client-codegen/handler/accountteammember" + alloydbomni "github.com/aiven/go-client-codegen/handler/alloydbomni" applicationuser "github.com/aiven/go-client-codegen/handler/applicationuser" billinggroup "github.com/aiven/go-client-codegen/handler/billinggroup" clickhouse "github.com/aiven/go-client-codegen/handler/clickhouse" @@ -51,6 +52,7 @@ func newClient(doer doer) Client { AccountHandler: account.NewHandler(doer), AccountTeamHandler: accountteam.NewHandler(doer), AccountTeamMemberHandler: accountteammember.NewHandler(doer), + AlloyDBOmniHandler: alloydbomni.NewHandler(doer), ApplicationUserHandler: applicationuser.NewHandler(doer), BillingGroupHandler: billinggroup.NewHandler(doer), ClickHouseHandler: clickhouse.NewHandler(doer), @@ -88,6 +90,7 @@ type client struct { accountauthentication.AccountAuthenticationHandler accountteam.AccountTeamHandler accountteammember.AccountTeamMemberHandler + alloydbomni.AlloyDBOmniHandler applicationuser.ApplicationUserHandler billinggroup.BillingGroupHandler clickhouse.ClickHouseHandler @@ -123,6 +126,7 @@ type Client interface { accountauthentication.Handler accountteam.Handler accountteammember.Handler + alloydbomni.Handler applicationuser.Handler billinggroup.Handler clickhouse.Handler diff --git a/config.yaml b/config.yaml index aa95b39..ffa93f5 100644 --- a/config.yaml +++ b/config.yaml @@ -38,6 +38,10 @@ AccountTeamMember: - AccountTeamMembersDelete - AccountTeamMembersInvite - AccountTeamMembersList +AlloyDBOmni: + - AlloyDbOmniGoogleCloudPrivateKeyIdentify + - AlloyDbOmniGoogleCloudPrivateKeyRemove + - AlloyDbOmniGoogleCloudPrivateKeySet ApplicationUser: - ApplicationUserAccessTokenCreate - ApplicationUserAccessTokenDelete @@ -250,9 +254,6 @@ ProjectBilling: - ProjectInvoiceGet - ProjectInvoiceList Service: - - AlloyDbOmniGoogleCloudPrivateKeyIdentify - - AlloyDbOmniGoogleCloudPrivateKeyRemove - - AlloyDbOmniGoogleCloudPrivateKeySet - ListProjectServiceTypes - ListPublicServiceTypes - ListServiceVersions diff --git a/handler/alloydbomni/alloydbomni.go b/handler/alloydbomni/alloydbomni.go new file mode 100644 index 0000000..30e5c85 --- /dev/null +++ b/handler/alloydbomni/alloydbomni.go @@ -0,0 +1,103 @@ +// Code generated by Aiven. DO NOT EDIT. + +package alloydbomni + +import ( + "context" + "encoding/json" + "fmt" + "net/url" +) + +type Handler interface { + // AlloyDbOmniGoogleCloudPrivateKeyIdentify get Google service account key + // GET /v1/project/{project}/service/{service_name}/alloydbomni/google_cloud_private_key + // https://api.aiven.io/doc/#tag/Service:_AlloyDB_Omni/operation/AlloyDbOmniGoogleCloudPrivateKeyIdentify + AlloyDbOmniGoogleCloudPrivateKeyIdentify(ctx context.Context, project string, serviceName string) (*AlloyDbOmniGoogleCloudPrivateKeyIdentifyOut, error) + + // AlloyDbOmniGoogleCloudPrivateKeyRemove delete Google service account key + // DELETE /v1/project/{project}/service/{service_name}/alloydbomni/google_cloud_private_key + // https://api.aiven.io/doc/#tag/Service:_AlloyDB_Omni/operation/AlloyDbOmniGoogleCloudPrivateKeyRemove + AlloyDbOmniGoogleCloudPrivateKeyRemove(ctx context.Context, project string, serviceName string) (*AlloyDbOmniGoogleCloudPrivateKeyRemoveOut, error) + + // AlloyDbOmniGoogleCloudPrivateKeySet add Google service account key + // POST /v1/project/{project}/service/{service_name}/alloydbomni/google_cloud_private_key + // https://api.aiven.io/doc/#tag/Service:_AlloyDB_Omni/operation/AlloyDbOmniGoogleCloudPrivateKeySet + AlloyDbOmniGoogleCloudPrivateKeySet(ctx context.Context, project string, serviceName string, in *AlloyDbOmniGoogleCloudPrivateKeySetIn) (*AlloyDbOmniGoogleCloudPrivateKeySetOut, error) +} + +// doer http client +type doer interface { + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) +} + +func NewHandler(doer doer) AlloyDBOmniHandler { + return AlloyDBOmniHandler{doer} +} + +type AlloyDBOmniHandler struct { + doer doer +} + +func (h *AlloyDBOmniHandler) AlloyDbOmniGoogleCloudPrivateKeyIdentify(ctx context.Context, project string, serviceName string) (*AlloyDbOmniGoogleCloudPrivateKeyIdentifyOut, error) { + path := fmt.Sprintf("/v1/project/%s/service/%s/alloydbomni/google_cloud_private_key", url.PathEscape(project), url.PathEscape(serviceName)) + b, err := h.doer.Do(ctx, "AlloyDbOmniGoogleCloudPrivateKeyIdentify", "GET", path, nil) + if err != nil { + return nil, err + } + out := new(AlloyDbOmniGoogleCloudPrivateKeyIdentifyOut) + err = json.Unmarshal(b, out) + if err != nil { + return nil, err + } + return out, nil +} +func (h *AlloyDBOmniHandler) AlloyDbOmniGoogleCloudPrivateKeyRemove(ctx context.Context, project string, serviceName string) (*AlloyDbOmniGoogleCloudPrivateKeyRemoveOut, error) { + path := fmt.Sprintf("/v1/project/%s/service/%s/alloydbomni/google_cloud_private_key", url.PathEscape(project), url.PathEscape(serviceName)) + b, err := h.doer.Do(ctx, "AlloyDbOmniGoogleCloudPrivateKeyRemove", "DELETE", path, nil) + if err != nil { + return nil, err + } + out := new(AlloyDbOmniGoogleCloudPrivateKeyRemoveOut) + err = json.Unmarshal(b, out) + if err != nil { + return nil, err + } + return out, nil +} +func (h *AlloyDBOmniHandler) AlloyDbOmniGoogleCloudPrivateKeySet(ctx context.Context, project string, serviceName string, in *AlloyDbOmniGoogleCloudPrivateKeySetIn) (*AlloyDbOmniGoogleCloudPrivateKeySetOut, error) { + path := fmt.Sprintf("/v1/project/%s/service/%s/alloydbomni/google_cloud_private_key", url.PathEscape(project), url.PathEscape(serviceName)) + b, err := h.doer.Do(ctx, "AlloyDbOmniGoogleCloudPrivateKeySet", "POST", path, in) + if err != nil { + return nil, err + } + out := new(AlloyDbOmniGoogleCloudPrivateKeySetOut) + err = json.Unmarshal(b, out) + if err != nil { + return nil, err + } + return out, nil +} + +// AlloyDbOmniGoogleCloudPrivateKeyIdentifyOut AlloyDbOmniGoogleCloudPrivateKeyIdentifyResponse +type AlloyDbOmniGoogleCloudPrivateKeyIdentifyOut struct { + ClientEmail string `json:"client_email"` // Email address of Google service account key + PrivateKeyId string `json:"private_key_id"` // Google service account key ID +} + +// AlloyDbOmniGoogleCloudPrivateKeyRemoveOut AlloyDbOmniGoogleCloudPrivateKeyRemoveResponse +type AlloyDbOmniGoogleCloudPrivateKeyRemoveOut struct { + ClientEmail string `json:"client_email"` // Email address of Google service account key + PrivateKeyId string `json:"private_key_id"` // Google service account key ID +} + +// AlloyDbOmniGoogleCloudPrivateKeySetIn AlloyDbOmniGoogleCloudPrivateKeySetRequestBody +type AlloyDbOmniGoogleCloudPrivateKeySetIn struct { + PrivateKey string `json:"private_key"` // Google Service Account Credentials +} + +// AlloyDbOmniGoogleCloudPrivateKeySetOut AlloyDbOmniGoogleCloudPrivateKeySetResponse +type AlloyDbOmniGoogleCloudPrivateKeySetOut struct { + ClientEmail string `json:"client_email"` // Email address of Google service account key + PrivateKeyId string `json:"private_key_id"` // Google service account key ID +} diff --git a/handler/service/service.go b/handler/service/service.go index 384bfa5..470946b 100644 --- a/handler/service/service.go +++ b/handler/service/service.go @@ -11,21 +11,6 @@ import ( ) type Handler interface { - // AlloyDbOmniGoogleCloudPrivateKeyIdentify get Google service account key - // GET /v1/project/{project}/service/{service_name}/alloydbomni/google_cloud_private_key - // https://api.aiven.io/doc/#tag/Service:_AlloyDB_Omni/operation/AlloyDbOmniGoogleCloudPrivateKeyIdentify - AlloyDbOmniGoogleCloudPrivateKeyIdentify(ctx context.Context, project string, serviceName string) (*AlloyDbOmniGoogleCloudPrivateKeyIdentifyOut, error) - - // AlloyDbOmniGoogleCloudPrivateKeyRemove delete Google service account key - // DELETE /v1/project/{project}/service/{service_name}/alloydbomni/google_cloud_private_key - // https://api.aiven.io/doc/#tag/Service:_AlloyDB_Omni/operation/AlloyDbOmniGoogleCloudPrivateKeyRemove - AlloyDbOmniGoogleCloudPrivateKeyRemove(ctx context.Context, project string, serviceName string) (*AlloyDbOmniGoogleCloudPrivateKeyRemoveOut, error) - - // AlloyDbOmniGoogleCloudPrivateKeySet add Google service account key - // POST /v1/project/{project}/service/{service_name}/alloydbomni/google_cloud_private_key - // https://api.aiven.io/doc/#tag/Service:_AlloyDB_Omni/operation/AlloyDbOmniGoogleCloudPrivateKeySet - AlloyDbOmniGoogleCloudPrivateKeySet(ctx context.Context, project string, serviceName string, in *AlloyDbOmniGoogleCloudPrivateKeySetIn) (*AlloyDbOmniGoogleCloudPrivateKeySetOut, error) - // ListProjectServiceTypes list service types for a project // GET /v1/project/{project}/service_types // https://api.aiven.io/doc/#tag/Service/operation/ListProjectServiceTypes @@ -275,45 +260,6 @@ type ServiceHandler struct { doer doer } -func (h *ServiceHandler) AlloyDbOmniGoogleCloudPrivateKeyIdentify(ctx context.Context, project string, serviceName string) (*AlloyDbOmniGoogleCloudPrivateKeyIdentifyOut, error) { - path := fmt.Sprintf("/v1/project/%s/service/%s/alloydbomni/google_cloud_private_key", url.PathEscape(project), url.PathEscape(serviceName)) - b, err := h.doer.Do(ctx, "AlloyDbOmniGoogleCloudPrivateKeyIdentify", "GET", path, nil) - if err != nil { - return nil, err - } - out := new(AlloyDbOmniGoogleCloudPrivateKeyIdentifyOut) - err = json.Unmarshal(b, out) - if err != nil { - return nil, err - } - return out, nil -} -func (h *ServiceHandler) AlloyDbOmniGoogleCloudPrivateKeyRemove(ctx context.Context, project string, serviceName string) (*AlloyDbOmniGoogleCloudPrivateKeyRemoveOut, error) { - path := fmt.Sprintf("/v1/project/%s/service/%s/alloydbomni/google_cloud_private_key", url.PathEscape(project), url.PathEscape(serviceName)) - b, err := h.doer.Do(ctx, "AlloyDbOmniGoogleCloudPrivateKeyRemove", "DELETE", path, nil) - if err != nil { - return nil, err - } - out := new(AlloyDbOmniGoogleCloudPrivateKeyRemoveOut) - err = json.Unmarshal(b, out) - if err != nil { - return nil, err - } - return out, nil -} -func (h *ServiceHandler) AlloyDbOmniGoogleCloudPrivateKeySet(ctx context.Context, project string, serviceName string, in *AlloyDbOmniGoogleCloudPrivateKeySetIn) (*AlloyDbOmniGoogleCloudPrivateKeySetOut, error) { - path := fmt.Sprintf("/v1/project/%s/service/%s/alloydbomni/google_cloud_private_key", url.PathEscape(project), url.PathEscape(serviceName)) - b, err := h.doer.Do(ctx, "AlloyDbOmniGoogleCloudPrivateKeySet", "POST", path, in) - if err != nil { - return nil, err - } - out := new(AlloyDbOmniGoogleCloudPrivateKeySetOut) - err = json.Unmarshal(b, out) - if err != nil { - return nil, err - } - return out, nil -} func (h *ServiceHandler) ListProjectServiceTypes(ctx context.Context, project string) (*ListProjectServiceTypesOut, error) { path := fmt.Sprintf("/v1/project/%s/service_types", url.PathEscape(project)) b, err := h.doer.Do(ctx, "ListProjectServiceTypes", "GET", path, nil) @@ -942,29 +888,6 @@ type AlertOut struct { Severity string `json:"severity"` // Severity of the event } -// AlloyDbOmniGoogleCloudPrivateKeyIdentifyOut AlloyDbOmniGoogleCloudPrivateKeyIdentifyResponse -type AlloyDbOmniGoogleCloudPrivateKeyIdentifyOut struct { - ClientEmail string `json:"client_email"` // Email address of Google service account key - PrivateKeyId string `json:"private_key_id"` // Google service account key ID -} - -// AlloyDbOmniGoogleCloudPrivateKeyRemoveOut AlloyDbOmniGoogleCloudPrivateKeyRemoveResponse -type AlloyDbOmniGoogleCloudPrivateKeyRemoveOut struct { - ClientEmail string `json:"client_email"` // Email address of Google service account key - PrivateKeyId string `json:"private_key_id"` // Google service account key ID -} - -// AlloyDbOmniGoogleCloudPrivateKeySetIn AlloyDbOmniGoogleCloudPrivateKeySetRequestBody -type AlloyDbOmniGoogleCloudPrivateKeySetIn struct { - PrivateKey string `json:"private_key"` // Google Service Account Credentials -} - -// AlloyDbOmniGoogleCloudPrivateKeySetOut AlloyDbOmniGoogleCloudPrivateKeySetResponse -type AlloyDbOmniGoogleCloudPrivateKeySetOut struct { - ClientEmail string `json:"client_email"` // Email address of Google service account key - PrivateKeyId string `json:"private_key_id"` // Google service account key ID -} - // AlloydbomniOut Service type information type AlloydbomniOut struct { DefaultVersion *string `json:"default_version,omitempty"` // Default version of the service if no explicit version is defined