diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection.md b/docs/generate_doc/ticloud_serverless_private-link-connection.md index 0ce557d5..23d2f300 100644 --- a/docs/generate_doc/ticloud_serverless_private-link-connection.md +++ b/docs/generate_doc/ticloud_serverless_private-link-connection.md @@ -19,9 +19,11 @@ Manage private link connections for dataflow ### SEE ALSO * [ticloud serverless](ticloud_serverless.md) - Manage TiDB Cloud Serverless clusters +* [ticloud serverless private-link-connection attach-domains](ticloud_serverless_private-link-connection_attach-domains.md) - Attach domains to a private link connection * [ticloud serverless private-link-connection create](ticloud_serverless_private-link-connection_create.md) - Create a private link connection for dataflow * [ticloud serverless private-link-connection delete](ticloud_serverless_private-link-connection_delete.md) - Delete a private link connection for dataflow * [ticloud serverless private-link-connection describe](ticloud_serverless_private-link-connection_describe.md) - Describe a private link connection for dataflow +* [ticloud serverless private-link-connection detach-domains](ticloud_serverless_private-link-connection_detach-domains.md) - Detach domains from a private link connection * [ticloud serverless private-link-connection list](ticloud_serverless_private-link-connection_list.md) - List private link connections for dataflow * [ticloud serverless private-link-connection zones](ticloud_serverless_private-link-connection_zones.md) - Get account and availability zones diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_attach-domains.md b/docs/generate_doc/ticloud_serverless_private-link-connection_attach-domains.md new file mode 100644 index 00000000..28f437ff --- /dev/null +++ b/docs/generate_doc/ticloud_serverless_private-link-connection_attach-domains.md @@ -0,0 +1,41 @@ +## ticloud serverless private-link-connection attach-domains + +Attach domains to a private link connection + +``` +ticloud serverless private-link-connection attach-domains [flags] +``` + +### Examples + +``` + Attach domain (interactive): + $ ticloud serverless private-link-connection attach-domains + + Attach domain (non-interactive): + $ ticloud serverless private-link-connection attach-domains -c --private-link-connection-id --type --unique-name +``` + +### Options + +``` + -c, --cluster-id string The cluster ID. + --dry-run Set dry run mode to only show generated domains without attaching them. + -h, --help help for attach-domains + --private-link-connection-id string The private link connection ID. + --type string The type of domain to attach, one of: [TIDBCLOUD_MANAGED CONFLUENT] + --unique-name string The unique name of the domain to attach, you can use --dry-run to generate the unique name when attaching a TiDB Cloud managed domain. +``` + +### Options inherited from parent commands + +``` + -D, --debug Enable debug mode + --no-color Disable color output + -P, --profile string Profile to use from your configuration file +``` + +### SEE ALSO + +* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow + diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_attach.md b/docs/generate_doc/ticloud_serverless_private-link-connection_attach.md new file mode 100644 index 00000000..fb0777f9 --- /dev/null +++ b/docs/generate_doc/ticloud_serverless_private-link-connection_attach.md @@ -0,0 +1,41 @@ +## ticloud serverless private-link-connection attach + +Attach domains to a private link connection + +``` +ticloud serverless private-link-connection attach [flags] +``` + +### Examples + +``` + Attach domain (interactive): + $ ticloud serverless private-link-connection attach + + Attach domain (non-interactive): + $ ticloud serverless private-link-connection attach -c --private-link-connection-id --type --unique-name +``` + +### Options + +``` + -c, --cluster-id string The cluster ID. + --dry-run set dry run mode to only show generated domains without attaching them. + -h, --help help for attach + --private-link-connection-id string The private link connection ID. + --type string The type of domain to attach, one of: [TIDBCLOUD_MANAGED CONFLUENT] + --unique-name string The unique name of the domain to attach, you can use --dry-run to generate the unique name when attaching a TiDB Cloud managed domain. +``` + +### Options inherited from parent commands + +``` + -D, --debug Enable debug mode + --no-color Disable color output + -P, --profile string Profile to use from your configuration file +``` + +### SEE ALSO + +* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow + diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_delete.md b/docs/generate_doc/ticloud_serverless_private-link-connection_delete.md index e717a613..504b8ccc 100644 --- a/docs/generate_doc/ticloud_serverless_private-link-connection_delete.md +++ b/docs/generate_doc/ticloud_serverless_private-link-connection_delete.md @@ -13,7 +13,7 @@ ticloud serverless private-link-connection delete [flags] $ ticloud serverless private-link-connection delete Delete a private link connection (non-interactive): - $ ticloud serverless private-link-connection delete -c -p + $ ticloud serverless private-link-connection delete -c --private-link-connection-id ``` ### Options diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_describe.md b/docs/generate_doc/ticloud_serverless_private-link-connection_describe.md index 470db859..b8b58327 100644 --- a/docs/generate_doc/ticloud_serverless_private-link-connection_describe.md +++ b/docs/generate_doc/ticloud_serverless_private-link-connection_describe.md @@ -13,7 +13,7 @@ ticloud serverless private-link-connection describe [flags] $ ticloud serverless private-link-connection describe Describe a private link connection (non-interactive): - $ ticloud serverless private-link-connection describe -c -p + $ ticloud serverless private-link-connection describe -c --private-link-connection-id ``` ### Options diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_detach-domains.md b/docs/generate_doc/ticloud_serverless_private-link-connection_detach-domains.md new file mode 100644 index 00000000..82015c70 --- /dev/null +++ b/docs/generate_doc/ticloud_serverless_private-link-connection_detach-domains.md @@ -0,0 +1,39 @@ +## ticloud serverless private-link-connection detach-domains + +Detach domains from a private link connection + +``` +ticloud serverless private-link-connection detach-domains [flags] +``` + +### Examples + +``` + Detach domains (interactive): + $ ticloud serverless private-link-connection detach + + Detach domains (non-interactive): + $ ticloud serverless private-link-connection detach-domains -c --private-link-connection-id --attach-domain-id +``` + +### Options + +``` + --attach-domain-id string The private link connection attach domain ID. + -c, --cluster-id string The cluster ID. + -h, --help help for detach-domains + --private-link-connection-id string The private link connection ID. +``` + +### Options inherited from parent commands + +``` + -D, --debug Enable debug mode + --no-color Disable color output + -P, --profile string Profile to use from your configuration file +``` + +### SEE ALSO + +* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow + diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_detach.md b/docs/generate_doc/ticloud_serverless_private-link-connection_detach.md new file mode 100644 index 00000000..6e6034d6 --- /dev/null +++ b/docs/generate_doc/ticloud_serverless_private-link-connection_detach.md @@ -0,0 +1,39 @@ +## ticloud serverless private-link-connection detach + +Detach domains from a private link connection + +``` +ticloud serverless private-link-connection detach [flags] +``` + +### Examples + +``` + Detach domains (interactive): + $ ticloud serverless private-link-connection detach + + Detach domains (non-interactive): + $ ticloud serverless private-link-connection detach -c --private-link-connection-id --plc-attach-domain-id +``` + +### Options + +``` + -c, --cluster-id string The cluster ID. + -h, --help help for detach + --plc-attach-domain-id string The private link connection attach domain ID. + --private-link-connection-id string The private link connection ID. +``` + +### Options inherited from parent commands + +``` + -D, --debug Enable debug mode + --no-color Disable color output + -P, --profile string Profile to use from your configuration file +``` + +### SEE ALSO + +* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow + diff --git a/internal/cli/serverless/changefeed/template.go b/internal/cli/serverless/changefeed/template.go index e19f0eb3..1e30c3bd 100644 --- a/internal/cli/serverless/changefeed/template.go +++ b/internal/cli/serverless/changefeed/template.go @@ -50,7 +50,9 @@ const ( "userName": "", // required when authType is SASL_PLAIN, SASL_SCRAM_SHA_256, or SASL_SCRAM_SHA_512 "password": "", - "enableTls": false + "enableTls": false, + // Specify this field when your server rely on TLS SNI, for example, Confluent Cloud Dedicated clusters. + "serverName": "", }, "outputRawChangeEvent": false, "dataFormat": { @@ -132,7 +134,8 @@ const ( "authType": "DISABLE", "userName": "", "password": "", - "enableTls": false + "enableTls": false, + "serverName": "" }, "outputRawChangeEvent": false, "dataFormat": { diff --git a/internal/cli/serverless/privatelink/attach.go b/internal/cli/serverless/privatelink/attach.go new file mode 100644 index 00000000..d15adb6b --- /dev/null +++ b/internal/cli/serverless/privatelink/attach.go @@ -0,0 +1,199 @@ +// Copyright 2025 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package privatelink + +import ( + "fmt" + "strings" + + "github.com/AlecAivazis/survey/v2" + "github.com/fatih/color" + "github.com/juju/errors" + "github.com/spf13/cobra" + + "github.com/tidbcloud/tidbcloud-cli/internal" + "github.com/tidbcloud/tidbcloud-cli/internal/config" + "github.com/tidbcloud/tidbcloud-cli/internal/flag" + "github.com/tidbcloud/tidbcloud-cli/internal/output" + "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" + plapi "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/privatelink" +) + +type AttachDomainOpts struct { + interactive bool +} + +func (o AttachDomainOpts) NonInteractiveFlags() []string { + return []string{ + flag.ClusterID, + flag.PrivateLinkConnectionID, + flag.PLCAttachDomainType, + flag.PLCAttachDomainUniqueName, + } +} + +func (o AttachDomainOpts) RequiredFlags() []string { + return []string{ + flag.ClusterID, + flag.PrivateLinkConnectionID, + flag.PLCAttachDomainType, + } +} + +func (o *AttachDomainOpts) MarkInteractive(cmd *cobra.Command) error { + o.interactive = true + for _, fn := range o.NonInteractiveFlags() { + if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { + o.interactive = false + } + } + if !o.interactive { + for _, fn := range o.RequiredFlags() { + if err := cmd.MarkFlagRequired(fn); err != nil { + return err + } + } + } + return nil +} + +func AttachDomainCmd(h *internal.Helper) *cobra.Command { + opts := &AttachDomainOpts{interactive: true} + cmd := &cobra.Command{ + Use: "attach-domains", + Short: "Attach domains to a private link connection", + Args: cobra.NoArgs, + Example: fmt.Sprintf(` Attach domain (interactive): + $ %[1]s serverless private-link-connection attach-domains + + Attach domain (non-interactive): + $ %[1]s serverless private-link-connection attach-domains -c --private-link-connection-id --type --unique-name `, config.CliName), + PreRunE: func(cmd *cobra.Command, args []string) error { + return opts.MarkInteractive(cmd) + }, + RunE: func(cmd *cobra.Command, args []string) error { + d, err := h.Client() + if err != nil { + return err + } + ctx := cmd.Context() + + var clusterID, plcID string + var domainType plapi.PrivateLinkConnectionDomainTypeEnum + var uniqueName string + var dryRun bool + dryRun, err = cmd.Flags().GetBool(flag.DryRun) + if err != nil { + return errors.Trace(err) + } + if opts.interactive { + if !h.IOStreams.CanPrompt { + return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") + } + + project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) + if err != nil { + return err + } + cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) + if err != nil { + return err + } + clusterID = cluster.ID + + privatelink, err := cloud.GetSelectedPrivateLinkConnection(ctx, cluster.ID, int32(h.QueryPageSize), d) + if err != nil { + return err + } + plcID = privatelink.ID + + domainType, err = GetSelectedPLCAttachDomainType() + if err != nil { + return err + } + + switch domainType { + case plapi.PRIVATELINKCONNECTIONDOMAINTYPEENUM_CONFLUENT: + if err := survey.AskOne(&survey.Input{Message: "Domain unique name:"}, &uniqueName); err != nil { + return err + } + case plapi.PRIVATELINKCONNECTIONDOMAINTYPEENUM_TIDBCLOUD_MANAGED: + if !dryRun { + if err := survey.AskOne(&survey.Input{Message: "Domain unique name:"}, &uniqueName); err != nil { + return err + } + } + default: + return errors.New("invalid domain type") + } + } else { + var err error + clusterID, err = cmd.Flags().GetString(flag.ClusterID) + if err != nil { + return errors.Trace(err) + } + plcID, err = cmd.Flags().GetString(flag.PrivateLinkConnectionID) + if err != nil { + return errors.Trace(err) + } + domainTypeStr, err := cmd.Flags().GetString(flag.PLCAttachDomainType) + if err != nil { + return errors.Trace(err) + } + domainType = plapi.PrivateLinkConnectionDomainTypeEnum(domainTypeStr) + uniqueName, err = cmd.Flags().GetString(flag.PLCAttachDomainUniqueName) + if err != nil { + return errors.Trace(err) + } + + if domainType == "" { + return errors.New("domain type is required") + } + } + + body := &plapi.PrivateLinkConnectionServiceAttachDomainsBody{ + AttachDomain: plapi.AttachDomain{ + Type: domainType, + UniqueName: &uniqueName, + }, + ValidateOnly: &dryRun, + } + + resp, err := d.AttachPrivateLinkDomains(ctx, clusterID, plcID, body) + if err != nil { + return errors.Trace(err) + } + if !dryRun { + return output.PrintJson(h.IOStreams.Out, resp) + } + domains := make([]string, 0, len(resp.Domains)) + for _, domain := range resp.Domains { + domains = append(domains, *domain.Name) + } + fmt.Fprintf(h.IOStreams.Out, "unique name %s:\n%s\n", + color.BlueString("%v", *resp.UniqueName), + color.GreenString("%v", strings.Join(domains, "\n"))) + return nil + }, + } + + cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") + cmd.Flags().String(flag.PrivateLinkConnectionID, "", "The private link connection ID.") + cmd.Flags().String(flag.PLCAttachDomainType, "", fmt.Sprintf("The type of domain to attach, one of: %v", plapi.AllowedPrivateLinkConnectionDomainTypeEnumEnumValues)) + cmd.Flags().String(flag.PLCAttachDomainUniqueName, "", "The unique name of the domain to attach, you can use --dry-run to generate the unique name when attaching a TiDB Cloud managed domain.") + cmd.Flags().Bool(flag.DryRun, false, "Set dry run mode to only show generated domains without attaching them.") + + return cmd +} diff --git a/internal/cli/serverless/privatelink/delete.go b/internal/cli/serverless/privatelink/delete.go index a07eaab9..77f1ff91 100644 --- a/internal/cli/serverless/privatelink/delete.go +++ b/internal/cli/serverless/privatelink/delete.go @@ -71,7 +71,7 @@ func DeleteCmd(h *internal.Helper) *cobra.Command { $ %[1]s serverless private-link-connection delete Delete a private link connection (non-interactive): - $ %[1]s serverless private-link-connection delete -c -p `, config.CliName), + $ %[1]s serverless private-link-connection delete -c --private-link-connection-id `, config.CliName), PreRunE: func(cmd *cobra.Command, args []string) error { return opts.MarkInteractive(cmd) }, diff --git a/internal/cli/serverless/privatelink/describe.go b/internal/cli/serverless/privatelink/describe.go index c958522b..3c1d0507 100644 --- a/internal/cli/serverless/privatelink/describe.go +++ b/internal/cli/serverless/privatelink/describe.go @@ -68,7 +68,7 @@ func DescribeCmd(h *internal.Helper) *cobra.Command { $ %[1]s serverless private-link-connection describe Describe a private link connection (non-interactive): - $ %[1]s serverless private-link-connection describe -c -p `, config.CliName), + $ %[1]s serverless private-link-connection describe -c --private-link-connection-id `, config.CliName), PreRunE: func(cmd *cobra.Command, args []string) error { return opts.MarkInteractive(cmd) }, diff --git a/internal/cli/serverless/privatelink/detach.go b/internal/cli/serverless/privatelink/detach.go new file mode 100644 index 00000000..50c41226 --- /dev/null +++ b/internal/cli/serverless/privatelink/detach.go @@ -0,0 +1,143 @@ +// Copyright 2025 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package privatelink + +import ( + "fmt" + "strings" + + "github.com/fatih/color" + "github.com/juju/errors" + "github.com/spf13/cobra" + + "github.com/tidbcloud/tidbcloud-cli/internal" + "github.com/tidbcloud/tidbcloud-cli/internal/config" + "github.com/tidbcloud/tidbcloud-cli/internal/flag" + "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" + plapi "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/privatelink" +) + +type DetachDomainOpts struct { + interactive bool +} + +func (o DetachDomainOpts) NonInteractiveFlags() []string { + return []string{ + flag.ClusterID, + flag.PrivateLinkConnectionID, + flag.PLCAttachDomainID, + } +} + +func (o *DetachDomainOpts) MarkInteractive(cmd *cobra.Command) error { + o.interactive = true + for _, fn := range o.NonInteractiveFlags() { + if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { + o.interactive = false + } + } + if !o.interactive { + for _, fn := range o.NonInteractiveFlags() { + if err := cmd.MarkFlagRequired(fn); err != nil { + return err + } + } + } + return nil +} + +func DetachDomainCmd(h *internal.Helper) *cobra.Command { + opts := &DetachDomainOpts{interactive: true} + + cmd := &cobra.Command{ + Use: "detach-domains", + Short: "Detach domains from a private link connection", + Args: cobra.NoArgs, + Example: fmt.Sprintf(` Detach domains (interactive): + $ %[1]s serverless private-link-connection detach + + Detach domains (non-interactive): + $ %[1]s serverless private-link-connection detach-domains -c --private-link-connection-id --attach-domain-id `, config.CliName), + PreRunE: func(cmd *cobra.Command, args []string) error { + return opts.MarkInteractive(cmd) + }, + RunE: func(cmd *cobra.Command, args []string) error { + d, err := h.Client() + if err != nil { + return err + } + ctx := cmd.Context() + + var clusterID, plcID, attachID string + if opts.interactive { + if !h.IOStreams.CanPrompt { + return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") + } + project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) + if err != nil { + return err + } + cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) + if err != nil { + return err + } + clusterID = cluster.ID + privatelink, err := cloud.GetSelectedPrivateLinkConnection(ctx, cluster.ID, int32(h.QueryPageSize), d) + if err != nil { + return err + } + plcID = privatelink.ID + attach, err := cloud.GetSelectedAttachDomain(ctx, cluster.ID, privatelink.ID, d) + if err != nil { + return err + } + attachID = attach.ID + } else { + var err error + clusterID, err = cmd.Flags().GetString(flag.ClusterID) + if err != nil { + return errors.Trace(err) + } + plcID, err = cmd.Flags().GetString(flag.PrivateLinkConnectionID) + if err != nil { + return errors.Trace(err) + } + attachID, err = cmd.Flags().GetString(flag.PLCAttachDomainID) + if err != nil { + return errors.Trace(err) + } + } + + body := &plapi.PrivateLinkConnectionServiceDetachDomainsBody{ + AttachDomainId: attachID, + } + resp, err := d.DetachPrivateLinkDomains(ctx, clusterID, plcID, body) + if err != nil { + return errors.Trace(err) + } + domains := make([]string, 0, len(resp.Domains)) + for _, domain := range resp.Domains { + domains = append(domains, *domain.Name) + } + fmt.Fprintf(h.IOStreams.Out, "Successfully detached domains:\n%s\n", color.GreenString("%v", strings.Join(domains, "\n"))) + return nil + }, + } + + cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") + cmd.Flags().String(flag.PrivateLinkConnectionID, "", "The private link connection ID.") + cmd.Flags().String(flag.PLCAttachDomainID, "", "The private link connection attach domain ID.") + return cmd +} diff --git a/internal/cli/serverless/privatelink/privatelink.go b/internal/cli/serverless/privatelink/privatelink.go index acf24108..7adce7fa 100644 --- a/internal/cli/serverless/privatelink/privatelink.go +++ b/internal/cli/serverless/privatelink/privatelink.go @@ -33,6 +33,8 @@ func PrivateLinkConnectionCmd(h *internal.Helper) *cobra.Command { DeleteCmd(h), ListCmd(h), GetZonesCmd(h), + AttachDomainCmd(h), + DetachDomainCmd(h), ) return cmd diff --git a/internal/cli/serverless/privatelink/ui.go b/internal/cli/serverless/privatelink/ui.go index 85299f05..4203191d 100644 --- a/internal/cli/serverless/privatelink/ui.go +++ b/internal/cli/serverless/privatelink/ui.go @@ -54,3 +54,28 @@ func GetSelectedPrivateLinkConnectionType() (privatelink.PrivateLinkConnectionTy } return resp.(privatelink.PrivateLinkConnectionTypeEnum), nil } + +func GetSelectedPLCAttachDomainType() (privatelink.PrivateLinkConnectionDomainTypeEnum, error) { + types := make([]interface{}, 0, len(privatelink.AllowedPrivateLinkConnectionDomainTypeEnumEnumValues)) + for _, v := range privatelink.AllowedPrivateLinkConnectionDomainTypeEnumEnumValues { + types = append(types, v) + } + selectModel, err := ui.InitialSelectModel(types, "Choose the private link connection domain type:") + if err != nil { + return "", errors.Trace(err) + } + p := tea.NewProgram(selectModel) + model, err := p.Run() + if err != nil { + return "", errors.Trace(err) + } + if m, _ := model.(ui.SelectModel); m.Interrupted { + return "", util.InterruptError + } + + resp := model.(ui.SelectModel).GetSelectedItem() + if resp == nil { + return "", errors.New("no private link connection domain type selected") + } + return resp.(privatelink.PrivateLinkConnectionDomainTypeEnum), nil +} diff --git a/internal/flag/flag.go b/internal/flag/flag.go index 97529487..807940b7 100644 --- a/internal/flag/flag.go +++ b/internal/flag/flag.go @@ -124,6 +124,9 @@ const ( AWSEndpointServiceName string = "aws.endpoint-service-name" AWSEndpointServiceRegion string = "aws.endpoint-service-region" AlicloudEndpointServiceName string = "alicloud.endpoint-service-name" + PLCAttachDomainType string = "type" + PLCAttachDomainUniqueName string = "unique-name" + PLCAttachDomainID string = "attach-domain-id" MigrationID string = "migration-id" MigrationIDShort string = "m" diff --git a/internal/mock/api_client.go b/internal/mock/api_client.go index 95bada0f..c90d0790 100644 --- a/internal/mock/api_client.go +++ b/internal/mock/api_client.go @@ -32,6 +32,36 @@ type TiDBCloudClient struct { mock.Mock } +// AttachPrivateLinkDomains provides a mock function with given fields: ctx, clusterId, privateLinkConnectionId, body +func (_m *TiDBCloudClient) AttachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) (*privatelink.AttachDomain, error) { + ret := _m.Called(ctx, clusterId, privateLinkConnectionId, body) + + if len(ret) == 0 { + panic("no return value specified for AttachPrivateLinkDomains") + } + + var r0 *privatelink.AttachDomain + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) (*privatelink.AttachDomain, error)); ok { + return rf(ctx, clusterId, privateLinkConnectionId, body) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) *privatelink.AttachDomain); ok { + r0 = rf(ctx, clusterId, privateLinkConnectionId, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*privatelink.AttachDomain) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) error); ok { + r1 = rf(ctx, clusterId, privateLinkConnectionId, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // CancelExport provides a mock function with given fields: ctx, clusterId, exportId func (_m *TiDBCloudClient) CancelExport(ctx context.Context, clusterId string, exportId string) (*export.Export, error) { ret := _m.Called(ctx, clusterId, exportId) @@ -734,6 +764,36 @@ func (_m *TiDBCloudClient) DescribeSchemaTable(ctx context.Context, clusterId st return r0, r1 } +// DetachPrivateLinkDomains provides a mock function with given fields: ctx, clusterId, privateLinkConnectionId, body +func (_m *TiDBCloudClient) DetachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) (*privatelink.AttachDomain, error) { + ret := _m.Called(ctx, clusterId, privateLinkConnectionId, body) + + if len(ret) == 0 { + panic("no return value specified for DetachPrivateLinkDomains") + } + + var r0 *privatelink.AttachDomain + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) (*privatelink.AttachDomain, error)); ok { + return rf(ctx, clusterId, privateLinkConnectionId, body) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) *privatelink.AttachDomain); ok { + r0 = rf(ctx, clusterId, privateLinkConnectionId, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*privatelink.AttachDomain) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) error); ok { + r1 = rf(ctx, clusterId, privateLinkConnectionId, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // DownloadAuditLogs provides a mock function with given fields: ctx, clusterID, body func (_m *TiDBCloudClient) DownloadAuditLogs(ctx context.Context, clusterID string, body *auditlog.DatabaseAuditLogServiceDownloadAuditLogFilesBody) (*auditlog.DownloadAuditLogFilesResponse, error) { ret := _m.Called(ctx, clusterID, body) diff --git a/internal/service/cloud/api_client.go b/internal/service/cloud/api_client.go index d70291a6..5e4f9533 100644 --- a/internal/service/cloud/api_client.go +++ b/internal/service/cloud/api_client.go @@ -168,6 +168,8 @@ type TiDBCloudClient interface { GetPrivateLinkConnection(ctx context.Context, clusterId string, privateLinkConnectionId string) (*privatelink.PrivateLinkConnection, error) ListPrivateLinkConnections(ctx context.Context, clusterId string, pageSize *int32, pageToken *string) (*privatelink.ListPrivateLinkConnectionsResponse, error) GetPrivateLinkAvailabilityZones(ctx context.Context, clusterId string) (*privatelink.GetAvailabilityZonesResponse, error) + AttachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) (*privatelink.AttachDomain, error) + DetachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) (*privatelink.AttachDomain, error) // ===== Private Link Connection ===== } @@ -716,6 +718,24 @@ func (d *ClientDelegate) GetPrivateLinkAvailabilityZones(ctx context.Context, cl return res, parseError(err, h) } +func (d *ClientDelegate) AttachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) (*privatelink.AttachDomain, error) { + r := d.plc.PrivateLinkConnectionServiceAPI.PrivateLinkConnectionServiceAttachDomains(ctx, clusterId, privateLinkConnectionId) + if body != nil { + r = r.Body(*body) + } + res, h, err := r.Execute() + return res, parseError(err, h) +} + +func (d *ClientDelegate) DetachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) (*privatelink.AttachDomain, error) { + r := d.plc.PrivateLinkConnectionServiceAPI.PrivateLinkConnectionServiceDetachDomains(ctx, clusterId, privateLinkConnectionId) + if body != nil { + r = r.Body(*body) + } + res, h, err := r.Execute() + return res, parseError(err, h) +} + // ===== Private Link Connection ===== func NewApiClient(rt http.RoundTripper, serverlessEndpoint string, iamEndpoint string) (*branch.APIClient, *cluster.APIClient, *br.APIClient, *imp.APIClient, *export.APIClient, *iam.APIClient, *auditlog.APIClient, *cdc.APIClient, *privatelink.APIClient, *migration.APIClient, error) { diff --git a/internal/service/cloud/logic.go b/internal/service/cloud/logic.go index f9f26c3a..57b27561 100644 --- a/internal/service/cloud/logic.go +++ b/internal/service/cloud/logic.go @@ -105,6 +105,16 @@ type PrivateLinkConnection struct { DisplayName string } +type AttachDomain struct { + ID string + UniqueName string + Type string +} + +func (a AttachDomain) String() string { + return fmt.Sprintf("%s-%s(%s)", a.Type, a.UniqueName, a.ID) +} + func (p PrivateLinkConnection) String() string { return fmt.Sprintf("%s(%s)", p.DisplayName, p.ID) } @@ -1199,6 +1209,48 @@ func GetSelectedPrivateLinkConnection(ctx context.Context, clusterID string, pag return resp.(*PrivateLinkConnection), nil } +func GetSelectedAttachDomain(ctx context.Context, clusterID, plcId string, client TiDBCloudClient) (*AttachDomain, error) { + plc, err := client.GetPrivateLinkConnection(ctx, clusterID, plcId) + if err != nil { + return nil, err + } + + var items = make([]interface{}, 0) + for _, item := range plc.AttachedDomains { + items = append(items, &AttachDomain{ + ID: *item.AttachDomainId, + UniqueName: *item.UniqueName, + Type: string(item.Type), + }) + } + + if len(items) == 0 { + return nil, fmt.Errorf("no available private link connection attach domain found") + } + + selectModel, err := ui.InitialSelectModel(items, "Choose the attached domain:") + if err != nil { + return nil, errors.Trace(err) + } + itemsPerPage := 6 + selectModel.EnablePagination(itemsPerPage) + selectModel.EnableFilter() + + p := tea.NewProgram(selectModel) + model, err := p.Run() + if err != nil { + return nil, errors.Trace(err) + } + if m, _ := model.(ui.SelectModel); m.Interrupted { + return nil, util.InterruptError + } + resp := model.(ui.SelectModel).GetSelectedItem() + if resp == nil { + return nil, errors.New("no attach domain") + } + return resp.(*AttachDomain), nil +} + func RetrievePrivateLinkConnections(ctx context.Context, clusterID string, pageSize int32, d TiDBCloudClient) ([]privatelink.PrivateLinkConnection, error) { var pageToken *string resp, err := d.ListPrivateLinkConnections(ctx, clusterID, &pageSize, nil) diff --git a/pkg/tidbcloud/v1beta1/serverless/cdc.swagger.json b/pkg/tidbcloud/v1beta1/serverless/cdc.swagger.json index bf561b90..50b66c63 100644 --- a/pkg/tidbcloud/v1beta1/serverless/cdc.swagger.json +++ b/pkg/tidbcloud/v1beta1/serverless/cdc.swagger.json @@ -1059,6 +1059,10 @@ }, "enableTls": { "type": "boolean" + }, + "serverName": { + "type": "string", + "description": "server name for tls verification. Specify this field when your server rely on TLS SNI, for example, Confluent Cloud Dedicated clusters." } } }, @@ -1548,4 +1552,4 @@ "description": " - ONE_TOPIC: One topic for all data.\n - BY_TABLE: Dispatch by table.\n - BY_DATABASE: Dispatch by database." } } -} +} \ No newline at end of file diff --git a/pkg/tidbcloud/v1beta1/serverless/cdc/api/openapi.yaml b/pkg/tidbcloud/v1beta1/serverless/cdc/api/openapi.yaml index d209d095..c172fe99 100644 --- a/pkg/tidbcloud/v1beta1/serverless/cdc/api/openapi.yaml +++ b/pkg/tidbcloud/v1beta1/serverless/cdc/api/openapi.yaml @@ -857,6 +857,11 @@ components: type: string enableTls: type: boolean + serverName: + description: "server name for tls verification. Specify this field when\ + \ your server rely on TLS SNI, for example, Confluent Cloud Dedicated\ + \ clusters." + type: string type: object Kafka.Broker: properties: diff --git a/pkg/tidbcloud/v1beta1/serverless/cdc/model_kafka_authentication.go b/pkg/tidbcloud/v1beta1/serverless/cdc/model_kafka_authentication.go index 24a7d41f..9e166e87 100644 --- a/pkg/tidbcloud/v1beta1/serverless/cdc/model_kafka_authentication.go +++ b/pkg/tidbcloud/v1beta1/serverless/cdc/model_kafka_authentication.go @@ -19,10 +19,12 @@ var _ MappedNullable = &KafkaAuthentication{} // KafkaAuthentication struct for KafkaAuthentication type KafkaAuthentication struct { - AuthType *KafkaAuthTypeEnum `json:"authType,omitempty"` - Username *string `json:"username,omitempty"` - Password *string `json:"password,omitempty"` - EnableTls *bool `json:"enableTls,omitempty"` + AuthType *KafkaAuthTypeEnum `json:"authType,omitempty"` + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` + EnableTls *bool `json:"enableTls,omitempty"` + // server name for tls verification. Specify this field when your server rely on TLS SNI, for example, Confluent Cloud Dedicated clusters. + ServerName *string `json:"serverName,omitempty"` AdditionalProperties map[string]interface{} } @@ -173,6 +175,38 @@ func (o *KafkaAuthentication) SetEnableTls(v bool) { o.EnableTls = &v } +// GetServerName returns the ServerName field value if set, zero value otherwise. +func (o *KafkaAuthentication) GetServerName() string { + if o == nil || IsNil(o.ServerName) { + var ret string + return ret + } + return *o.ServerName +} + +// GetServerNameOk returns a tuple with the ServerName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *KafkaAuthentication) GetServerNameOk() (*string, bool) { + if o == nil || IsNil(o.ServerName) { + return nil, false + } + return o.ServerName, true +} + +// HasServerName returns a boolean if a field has been set. +func (o *KafkaAuthentication) HasServerName() bool { + if o != nil && !IsNil(o.ServerName) { + return true + } + + return false +} + +// SetServerName gets a reference to the given string and assigns it to the ServerName field. +func (o *KafkaAuthentication) SetServerName(v string) { + o.ServerName = &v +} + func (o KafkaAuthentication) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -195,6 +229,9 @@ func (o KafkaAuthentication) ToMap() (map[string]interface{}, error) { if !IsNil(o.EnableTls) { toSerialize["enableTls"] = o.EnableTls } + if !IsNil(o.ServerName) { + toSerialize["serverName"] = o.ServerName + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -221,6 +258,7 @@ func (o *KafkaAuthentication) UnmarshalJSON(data []byte) (err error) { delete(additionalProperties, "username") delete(additionalProperties, "password") delete(additionalProperties, "enableTls") + delete(additionalProperties, "serverName") o.AdditionalProperties = additionalProperties } diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink.swagger.json b/pkg/tidbcloud/v1beta1/serverless/privatelink.swagger.json index 53590312..4c3d0473 100644 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink.swagger.json +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink.swagger.json @@ -137,6 +137,20 @@ "in": "query", "required": false, "type": "string" + }, + { + "name": "state", + "description": " - CREATING: The private link connection is being created.\n - ACTIVE: The private link connection is active.\n - FAILED: The private link connection is in failed state.\n - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service.\n - DELETING: The private link connection is being deleted.", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "CREATING", + "ACTIVE", + "FAILED", + "PENDING_ACCEPTANCE", + "DELETING" + ] } ], "tags": [ @@ -213,6 +227,100 @@ "PrivateLinkConnectionService" ] } + }, + "/v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:attachDomains": { + "post": { + "summary": "Attach domains for private link connection.", + "operationId": "PrivateLinkConnectionService_AttachDomains", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/AttachDomain" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Status" + } + } + }, + "parameters": [ + { + "name": "clusterId", + "description": "The cluster ID.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "privateLinkConnectionId", + "description": "The private link connection ID.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PrivateLinkConnectionService.AttachDomainsBody" + } + } + ], + "tags": [ + "PrivateLinkConnectionService" + ] + } + }, + "/v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:detachDomains": { + "post": { + "summary": "Detach domains for private link connection.", + "operationId": "PrivateLinkConnectionService_DetachDomains", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/AttachDomain" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Status" + } + } + }, + "parameters": [ + { + "name": "clusterId", + "description": "The cluster ID.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "privateLinkConnectionId", + "description": "The private link connection ID.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PrivateLinkConnectionService.DetachDomainsBody" + } + } + ], + "tags": [ + "PrivateLinkConnectionService" + ] + } } }, "definitions": { @@ -222,6 +330,19 @@ "name": { "type": "string", "description": "The endpoint service name." + }, + "endpointId": { + "type": "string", + "description": "The endpoint ID.", + "readOnly": true + }, + "availabilityZoneIds": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The availability zones of the endpoint.", + "readOnly": true } }, "required": [ @@ -237,6 +358,61 @@ }, "additionalProperties": {} }, + "AttachDomain": { + "type": "object", + "properties": { + "attachDomainId": { + "type": "string", + "description": "The attach domain ID.", + "readOnly": true + }, + "clusterId": { + "type": "string", + "description": "The cluster ID.", + "readOnly": true + }, + "privateLinkConnectionId": { + "type": "string", + "description": "The private link connection ID.", + "readOnly": true + }, + "type": { + "description": "The domain type to attach.", + "allOf": [ + { + "$ref": "#/definitions/PrivateLinkConnectionDomainType.Enum" + } + ] + }, + "uniqueName": { + "type": "string", + "description": "The unique name of the domain to attach, it can be empty only when type is TIDBCLOUD_MANAGED and validate_only is true." + }, + "domains": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/Domain" + }, + "description": "The domains attached.", + "readOnly": true + }, + "createdBy": { + "type": "string", + "description": "The user who attach the domain.", + "readOnly": true + }, + "createTime": { + "type": "string", + "format": "date-time", + "title": "create time", + "readOnly": true + } + }, + "required": [ + "type" + ] + }, "AwsEndpointService": { "type": "object", "properties": { @@ -247,12 +423,45 @@ "region": { "type": "string", "title": "The region of endpoint service name, default to cluster's region" + }, + "endpointId": { + "type": "string", + "description": "The endpoint ID.", + "readOnly": true + }, + "availabilityZoneIds": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The availability zones of the endpoint.", + "readOnly": true } }, "required": [ "name" ] }, + "Domain": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The domain name.", + "readOnly": true + }, + "state": { + "type": "string", + "title": "The domain state", + "readOnly": true + }, + "message": { + "type": "string", + "description": "Fail message if the domain is in failed state.", + "readOnly": true + } + } + }, "GetAvailabilityZonesResponse": { "type": "object", "properties": { @@ -293,7 +502,7 @@ "properties": { "privateLinkConnectionId": { "type": "string", - "title": "The private link connection ID, format: pl-xxx", + "title": "The private link connection ID, format: plc-xxx", "readOnly": true }, "clusterId": { @@ -344,6 +553,15 @@ } ] }, + "attachedDomains": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/AttachDomain" + }, + "title": "The attached domains for the private link connection, only display in Get API", + "readOnly": true + }, "awsEndpointService": { "$ref": "#/definitions/AwsEndpointService" }, @@ -357,6 +575,34 @@ "type" ] }, + "PrivateLinkConnectionDomainType.Enum": { + "type": "string", + "enum": [ + "TIDBCLOUD_MANAGED", + "CONFLUENT" + ], + "description": " - TIDBCLOUD_MANAGED: The domain pattern is .plc.tidbcloud.com.\n - CONFLUENT: The domain pattern is .confluent.cloud." + }, + "PrivateLinkConnectionService.AttachDomainsBody": { + "type": "object", + "properties": { + "attachDomain": { + "description": "The domain to attach.", + "allOf": [ + { + "$ref": "#/definitions/AttachDomain" + } + ] + }, + "validateOnly": { + "type": "boolean", + "description": "Only validate the request and return the domains without attaching them." + } + }, + "required": [ + "attachDomain" + ] + }, "PrivateLinkConnectionService.CreatePrivateLinkConnectionBody": { "type": "object", "properties": { @@ -373,6 +619,18 @@ "privateLinkConnection" ] }, + "PrivateLinkConnectionService.DetachDomainsBody": { + "type": "object", + "properties": { + "attachDomainId": { + "type": "string", + "description": "The attached domain ID to detach." + } + }, + "required": [ + "attachDomainId" + ] + }, "PrivateLinkConnectionState.Enum": { "type": "string", "enum": [ @@ -380,10 +638,9 @@ "ACTIVE", "FAILED", "PENDING_ACCEPTANCE", - "DELETING", - "CONNECTING" + "DELETING" ], - "title": "- CREATING: The private link connection is being created.\n - ACTIVE: The private link connection is active.\n - FAILED: The private link connection is in failed state.\n - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service.\n - DELETING: The private link connection is being deleted.\n - CONNECTING: The private link connection is connecting" + "description": " - CREATING: The private link connection is being created.\n - ACTIVE: The private link connection is active.\n - FAILED: The private link connection is in failed state.\n - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service.\n - DELETING: The private link connection is being deleted." }, "PrivateLinkConnectionType.Enum": { "type": "string", @@ -413,4 +670,4 @@ } } } -} \ No newline at end of file +} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator/FILES b/pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator/FILES index 2248a1ca..3e00c6b7 100644 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator/FILES +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator/FILES @@ -9,11 +9,17 @@ configuration.go git_push.sh model_alicloud_endpoint_service.go model_any.go +model_attach_domain.go model_aws_endpoint_service.go +model_domain.go model_get_availability_zones_response.go model_list_private_link_connections_response.go model_private_link_connection.go +model_private_link_connection_domain_type_enum.go +model_private_link_connection_service_attach_domains_body.go model_private_link_connection_service_create_private_link_connection_body.go +model_private_link_connection_service_detach_domains_body.go +model_private_link_connection_service_list_private_link_connections_state_parameter.go model_private_link_connection_state_enum.go model_private_link_connection_type_enum.go model_status.go diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/README.md b/pkg/tidbcloud/v1beta1/serverless/privatelink/README.md index 35aeae8c..b43215ae 100644 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/README.md +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/README.md @@ -78,8 +78,10 @@ All URIs are relative to *https://serverless.tidbapi.com* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceAttachDomains**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionserviceattachdomains) | **Post** /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:attachDomains | Attach domains for private link connection. *PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceCreatePrivateLinkConnection**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicecreateprivatelinkconnection) | **Post** /v1beta1/clusters/{clusterId}/privateLinkConnections | Create a private link connection. *PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceDeletePrivateLinkConnection**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicedeleteprivatelinkconnection) | **Delete** /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId} | Delete a private link connection. +*PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceDetachDomains**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicedetachdomains) | **Post** /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:detachDomains | Detach domains for private link connection. *PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceGetAvailabilityZones**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicegetavailabilityzones) | **Get** /v1beta1/clusters/{clusterId}/privateLinkConnections:getAvailabilityZones | Get account and availability zones information for private link connection. *PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceGetPrivateLinkConnection**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicegetprivatelinkconnection) | **Get** /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId} | Get a private link connection. *PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceListPrivateLinkConnections**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicelistprivatelinkconnections) | **Get** /v1beta1/clusters/{clusterId}/privateLinkConnections | List private link connections. @@ -89,11 +91,17 @@ Class | Method | HTTP request | Description - [AlicloudEndpointService](docs/AlicloudEndpointService.md) - [Any](docs/Any.md) + - [AttachDomain](docs/AttachDomain.md) - [AwsEndpointService](docs/AwsEndpointService.md) + - [Domain](docs/Domain.md) - [GetAvailabilityZonesResponse](docs/GetAvailabilityZonesResponse.md) - [ListPrivateLinkConnectionsResponse](docs/ListPrivateLinkConnectionsResponse.md) - [PrivateLinkConnection](docs/PrivateLinkConnection.md) + - [PrivateLinkConnectionDomainTypeEnum](docs/PrivateLinkConnectionDomainTypeEnum.md) + - [PrivateLinkConnectionServiceAttachDomainsBody](docs/PrivateLinkConnectionServiceAttachDomainsBody.md) - [PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody](docs/PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody.md) + - [PrivateLinkConnectionServiceDetachDomainsBody](docs/PrivateLinkConnectionServiceDetachDomainsBody.md) + - [PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter](docs/PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter.md) - [PrivateLinkConnectionStateEnum](docs/PrivateLinkConnectionStateEnum.md) - [PrivateLinkConnectionTypeEnum](docs/PrivateLinkConnectionTypeEnum.md) - [Status](docs/Status.md) diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/api/openapi.yaml b/pkg/tidbcloud/v1beta1/serverless/privatelink/api/openapi.yaml index f9be3eb4..d1b57164 100644 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/api/openapi.yaml +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/api/openapi.yaml @@ -92,6 +92,16 @@ paths: name: pageToken schema: type: string + - description: |2- + - CREATING: The private link connection is being created. + - ACTIVE: The private link connection is active. + - FAILED: The private link connection is in failed state. + - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service. + - DELETING: The private link connection is being deleted. + in: query + name: state + schema: + $ref: '#/components/schemas/PrivateLinkConnectionService_ListPrivateLinkConnections_state_parameter' responses: "200": content: @@ -166,15 +176,107 @@ paths: summary: Get account and availability zones information for private link connection. tags: - PrivateLinkConnectionService + /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:attachDomains: + post: + operationId: PrivateLinkConnectionService_AttachDomains + parameters: + - description: The cluster ID. + in: path + name: clusterId + required: true + schema: + type: string + - description: The private link connection ID. + in: path + name: privateLinkConnectionId + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PrivateLinkConnectionService.AttachDomainsBody' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/AttachDomain' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + description: An unexpected error response. + summary: Attach domains for private link connection. + tags: + - PrivateLinkConnectionService + x-codegen-request-body-name: body + /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:detachDomains: + post: + operationId: PrivateLinkConnectionService_DetachDomains + parameters: + - description: The cluster ID. + in: path + name: clusterId + required: true + schema: + type: string + - description: The private link connection ID. + in: path + name: privateLinkConnectionId + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PrivateLinkConnectionService.DetachDomainsBody' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/AttachDomain' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + description: An unexpected error response. + summary: Detach domains for private link connection. + tags: + - PrivateLinkConnectionService + x-codegen-request-body-name: body components: schemas: AlicloudEndpointService: example: + availabilityZoneIds: + - availabilityZoneIds + - availabilityZoneIds + endpointId: endpointId name: name properties: name: description: The endpoint service name. type: string + endpointId: + description: The endpoint ID. + readOnly: true + type: string + availabilityZoneIds: + description: The availability zones of the endpoint. + items: + type: string + readOnly: true + type: array required: - name type: object @@ -187,8 +289,68 @@ components: '@type': type: string type: object + AttachDomain: + example: + uniqueName: uniqueName + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + domains: + - name: name + state: state + message: message + - name: name + state: state + message: message + attachDomainId: attachDomainId + privateLinkConnectionId: privateLinkConnectionId + clusterId: clusterId + type: "{}" + properties: + attachDomainId: + description: The attach domain ID. + readOnly: true + type: string + clusterId: + description: The cluster ID. + readOnly: true + type: string + privateLinkConnectionId: + description: The private link connection ID. + readOnly: true + type: string + type: + allOf: + - $ref: '#/components/schemas/PrivateLinkConnectionDomainType.Enum' + description: The domain type to attach. + type: object + uniqueName: + description: "The unique name of the domain to attach, it can be empty only\ + \ when type is TIDBCLOUD_MANAGED and validate_only is true." + type: string + domains: + description: The domains attached. + items: + $ref: '#/components/schemas/Domain' + readOnly: true + type: array + createdBy: + description: The user who attach the domain. + readOnly: true + type: string + createTime: + format: date-time + readOnly: true + title: create time + type: string + required: + - type + type: object AwsEndpointService: example: + availabilityZoneIds: + - availabilityZoneIds + - availabilityZoneIds + endpointId: endpointId name: name region: region properties: @@ -198,9 +360,38 @@ components: region: title: "The region of endpoint service name, default to cluster's region" type: string + endpointId: + description: The endpoint ID. + readOnly: true + type: string + availabilityZoneIds: + description: The availability zones of the endpoint. + items: + type: string + readOnly: true + type: array required: - name type: object + Domain: + example: + name: name + state: state + message: message + properties: + name: + description: The domain name. + readOnly: true + type: string + state: + readOnly: true + title: The domain state + type: string + message: + description: Fail message if the domain is in failed state. + readOnly: true + type: string + type: object GetAvailabilityZonesResponse: example: azIds: @@ -223,11 +414,44 @@ components: nextPageToken: nextPageToken privateLinkConnections: - awsEndpointService: + availabilityZoneIds: + - availabilityZoneIds + - availabilityZoneIds + endpointId: endpointId name: name region: region createdBy: createdBy createTime: 2000-01-23T04:56:07.000+00:00 displayName: displayName + attachedDomains: + - uniqueName: uniqueName + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + domains: + - name: name + state: state + message: message + - name: name + state: state + message: message + attachDomainId: attachDomainId + privateLinkConnectionId: privateLinkConnectionId + clusterId: clusterId + type: "{}" + - uniqueName: uniqueName + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + domains: + - name: name + state: state + message: message + - name: name + state: state + message: message + attachDomainId: attachDomainId + privateLinkConnectionId: privateLinkConnectionId + clusterId: clusterId + type: "{}" privateLinkConnectionId: privateLinkConnectionId updateTime: 2000-01-23T04:56:07.000+00:00 clusterId: clusterId @@ -235,13 +459,50 @@ components: message: message type: "{}" alicloudEndpointService: + availabilityZoneIds: + - availabilityZoneIds + - availabilityZoneIds + endpointId: endpointId name: name - awsEndpointService: + availabilityZoneIds: + - availabilityZoneIds + - availabilityZoneIds + endpointId: endpointId name: name region: region createdBy: createdBy createTime: 2000-01-23T04:56:07.000+00:00 displayName: displayName + attachedDomains: + - uniqueName: uniqueName + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + domains: + - name: name + state: state + message: message + - name: name + state: state + message: message + attachDomainId: attachDomainId + privateLinkConnectionId: privateLinkConnectionId + clusterId: clusterId + type: "{}" + - uniqueName: uniqueName + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + domains: + - name: name + state: state + message: message + - name: name + state: state + message: message + attachDomainId: attachDomainId + privateLinkConnectionId: privateLinkConnectionId + clusterId: clusterId + type: "{}" privateLinkConnectionId: privateLinkConnectionId updateTime: 2000-01-23T04:56:07.000+00:00 clusterId: clusterId @@ -249,6 +510,10 @@ components: message: message type: "{}" alicloudEndpointService: + availabilityZoneIds: + - availabilityZoneIds + - availabilityZoneIds + endpointId: endpointId name: name properties: privateLinkConnections: @@ -264,11 +529,44 @@ components: PrivateLinkConnection: example: awsEndpointService: + availabilityZoneIds: + - availabilityZoneIds + - availabilityZoneIds + endpointId: endpointId name: name region: region createdBy: createdBy createTime: 2000-01-23T04:56:07.000+00:00 displayName: displayName + attachedDomains: + - uniqueName: uniqueName + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + domains: + - name: name + state: state + message: message + - name: name + state: state + message: message + attachDomainId: attachDomainId + privateLinkConnectionId: privateLinkConnectionId + clusterId: clusterId + type: "{}" + - uniqueName: uniqueName + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + domains: + - name: name + state: state + message: message + - name: name + state: state + message: message + attachDomainId: attachDomainId + privateLinkConnectionId: privateLinkConnectionId + clusterId: clusterId + type: "{}" privateLinkConnectionId: privateLinkConnectionId updateTime: 2000-01-23T04:56:07.000+00:00 clusterId: clusterId @@ -276,11 +574,15 @@ components: message: message type: "{}" alicloudEndpointService: + availabilityZoneIds: + - availabilityZoneIds + - availabilityZoneIds + endpointId: endpointId name: name properties: privateLinkConnectionId: readOnly: true - title: "The private link connection ID, format: pl-xxx" + title: "The private link connection ID, format: plc-xxx" type: string clusterId: description: The ID of the cluster. @@ -317,6 +619,13 @@ components: - $ref: '#/components/schemas/PrivateLinkConnectionType.Enum' title: The type of the private link connection type: object + attachedDomains: + items: + $ref: '#/components/schemas/AttachDomain' + readOnly: true + title: "The attached domains for the private link connection, only display\ + \ in Get API" + type: array awsEndpointService: $ref: '#/components/schemas/AwsEndpointService' alicloudEndpointService: @@ -326,6 +635,28 @@ components: - displayName - type type: object + PrivateLinkConnectionDomainType.Enum: + description: |2- + - TIDBCLOUD_MANAGED: The domain pattern is .plc.tidbcloud.com. + - CONFLUENT: The domain pattern is .confluent.cloud. + enum: + - TIDBCLOUD_MANAGED + - CONFLUENT + type: string + PrivateLinkConnectionService.AttachDomainsBody: + properties: + attachDomain: + allOf: + - $ref: '#/components/schemas/AttachDomain' + description: The domain to attach. + type: object + validateOnly: + description: Only validate the request and return the domains without attaching + them. + type: boolean + required: + - attachDomain + type: object PrivateLinkConnectionService.CreatePrivateLinkConnectionBody: properties: privateLinkConnection: @@ -336,21 +667,27 @@ components: required: - privateLinkConnection type: object + PrivateLinkConnectionService.DetachDomainsBody: + properties: + attachDomainId: + description: The attached domain ID to detach. + type: string + required: + - attachDomainId + type: object PrivateLinkConnectionState.Enum: + description: |2- + - CREATING: The private link connection is being created. + - ACTIVE: The private link connection is active. + - FAILED: The private link connection is in failed state. + - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service. + - DELETING: The private link connection is being deleted. enum: - CREATING - ACTIVE - FAILED - PENDING_ACCEPTANCE - DELETING - - CONNECTING - title: |- - - CREATING: The private link connection is being created. - - ACTIVE: The private link connection is active. - - FAILED: The private link connection is in failed state. - - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service. - - DELETING: The private link connection is being deleted. - - CONNECTING: The private link connection is connecting type: string PrivateLinkConnectionType.Enum: description: |2- @@ -378,4 +715,12 @@ components: $ref: '#/components/schemas/Any' type: array type: object + PrivateLinkConnectionService_ListPrivateLinkConnections_state_parameter: + enum: + - CREATING + - ACTIVE + - FAILED + - PENDING_ACCEPTANCE + - DELETING + type: string x-original-swagger-version: "2.0" diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/api_private_link_connection_service.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/api_private_link_connection_service.go index bd77ce9f..3669446c 100644 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/api_private_link_connection_service.go +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/api_private_link_connection_service.go @@ -22,6 +22,131 @@ import ( // PrivateLinkConnectionServiceAPIService PrivateLinkConnectionServiceAPI service type PrivateLinkConnectionServiceAPIService service +type ApiPrivateLinkConnectionServiceAttachDomainsRequest struct { + ctx context.Context + ApiService *PrivateLinkConnectionServiceAPIService + clusterId string + privateLinkConnectionId string + body *PrivateLinkConnectionServiceAttachDomainsBody +} + +func (r ApiPrivateLinkConnectionServiceAttachDomainsRequest) Body(body PrivateLinkConnectionServiceAttachDomainsBody) ApiPrivateLinkConnectionServiceAttachDomainsRequest { + r.body = &body + return r +} + +func (r ApiPrivateLinkConnectionServiceAttachDomainsRequest) Execute() (*AttachDomain, *http.Response, error) { + return r.ApiService.PrivateLinkConnectionServiceAttachDomainsExecute(r) +} + +/* +PrivateLinkConnectionServiceAttachDomains Attach domains for private link connection. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param clusterId The cluster ID. + @param privateLinkConnectionId The private link connection ID. + @return ApiPrivateLinkConnectionServiceAttachDomainsRequest +*/ +func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceAttachDomains(ctx context.Context, clusterId string, privateLinkConnectionId string) ApiPrivateLinkConnectionServiceAttachDomainsRequest { + return ApiPrivateLinkConnectionServiceAttachDomainsRequest{ + ApiService: a, + ctx: ctx, + clusterId: clusterId, + privateLinkConnectionId: privateLinkConnectionId, + } +} + +// Execute executes the request +// +// @return AttachDomain +func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceAttachDomainsExecute(r ApiPrivateLinkConnectionServiceAttachDomainsRequest) (*AttachDomain, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *AttachDomain + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PrivateLinkConnectionServiceAPIService.PrivateLinkConnectionServiceAttachDomains") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:attachDomains" + localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"privateLinkConnectionId"+"}", url.PathEscape(parameterValueToString(r.privateLinkConnectionId, "privateLinkConnectionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.body == nil { + return localVarReturnValue, nil, reportError("body is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.body + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type ApiPrivateLinkConnectionServiceCreatePrivateLinkConnectionRequest struct { ctx context.Context ApiService *PrivateLinkConnectionServiceAPIService @@ -257,6 +382,131 @@ func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceDel return localVarReturnValue, localVarHTTPResponse, nil } +type ApiPrivateLinkConnectionServiceDetachDomainsRequest struct { + ctx context.Context + ApiService *PrivateLinkConnectionServiceAPIService + clusterId string + privateLinkConnectionId string + body *PrivateLinkConnectionServiceDetachDomainsBody +} + +func (r ApiPrivateLinkConnectionServiceDetachDomainsRequest) Body(body PrivateLinkConnectionServiceDetachDomainsBody) ApiPrivateLinkConnectionServiceDetachDomainsRequest { + r.body = &body + return r +} + +func (r ApiPrivateLinkConnectionServiceDetachDomainsRequest) Execute() (*AttachDomain, *http.Response, error) { + return r.ApiService.PrivateLinkConnectionServiceDetachDomainsExecute(r) +} + +/* +PrivateLinkConnectionServiceDetachDomains Detach domains for private link connection. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param clusterId The cluster ID. + @param privateLinkConnectionId The private link connection ID. + @return ApiPrivateLinkConnectionServiceDetachDomainsRequest +*/ +func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceDetachDomains(ctx context.Context, clusterId string, privateLinkConnectionId string) ApiPrivateLinkConnectionServiceDetachDomainsRequest { + return ApiPrivateLinkConnectionServiceDetachDomainsRequest{ + ApiService: a, + ctx: ctx, + clusterId: clusterId, + privateLinkConnectionId: privateLinkConnectionId, + } +} + +// Execute executes the request +// +// @return AttachDomain +func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceDetachDomainsExecute(r ApiPrivateLinkConnectionServiceDetachDomainsRequest) (*AttachDomain, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *AttachDomain + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PrivateLinkConnectionServiceAPIService.PrivateLinkConnectionServiceDetachDomains") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:detachDomains" + localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"privateLinkConnectionId"+"}", url.PathEscape(parameterValueToString(r.privateLinkConnectionId, "privateLinkConnectionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.body == nil { + return localVarReturnValue, nil, reportError("body is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.body + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type ApiPrivateLinkConnectionServiceGetAvailabilityZonesRequest struct { ctx context.Context ApiService *PrivateLinkConnectionServiceAPIService @@ -487,6 +737,7 @@ type ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest struct { clusterId string pageSize *int32 pageToken *string + state *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter } // The maximum number to return. @@ -501,6 +752,12 @@ func (r ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest) PageTo return r } +// - CREATING: The private link connection is being created. - ACTIVE: The private link connection is active. - FAILED: The private link connection is in failed state. - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service. - DELETING: The private link connection is being deleted. +func (r ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest) State(state PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest { + r.state = &state + return r +} + func (r ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest) Execute() (*ListPrivateLinkConnectionsResponse, *http.Response, error) { return r.ApiService.PrivateLinkConnectionServiceListPrivateLinkConnectionsExecute(r) } @@ -549,6 +806,9 @@ func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceLis if r.pageToken != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "pageToken", r.pageToken, "", "") } + if r.state != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "state", r.state, "", "") + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_alicloud_endpoint_service.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_alicloud_endpoint_service.go index 91f2b846..2ecb9a49 100644 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_alicloud_endpoint_service.go +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_alicloud_endpoint_service.go @@ -21,7 +21,11 @@ var _ MappedNullable = &AlicloudEndpointService{} // AlicloudEndpointService struct for AlicloudEndpointService type AlicloudEndpointService struct { // The endpoint service name. - Name string `json:"name"` + Name string `json:"name"` + // The endpoint ID. + EndpointId *string `json:"endpointId,omitempty"` + // The availability zones of the endpoint. + AvailabilityZoneIds []string `json:"availabilityZoneIds,omitempty"` AdditionalProperties map[string]interface{} } @@ -69,6 +73,70 @@ func (o *AlicloudEndpointService) SetName(v string) { o.Name = v } +// GetEndpointId returns the EndpointId field value if set, zero value otherwise. +func (o *AlicloudEndpointService) GetEndpointId() string { + if o == nil || IsNil(o.EndpointId) { + var ret string + return ret + } + return *o.EndpointId +} + +// GetEndpointIdOk returns a tuple with the EndpointId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlicloudEndpointService) GetEndpointIdOk() (*string, bool) { + if o == nil || IsNil(o.EndpointId) { + return nil, false + } + return o.EndpointId, true +} + +// HasEndpointId returns a boolean if a field has been set. +func (o *AlicloudEndpointService) HasEndpointId() bool { + if o != nil && !IsNil(o.EndpointId) { + return true + } + + return false +} + +// SetEndpointId gets a reference to the given string and assigns it to the EndpointId field. +func (o *AlicloudEndpointService) SetEndpointId(v string) { + o.EndpointId = &v +} + +// GetAvailabilityZoneIds returns the AvailabilityZoneIds field value if set, zero value otherwise. +func (o *AlicloudEndpointService) GetAvailabilityZoneIds() []string { + if o == nil || IsNil(o.AvailabilityZoneIds) { + var ret []string + return ret + } + return o.AvailabilityZoneIds +} + +// GetAvailabilityZoneIdsOk returns a tuple with the AvailabilityZoneIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlicloudEndpointService) GetAvailabilityZoneIdsOk() ([]string, bool) { + if o == nil || IsNil(o.AvailabilityZoneIds) { + return nil, false + } + return o.AvailabilityZoneIds, true +} + +// HasAvailabilityZoneIds returns a boolean if a field has been set. +func (o *AlicloudEndpointService) HasAvailabilityZoneIds() bool { + if o != nil && !IsNil(o.AvailabilityZoneIds) { + return true + } + + return false +} + +// SetAvailabilityZoneIds gets a reference to the given []string and assigns it to the AvailabilityZoneIds field. +func (o *AlicloudEndpointService) SetAvailabilityZoneIds(v []string) { + o.AvailabilityZoneIds = v +} + func (o AlicloudEndpointService) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -80,6 +148,12 @@ func (o AlicloudEndpointService) MarshalJSON() ([]byte, error) { func (o AlicloudEndpointService) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} toSerialize["name"] = o.Name + if !IsNil(o.EndpointId) { + toSerialize["endpointId"] = o.EndpointId + } + if !IsNil(o.AvailabilityZoneIds) { + toSerialize["availabilityZoneIds"] = o.AvailabilityZoneIds + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -124,6 +198,8 @@ func (o *AlicloudEndpointService) UnmarshalJSON(data []byte) (err error) { if err = json.Unmarshal(data, &additionalProperties); err == nil { delete(additionalProperties, "name") + delete(additionalProperties, "endpointId") + delete(additionalProperties, "availabilityZoneIds") o.AdditionalProperties = additionalProperties } diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_attach_domain.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_attach_domain.go new file mode 100644 index 00000000..71abf186 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_attach_domain.go @@ -0,0 +1,433 @@ +/* +TiDB Cloud Serverless Private Link Connection Open API + +TiDB Cloud Serverless Private Link Connection Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package privatelink + +import ( + "encoding/json" + "fmt" + "time" +) + +// checks if the AttachDomain type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &AttachDomain{} + +// AttachDomain struct for AttachDomain +type AttachDomain struct { + // The attach domain ID. + AttachDomainId *string `json:"attachDomainId,omitempty"` + // The cluster ID. + ClusterId *string `json:"clusterId,omitempty"` + // The private link connection ID. + PrivateLinkConnectionId *string `json:"privateLinkConnectionId,omitempty"` + // The domain type to attach. + Type PrivateLinkConnectionDomainTypeEnum `json:"type"` + // The unique name of the domain to attach, it can be empty only when type is TIDBCLOUD_MANAGED and validate_only is true. + UniqueName *string `json:"uniqueName,omitempty"` + // The domains attached. + Domains []Domain `json:"domains,omitempty"` + // The user who attach the domain. + CreatedBy *string `json:"createdBy,omitempty"` + CreateTime *time.Time `json:"createTime,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _AttachDomain AttachDomain + +// NewAttachDomain instantiates a new AttachDomain object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewAttachDomain(type_ PrivateLinkConnectionDomainTypeEnum) *AttachDomain { + this := AttachDomain{} + this.Type = type_ + return &this +} + +// NewAttachDomainWithDefaults instantiates a new AttachDomain object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewAttachDomainWithDefaults() *AttachDomain { + this := AttachDomain{} + return &this +} + +// GetAttachDomainId returns the AttachDomainId field value if set, zero value otherwise. +func (o *AttachDomain) GetAttachDomainId() string { + if o == nil || IsNil(o.AttachDomainId) { + var ret string + return ret + } + return *o.AttachDomainId +} + +// GetAttachDomainIdOk returns a tuple with the AttachDomainId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AttachDomain) GetAttachDomainIdOk() (*string, bool) { + if o == nil || IsNil(o.AttachDomainId) { + return nil, false + } + return o.AttachDomainId, true +} + +// HasAttachDomainId returns a boolean if a field has been set. +func (o *AttachDomain) HasAttachDomainId() bool { + if o != nil && !IsNil(o.AttachDomainId) { + return true + } + + return false +} + +// SetAttachDomainId gets a reference to the given string and assigns it to the AttachDomainId field. +func (o *AttachDomain) SetAttachDomainId(v string) { + o.AttachDomainId = &v +} + +// GetClusterId returns the ClusterId field value if set, zero value otherwise. +func (o *AttachDomain) GetClusterId() string { + if o == nil || IsNil(o.ClusterId) { + var ret string + return ret + } + return *o.ClusterId +} + +// GetClusterIdOk returns a tuple with the ClusterId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AttachDomain) GetClusterIdOk() (*string, bool) { + if o == nil || IsNil(o.ClusterId) { + return nil, false + } + return o.ClusterId, true +} + +// HasClusterId returns a boolean if a field has been set. +func (o *AttachDomain) HasClusterId() bool { + if o != nil && !IsNil(o.ClusterId) { + return true + } + + return false +} + +// SetClusterId gets a reference to the given string and assigns it to the ClusterId field. +func (o *AttachDomain) SetClusterId(v string) { + o.ClusterId = &v +} + +// GetPrivateLinkConnectionId returns the PrivateLinkConnectionId field value if set, zero value otherwise. +func (o *AttachDomain) GetPrivateLinkConnectionId() string { + if o == nil || IsNil(o.PrivateLinkConnectionId) { + var ret string + return ret + } + return *o.PrivateLinkConnectionId +} + +// GetPrivateLinkConnectionIdOk returns a tuple with the PrivateLinkConnectionId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AttachDomain) GetPrivateLinkConnectionIdOk() (*string, bool) { + if o == nil || IsNil(o.PrivateLinkConnectionId) { + return nil, false + } + return o.PrivateLinkConnectionId, true +} + +// HasPrivateLinkConnectionId returns a boolean if a field has been set. +func (o *AttachDomain) HasPrivateLinkConnectionId() bool { + if o != nil && !IsNil(o.PrivateLinkConnectionId) { + return true + } + + return false +} + +// SetPrivateLinkConnectionId gets a reference to the given string and assigns it to the PrivateLinkConnectionId field. +func (o *AttachDomain) SetPrivateLinkConnectionId(v string) { + o.PrivateLinkConnectionId = &v +} + +// GetType returns the Type field value +func (o *AttachDomain) GetType() PrivateLinkConnectionDomainTypeEnum { + if o == nil { + var ret PrivateLinkConnectionDomainTypeEnum + return ret + } + + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *AttachDomain) GetTypeOk() (*PrivateLinkConnectionDomainTypeEnum, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value +func (o *AttachDomain) SetType(v PrivateLinkConnectionDomainTypeEnum) { + o.Type = v +} + +// GetUniqueName returns the UniqueName field value if set, zero value otherwise. +func (o *AttachDomain) GetUniqueName() string { + if o == nil || IsNil(o.UniqueName) { + var ret string + return ret + } + return *o.UniqueName +} + +// GetUniqueNameOk returns a tuple with the UniqueName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AttachDomain) GetUniqueNameOk() (*string, bool) { + if o == nil || IsNil(o.UniqueName) { + return nil, false + } + return o.UniqueName, true +} + +// HasUniqueName returns a boolean if a field has been set. +func (o *AttachDomain) HasUniqueName() bool { + if o != nil && !IsNil(o.UniqueName) { + return true + } + + return false +} + +// SetUniqueName gets a reference to the given string and assigns it to the UniqueName field. +func (o *AttachDomain) SetUniqueName(v string) { + o.UniqueName = &v +} + +// GetDomains returns the Domains field value if set, zero value otherwise. +func (o *AttachDomain) GetDomains() []Domain { + if o == nil || IsNil(o.Domains) { + var ret []Domain + return ret + } + return o.Domains +} + +// GetDomainsOk returns a tuple with the Domains field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AttachDomain) GetDomainsOk() ([]Domain, bool) { + if o == nil || IsNil(o.Domains) { + return nil, false + } + return o.Domains, true +} + +// HasDomains returns a boolean if a field has been set. +func (o *AttachDomain) HasDomains() bool { + if o != nil && !IsNil(o.Domains) { + return true + } + + return false +} + +// SetDomains gets a reference to the given []Domain and assigns it to the Domains field. +func (o *AttachDomain) SetDomains(v []Domain) { + o.Domains = v +} + +// GetCreatedBy returns the CreatedBy field value if set, zero value otherwise. +func (o *AttachDomain) GetCreatedBy() string { + if o == nil || IsNil(o.CreatedBy) { + var ret string + return ret + } + return *o.CreatedBy +} + +// GetCreatedByOk returns a tuple with the CreatedBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AttachDomain) GetCreatedByOk() (*string, bool) { + if o == nil || IsNil(o.CreatedBy) { + return nil, false + } + return o.CreatedBy, true +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *AttachDomain) HasCreatedBy() bool { + if o != nil && !IsNil(o.CreatedBy) { + return true + } + + return false +} + +// SetCreatedBy gets a reference to the given string and assigns it to the CreatedBy field. +func (o *AttachDomain) SetCreatedBy(v string) { + o.CreatedBy = &v +} + +// GetCreateTime returns the CreateTime field value if set, zero value otherwise. +func (o *AttachDomain) GetCreateTime() time.Time { + if o == nil || IsNil(o.CreateTime) { + var ret time.Time + return ret + } + return *o.CreateTime +} + +// GetCreateTimeOk returns a tuple with the CreateTime field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AttachDomain) GetCreateTimeOk() (*time.Time, bool) { + if o == nil || IsNil(o.CreateTime) { + return nil, false + } + return o.CreateTime, true +} + +// HasCreateTime returns a boolean if a field has been set. +func (o *AttachDomain) HasCreateTime() bool { + if o != nil && !IsNil(o.CreateTime) { + return true + } + + return false +} + +// SetCreateTime gets a reference to the given time.Time and assigns it to the CreateTime field. +func (o *AttachDomain) SetCreateTime(v time.Time) { + o.CreateTime = &v +} + +func (o AttachDomain) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o AttachDomain) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.AttachDomainId) { + toSerialize["attachDomainId"] = o.AttachDomainId + } + if !IsNil(o.ClusterId) { + toSerialize["clusterId"] = o.ClusterId + } + if !IsNil(o.PrivateLinkConnectionId) { + toSerialize["privateLinkConnectionId"] = o.PrivateLinkConnectionId + } + toSerialize["type"] = o.Type + if !IsNil(o.UniqueName) { + toSerialize["uniqueName"] = o.UniqueName + } + if !IsNil(o.Domains) { + toSerialize["domains"] = o.Domains + } + if !IsNil(o.CreatedBy) { + toSerialize["createdBy"] = o.CreatedBy + } + if !IsNil(o.CreateTime) { + toSerialize["createTime"] = o.CreateTime + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *AttachDomain) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "type", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varAttachDomain := _AttachDomain{} + + err = json.Unmarshal(data, &varAttachDomain) + + if err != nil { + return err + } + + *o = AttachDomain(varAttachDomain) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "attachDomainId") + delete(additionalProperties, "clusterId") + delete(additionalProperties, "privateLinkConnectionId") + delete(additionalProperties, "type") + delete(additionalProperties, "uniqueName") + delete(additionalProperties, "domains") + delete(additionalProperties, "createdBy") + delete(additionalProperties, "createTime") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableAttachDomain struct { + value *AttachDomain + isSet bool +} + +func (v NullableAttachDomain) Get() *AttachDomain { + return v.value +} + +func (v *NullableAttachDomain) Set(val *AttachDomain) { + v.value = val + v.isSet = true +} + +func (v NullableAttachDomain) IsSet() bool { + return v.isSet +} + +func (v *NullableAttachDomain) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableAttachDomain(val *AttachDomain) *NullableAttachDomain { + return &NullableAttachDomain{value: val, isSet: true} +} + +func (v NullableAttachDomain) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableAttachDomain) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_aws_endpoint_service.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_aws_endpoint_service.go index a0186e30..7a084b58 100644 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_aws_endpoint_service.go +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_aws_endpoint_service.go @@ -21,8 +21,12 @@ var _ MappedNullable = &AwsEndpointService{} // AwsEndpointService struct for AwsEndpointService type AwsEndpointService struct { // The endpoint service name. - Name string `json:"name"` - Region *string `json:"region,omitempty"` + Name string `json:"name"` + Region *string `json:"region,omitempty"` + // The endpoint ID. + EndpointId *string `json:"endpointId,omitempty"` + // The availability zones of the endpoint. + AvailabilityZoneIds []string `json:"availabilityZoneIds,omitempty"` AdditionalProperties map[string]interface{} } @@ -102,6 +106,70 @@ func (o *AwsEndpointService) SetRegion(v string) { o.Region = &v } +// GetEndpointId returns the EndpointId field value if set, zero value otherwise. +func (o *AwsEndpointService) GetEndpointId() string { + if o == nil || IsNil(o.EndpointId) { + var ret string + return ret + } + return *o.EndpointId +} + +// GetEndpointIdOk returns a tuple with the EndpointId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AwsEndpointService) GetEndpointIdOk() (*string, bool) { + if o == nil || IsNil(o.EndpointId) { + return nil, false + } + return o.EndpointId, true +} + +// HasEndpointId returns a boolean if a field has been set. +func (o *AwsEndpointService) HasEndpointId() bool { + if o != nil && !IsNil(o.EndpointId) { + return true + } + + return false +} + +// SetEndpointId gets a reference to the given string and assigns it to the EndpointId field. +func (o *AwsEndpointService) SetEndpointId(v string) { + o.EndpointId = &v +} + +// GetAvailabilityZoneIds returns the AvailabilityZoneIds field value if set, zero value otherwise. +func (o *AwsEndpointService) GetAvailabilityZoneIds() []string { + if o == nil || IsNil(o.AvailabilityZoneIds) { + var ret []string + return ret + } + return o.AvailabilityZoneIds +} + +// GetAvailabilityZoneIdsOk returns a tuple with the AvailabilityZoneIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AwsEndpointService) GetAvailabilityZoneIdsOk() ([]string, bool) { + if o == nil || IsNil(o.AvailabilityZoneIds) { + return nil, false + } + return o.AvailabilityZoneIds, true +} + +// HasAvailabilityZoneIds returns a boolean if a field has been set. +func (o *AwsEndpointService) HasAvailabilityZoneIds() bool { + if o != nil && !IsNil(o.AvailabilityZoneIds) { + return true + } + + return false +} + +// SetAvailabilityZoneIds gets a reference to the given []string and assigns it to the AvailabilityZoneIds field. +func (o *AwsEndpointService) SetAvailabilityZoneIds(v []string) { + o.AvailabilityZoneIds = v +} + func (o AwsEndpointService) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -116,6 +184,12 @@ func (o AwsEndpointService) ToMap() (map[string]interface{}, error) { if !IsNil(o.Region) { toSerialize["region"] = o.Region } + if !IsNil(o.EndpointId) { + toSerialize["endpointId"] = o.EndpointId + } + if !IsNil(o.AvailabilityZoneIds) { + toSerialize["availabilityZoneIds"] = o.AvailabilityZoneIds + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -161,6 +235,8 @@ func (o *AwsEndpointService) UnmarshalJSON(data []byte) (err error) { if err = json.Unmarshal(data, &additionalProperties); err == nil { delete(additionalProperties, "name") delete(additionalProperties, "region") + delete(additionalProperties, "endpointId") + delete(additionalProperties, "availabilityZoneIds") o.AdditionalProperties = additionalProperties } diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_domain.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_domain.go new file mode 100644 index 00000000..26eae09c --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_domain.go @@ -0,0 +1,229 @@ +/* +TiDB Cloud Serverless Private Link Connection Open API + +TiDB Cloud Serverless Private Link Connection Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package privatelink + +import ( + "encoding/json" +) + +// checks if the Domain type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Domain{} + +// Domain struct for Domain +type Domain struct { + // The domain name. + Name *string `json:"name,omitempty"` + State *string `json:"state,omitempty"` + // Fail message if the domain is in failed state. + Message *string `json:"message,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _Domain Domain + +// NewDomain instantiates a new Domain object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewDomain() *Domain { + this := Domain{} + return &this +} + +// NewDomainWithDefaults instantiates a new Domain object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewDomainWithDefaults() *Domain { + this := Domain{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *Domain) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Domain) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *Domain) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *Domain) SetName(v string) { + o.Name = &v +} + +// GetState returns the State field value if set, zero value otherwise. +func (o *Domain) GetState() string { + if o == nil || IsNil(o.State) { + var ret string + return ret + } + return *o.State +} + +// GetStateOk returns a tuple with the State field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Domain) GetStateOk() (*string, bool) { + if o == nil || IsNil(o.State) { + return nil, false + } + return o.State, true +} + +// HasState returns a boolean if a field has been set. +func (o *Domain) HasState() bool { + if o != nil && !IsNil(o.State) { + return true + } + + return false +} + +// SetState gets a reference to the given string and assigns it to the State field. +func (o *Domain) SetState(v string) { + o.State = &v +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *Domain) GetMessage() string { + if o == nil || IsNil(o.Message) { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Domain) GetMessageOk() (*string, bool) { + if o == nil || IsNil(o.Message) { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *Domain) HasMessage() bool { + if o != nil && !IsNil(o.Message) { + return true + } + + return false +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *Domain) SetMessage(v string) { + o.Message = &v +} + +func (o Domain) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Domain) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.State) { + toSerialize["state"] = o.State + } + if !IsNil(o.Message) { + toSerialize["message"] = o.Message + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *Domain) UnmarshalJSON(data []byte) (err error) { + varDomain := _Domain{} + + err = json.Unmarshal(data, &varDomain) + + if err != nil { + return err + } + + *o = Domain(varDomain) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "name") + delete(additionalProperties, "state") + delete(additionalProperties, "message") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableDomain struct { + value *Domain + isSet bool +} + +func (v NullableDomain) Get() *Domain { + return v.value +} + +func (v *NullableDomain) Set(val *Domain) { + v.value = val + v.isSet = true +} + +func (v NullableDomain) IsSet() bool { + return v.isSet +} + +func (v *NullableDomain) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDomain(val *Domain) *NullableDomain { + return &NullableDomain{value: val, isSet: true} +} + +func (v NullableDomain) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDomain) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection.go index f3bb9f6c..870d7460 100644 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection.go +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection.go @@ -37,6 +37,7 @@ type PrivateLinkConnection struct { // Timestamp when the private link connection was updated. UpdateTime NullableTime `json:"updateTime,omitempty"` Type PrivateLinkConnectionTypeEnum `json:"type"` + AttachedDomains []AttachDomain `json:"attachedDomains,omitempty"` AwsEndpointService *AwsEndpointService `json:"awsEndpointService,omitempty"` AlicloudEndpointService *AlicloudEndpointService `json:"alicloudEndpointService,omitempty"` AdditionalProperties map[string]interface{} @@ -339,6 +340,38 @@ func (o *PrivateLinkConnection) SetType(v PrivateLinkConnectionTypeEnum) { o.Type = v } +// GetAttachedDomains returns the AttachedDomains field value if set, zero value otherwise. +func (o *PrivateLinkConnection) GetAttachedDomains() []AttachDomain { + if o == nil || IsNil(o.AttachedDomains) { + var ret []AttachDomain + return ret + } + return o.AttachedDomains +} + +// GetAttachedDomainsOk returns a tuple with the AttachedDomains field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PrivateLinkConnection) GetAttachedDomainsOk() ([]AttachDomain, bool) { + if o == nil || IsNil(o.AttachedDomains) { + return nil, false + } + return o.AttachedDomains, true +} + +// HasAttachedDomains returns a boolean if a field has been set. +func (o *PrivateLinkConnection) HasAttachedDomains() bool { + if o != nil && !IsNil(o.AttachedDomains) { + return true + } + + return false +} + +// SetAttachedDomains gets a reference to the given []AttachDomain and assigns it to the AttachedDomains field. +func (o *PrivateLinkConnection) SetAttachedDomains(v []AttachDomain) { + o.AttachedDomains = v +} + // GetAwsEndpointService returns the AwsEndpointService field value if set, zero value otherwise. func (o *PrivateLinkConnection) GetAwsEndpointService() AwsEndpointService { if o == nil || IsNil(o.AwsEndpointService) { @@ -434,6 +467,9 @@ func (o PrivateLinkConnection) ToMap() (map[string]interface{}, error) { toSerialize["updateTime"] = o.UpdateTime.Get() } toSerialize["type"] = o.Type + if !IsNil(o.AttachedDomains) { + toSerialize["attachedDomains"] = o.AttachedDomains + } if !IsNil(o.AwsEndpointService) { toSerialize["awsEndpointService"] = o.AwsEndpointService } @@ -494,6 +530,7 @@ func (o *PrivateLinkConnection) UnmarshalJSON(data []byte) (err error) { delete(additionalProperties, "createTime") delete(additionalProperties, "updateTime") delete(additionalProperties, "type") + delete(additionalProperties, "attachedDomains") delete(additionalProperties, "awsEndpointService") delete(additionalProperties, "alicloudEndpointService") o.AdditionalProperties = additionalProperties diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_domain_type_enum.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_domain_type_enum.go new file mode 100644 index 00000000..7ef09a90 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_domain_type_enum.go @@ -0,0 +1,105 @@ +/* +TiDB Cloud Serverless Private Link Connection Open API + +TiDB Cloud Serverless Private Link Connection Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package privatelink + +import ( + "encoding/json" +) + +// PrivateLinkConnectionDomainTypeEnum - TIDBCLOUD_MANAGED: The domain pattern is .plc.tidbcloud.com. - CONFLUENT: The domain pattern is .confluent.cloud. +type PrivateLinkConnectionDomainTypeEnum string + +// List of PrivateLinkConnectionDomainType.Enum +const ( + PRIVATELINKCONNECTIONDOMAINTYPEENUM_TIDBCLOUD_MANAGED PrivateLinkConnectionDomainTypeEnum = "TIDBCLOUD_MANAGED" + PRIVATELINKCONNECTIONDOMAINTYPEENUM_CONFLUENT PrivateLinkConnectionDomainTypeEnum = "CONFLUENT" +) + +// All allowed values of PrivateLinkConnectionDomainTypeEnum enum +var AllowedPrivateLinkConnectionDomainTypeEnumEnumValues = []PrivateLinkConnectionDomainTypeEnum{ + "TIDBCLOUD_MANAGED", + "CONFLUENT", +} + +func (v *PrivateLinkConnectionDomainTypeEnum) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := PrivateLinkConnectionDomainTypeEnum(value) + for _, existing := range AllowedPrivateLinkConnectionDomainTypeEnumEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + *v = PrivateLinkConnectionDomainTypeEnum(value) + return nil +} + +// NewPrivateLinkConnectionDomainTypeEnumFromValue returns a pointer to a valid PrivateLinkConnectionDomainTypeEnum for the value passed as argument +func NewPrivateLinkConnectionDomainTypeEnumFromValue(v string) *PrivateLinkConnectionDomainTypeEnum { + ev := PrivateLinkConnectionDomainTypeEnum(v) + return &ev +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v PrivateLinkConnectionDomainTypeEnum) IsValid() bool { + for _, existing := range AllowedPrivateLinkConnectionDomainTypeEnumEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to PrivateLinkConnectionDomainType.Enum value +func (v PrivateLinkConnectionDomainTypeEnum) Ptr() *PrivateLinkConnectionDomainTypeEnum { + return &v +} + +type NullablePrivateLinkConnectionDomainTypeEnum struct { + value *PrivateLinkConnectionDomainTypeEnum + isSet bool +} + +func (v NullablePrivateLinkConnectionDomainTypeEnum) Get() *PrivateLinkConnectionDomainTypeEnum { + return v.value +} + +func (v *NullablePrivateLinkConnectionDomainTypeEnum) Set(val *PrivateLinkConnectionDomainTypeEnum) { + v.value = val + v.isSet = true +} + +func (v NullablePrivateLinkConnectionDomainTypeEnum) IsSet() bool { + return v.isSet +} + +func (v *NullablePrivateLinkConnectionDomainTypeEnum) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePrivateLinkConnectionDomainTypeEnum(val *PrivateLinkConnectionDomainTypeEnum) *NullablePrivateLinkConnectionDomainTypeEnum { + return &NullablePrivateLinkConnectionDomainTypeEnum{value: val, isSet: true} +} + +func (v NullablePrivateLinkConnectionDomainTypeEnum) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePrivateLinkConnectionDomainTypeEnum) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_attach_domains_body.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_attach_domains_body.go new file mode 100644 index 00000000..7aa462a2 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_attach_domains_body.go @@ -0,0 +1,205 @@ +/* +TiDB Cloud Serverless Private Link Connection Open API + +TiDB Cloud Serverless Private Link Connection Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package privatelink + +import ( + "encoding/json" + "fmt" +) + +// checks if the PrivateLinkConnectionServiceAttachDomainsBody type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PrivateLinkConnectionServiceAttachDomainsBody{} + +// PrivateLinkConnectionServiceAttachDomainsBody struct for PrivateLinkConnectionServiceAttachDomainsBody +type PrivateLinkConnectionServiceAttachDomainsBody struct { + // The domain to attach. + AttachDomain AttachDomain `json:"attachDomain"` + // Only validate the request and return the domains without attaching them. + ValidateOnly *bool `json:"validateOnly,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _PrivateLinkConnectionServiceAttachDomainsBody PrivateLinkConnectionServiceAttachDomainsBody + +// NewPrivateLinkConnectionServiceAttachDomainsBody instantiates a new PrivateLinkConnectionServiceAttachDomainsBody object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewPrivateLinkConnectionServiceAttachDomainsBody(attachDomain AttachDomain) *PrivateLinkConnectionServiceAttachDomainsBody { + this := PrivateLinkConnectionServiceAttachDomainsBody{} + this.AttachDomain = attachDomain + return &this +} + +// NewPrivateLinkConnectionServiceAttachDomainsBodyWithDefaults instantiates a new PrivateLinkConnectionServiceAttachDomainsBody object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewPrivateLinkConnectionServiceAttachDomainsBodyWithDefaults() *PrivateLinkConnectionServiceAttachDomainsBody { + this := PrivateLinkConnectionServiceAttachDomainsBody{} + return &this +} + +// GetAttachDomain returns the AttachDomain field value +func (o *PrivateLinkConnectionServiceAttachDomainsBody) GetAttachDomain() AttachDomain { + if o == nil { + var ret AttachDomain + return ret + } + + return o.AttachDomain +} + +// GetAttachDomainOk returns a tuple with the AttachDomain field value +// and a boolean to check if the value has been set. +func (o *PrivateLinkConnectionServiceAttachDomainsBody) GetAttachDomainOk() (*AttachDomain, bool) { + if o == nil { + return nil, false + } + return &o.AttachDomain, true +} + +// SetAttachDomain sets field value +func (o *PrivateLinkConnectionServiceAttachDomainsBody) SetAttachDomain(v AttachDomain) { + o.AttachDomain = v +} + +// GetValidateOnly returns the ValidateOnly field value if set, zero value otherwise. +func (o *PrivateLinkConnectionServiceAttachDomainsBody) GetValidateOnly() bool { + if o == nil || IsNil(o.ValidateOnly) { + var ret bool + return ret + } + return *o.ValidateOnly +} + +// GetValidateOnlyOk returns a tuple with the ValidateOnly field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PrivateLinkConnectionServiceAttachDomainsBody) GetValidateOnlyOk() (*bool, bool) { + if o == nil || IsNil(o.ValidateOnly) { + return nil, false + } + return o.ValidateOnly, true +} + +// HasValidateOnly returns a boolean if a field has been set. +func (o *PrivateLinkConnectionServiceAttachDomainsBody) HasValidateOnly() bool { + if o != nil && !IsNil(o.ValidateOnly) { + return true + } + + return false +} + +// SetValidateOnly gets a reference to the given bool and assigns it to the ValidateOnly field. +func (o *PrivateLinkConnectionServiceAttachDomainsBody) SetValidateOnly(v bool) { + o.ValidateOnly = &v +} + +func (o PrivateLinkConnectionServiceAttachDomainsBody) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o PrivateLinkConnectionServiceAttachDomainsBody) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["attachDomain"] = o.AttachDomain + if !IsNil(o.ValidateOnly) { + toSerialize["validateOnly"] = o.ValidateOnly + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *PrivateLinkConnectionServiceAttachDomainsBody) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "attachDomain", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varPrivateLinkConnectionServiceAttachDomainsBody := _PrivateLinkConnectionServiceAttachDomainsBody{} + + err = json.Unmarshal(data, &varPrivateLinkConnectionServiceAttachDomainsBody) + + if err != nil { + return err + } + + *o = PrivateLinkConnectionServiceAttachDomainsBody(varPrivateLinkConnectionServiceAttachDomainsBody) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "attachDomain") + delete(additionalProperties, "validateOnly") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullablePrivateLinkConnectionServiceAttachDomainsBody struct { + value *PrivateLinkConnectionServiceAttachDomainsBody + isSet bool +} + +func (v NullablePrivateLinkConnectionServiceAttachDomainsBody) Get() *PrivateLinkConnectionServiceAttachDomainsBody { + return v.value +} + +func (v *NullablePrivateLinkConnectionServiceAttachDomainsBody) Set(val *PrivateLinkConnectionServiceAttachDomainsBody) { + v.value = val + v.isSet = true +} + +func (v NullablePrivateLinkConnectionServiceAttachDomainsBody) IsSet() bool { + return v.isSet +} + +func (v *NullablePrivateLinkConnectionServiceAttachDomainsBody) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePrivateLinkConnectionServiceAttachDomainsBody(val *PrivateLinkConnectionServiceAttachDomainsBody) *NullablePrivateLinkConnectionServiceAttachDomainsBody { + return &NullablePrivateLinkConnectionServiceAttachDomainsBody{value: val, isSet: true} +} + +func (v NullablePrivateLinkConnectionServiceAttachDomainsBody) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePrivateLinkConnectionServiceAttachDomainsBody) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_detach_domains_body.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_detach_domains_body.go new file mode 100644 index 00000000..fe3a28fc --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_detach_domains_body.go @@ -0,0 +1,167 @@ +/* +TiDB Cloud Serverless Private Link Connection Open API + +TiDB Cloud Serverless Private Link Connection Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package privatelink + +import ( + "encoding/json" + "fmt" +) + +// checks if the PrivateLinkConnectionServiceDetachDomainsBody type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PrivateLinkConnectionServiceDetachDomainsBody{} + +// PrivateLinkConnectionServiceDetachDomainsBody struct for PrivateLinkConnectionServiceDetachDomainsBody +type PrivateLinkConnectionServiceDetachDomainsBody struct { + // The attached domain ID to detach. + AttachDomainId string `json:"attachDomainId"` + AdditionalProperties map[string]interface{} +} + +type _PrivateLinkConnectionServiceDetachDomainsBody PrivateLinkConnectionServiceDetachDomainsBody + +// NewPrivateLinkConnectionServiceDetachDomainsBody instantiates a new PrivateLinkConnectionServiceDetachDomainsBody object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewPrivateLinkConnectionServiceDetachDomainsBody(attachDomainId string) *PrivateLinkConnectionServiceDetachDomainsBody { + this := PrivateLinkConnectionServiceDetachDomainsBody{} + this.AttachDomainId = attachDomainId + return &this +} + +// NewPrivateLinkConnectionServiceDetachDomainsBodyWithDefaults instantiates a new PrivateLinkConnectionServiceDetachDomainsBody object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewPrivateLinkConnectionServiceDetachDomainsBodyWithDefaults() *PrivateLinkConnectionServiceDetachDomainsBody { + this := PrivateLinkConnectionServiceDetachDomainsBody{} + return &this +} + +// GetAttachDomainId returns the AttachDomainId field value +func (o *PrivateLinkConnectionServiceDetachDomainsBody) GetAttachDomainId() string { + if o == nil { + var ret string + return ret + } + + return o.AttachDomainId +} + +// GetAttachDomainIdOk returns a tuple with the AttachDomainId field value +// and a boolean to check if the value has been set. +func (o *PrivateLinkConnectionServiceDetachDomainsBody) GetAttachDomainIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AttachDomainId, true +} + +// SetAttachDomainId sets field value +func (o *PrivateLinkConnectionServiceDetachDomainsBody) SetAttachDomainId(v string) { + o.AttachDomainId = v +} + +func (o PrivateLinkConnectionServiceDetachDomainsBody) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o PrivateLinkConnectionServiceDetachDomainsBody) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["attachDomainId"] = o.AttachDomainId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *PrivateLinkConnectionServiceDetachDomainsBody) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "attachDomainId", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varPrivateLinkConnectionServiceDetachDomainsBody := _PrivateLinkConnectionServiceDetachDomainsBody{} + + err = json.Unmarshal(data, &varPrivateLinkConnectionServiceDetachDomainsBody) + + if err != nil { + return err + } + + *o = PrivateLinkConnectionServiceDetachDomainsBody(varPrivateLinkConnectionServiceDetachDomainsBody) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "attachDomainId") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullablePrivateLinkConnectionServiceDetachDomainsBody struct { + value *PrivateLinkConnectionServiceDetachDomainsBody + isSet bool +} + +func (v NullablePrivateLinkConnectionServiceDetachDomainsBody) Get() *PrivateLinkConnectionServiceDetachDomainsBody { + return v.value +} + +func (v *NullablePrivateLinkConnectionServiceDetachDomainsBody) Set(val *PrivateLinkConnectionServiceDetachDomainsBody) { + v.value = val + v.isSet = true +} + +func (v NullablePrivateLinkConnectionServiceDetachDomainsBody) IsSet() bool { + return v.isSet +} + +func (v *NullablePrivateLinkConnectionServiceDetachDomainsBody) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePrivateLinkConnectionServiceDetachDomainsBody(val *PrivateLinkConnectionServiceDetachDomainsBody) *NullablePrivateLinkConnectionServiceDetachDomainsBody { + return &NullablePrivateLinkConnectionServiceDetachDomainsBody{value: val, isSet: true} +} + +func (v NullablePrivateLinkConnectionServiceDetachDomainsBody) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePrivateLinkConnectionServiceDetachDomainsBody) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_list_private_link_connections_state_parameter.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_list_private_link_connections_state_parameter.go new file mode 100644 index 00000000..a1c3b138 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_list_private_link_connections_state_parameter.go @@ -0,0 +1,111 @@ +/* +TiDB Cloud Serverless Private Link Connection Open API + +TiDB Cloud Serverless Private Link Connection Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package privatelink + +import ( + "encoding/json" +) + +// PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter the model 'PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter' +type PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter string + +// List of PrivateLinkConnectionService_ListPrivateLinkConnections_state_parameter +const ( + PRIVATELINKCONNECTIONSERVICELISTPRIVATELINKCONNECTIONSSTATEPARAMETER_CREATING PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter = "CREATING" + PRIVATELINKCONNECTIONSERVICELISTPRIVATELINKCONNECTIONSSTATEPARAMETER_ACTIVE PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter = "ACTIVE" + PRIVATELINKCONNECTIONSERVICELISTPRIVATELINKCONNECTIONSSTATEPARAMETER_FAILED PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter = "FAILED" + PRIVATELINKCONNECTIONSERVICELISTPRIVATELINKCONNECTIONSSTATEPARAMETER_PENDING_ACCEPTANCE PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter = "PENDING_ACCEPTANCE" + PRIVATELINKCONNECTIONSERVICELISTPRIVATELINKCONNECTIONSSTATEPARAMETER_DELETING PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter = "DELETING" +) + +// All allowed values of PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter enum +var AllowedPrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameterEnumValues = []PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter{ + "CREATING", + "ACTIVE", + "FAILED", + "PENDING_ACCEPTANCE", + "DELETING", +} + +func (v *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter(value) + for _, existing := range AllowedPrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameterEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + *v = PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter(value) + return nil +} + +// NewPrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameterFromValue returns a pointer to a valid PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter for the value passed as argument +func NewPrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameterFromValue(v string) *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter { + ev := PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter(v) + return &ev +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) IsValid() bool { + for _, existing := range AllowedPrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameterEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to PrivateLinkConnectionService_ListPrivateLinkConnections_state_parameter value +func (v PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) Ptr() *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter { + return &v +} + +type NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter struct { + value *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter + isSet bool +} + +func (v NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) Get() *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter { + return v.value +} + +func (v *NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) Set(val *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) { + v.value = val + v.isSet = true +} + +func (v NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) IsSet() bool { + return v.isSet +} + +func (v *NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter(val *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) *NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter { + return &NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter{value: val, isSet: true} +} + +func (v NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_state_enum.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_state_enum.go index 2eb1b7b3..d07e374e 100644 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_state_enum.go +++ b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_state_enum.go @@ -14,7 +14,7 @@ import ( "encoding/json" ) -// PrivateLinkConnectionStateEnum the model 'PrivateLinkConnectionStateEnum' +// PrivateLinkConnectionStateEnum - CREATING: The private link connection is being created. - ACTIVE: The private link connection is active. - FAILED: The private link connection is in failed state. - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service. - DELETING: The private link connection is being deleted. type PrivateLinkConnectionStateEnum string // List of PrivateLinkConnectionState.Enum @@ -24,7 +24,6 @@ const ( PRIVATELINKCONNECTIONSTATEENUM_FAILED PrivateLinkConnectionStateEnum = "FAILED" PRIVATELINKCONNECTIONSTATEENUM_PENDING_ACCEPTANCE PrivateLinkConnectionStateEnum = "PENDING_ACCEPTANCE" PRIVATELINKCONNECTIONSTATEENUM_DELETING PrivateLinkConnectionStateEnum = "DELETING" - PRIVATELINKCONNECTIONSTATEENUM_CONNECTING PrivateLinkConnectionStateEnum = "CONNECTING" ) // All allowed values of PrivateLinkConnectionStateEnum enum @@ -34,7 +33,6 @@ var AllowedPrivateLinkConnectionStateEnumEnumValues = []PrivateLinkConnectionSta "FAILED", "PENDING_ACCEPTANCE", "DELETING", - "CONNECTING", } func (v *PrivateLinkConnectionStateEnum) UnmarshalJSON(src []byte) error {