// Copyright 2025 Google LLC // // 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 // // https://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. // Code generated by protoc-gen-go_gapic. DO NOT EDIT. package managedkafka import ( "bytes" "context" "fmt" "log/slog" "math" "net/http" "net/url" "time" "cloud.google.com/go/longrunning" lroauto "cloud.google.com/go/longrunning/autogen" longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" managedkafkapb "cloud.google.com/go/managedkafka/apiv1/managedkafkapb" gax "github.com/googleapis/gax-go/v2" "google.golang.org/api/iterator" "google.golang.org/api/option" "google.golang.org/api/option/internaloption" gtransport "google.golang.org/api/transport/grpc" httptransport "google.golang.org/api/transport/http" locationpb "google.golang.org/genproto/googleapis/cloud/location" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" ) var newManagedKafkaConnectClientHook clientHook // ManagedKafkaConnectCallOptions contains the retry settings for each method of ManagedKafkaConnectClient. type ManagedKafkaConnectCallOptions struct { ListConnectClusters []gax.CallOption GetConnectCluster []gax.CallOption CreateConnectCluster []gax.CallOption UpdateConnectCluster []gax.CallOption DeleteConnectCluster []gax.CallOption ListConnectors []gax.CallOption GetConnector []gax.CallOption CreateConnector []gax.CallOption UpdateConnector []gax.CallOption DeleteConnector []gax.CallOption PauseConnector []gax.CallOption ResumeConnector []gax.CallOption RestartConnector []gax.CallOption StopConnector []gax.CallOption GetLocation []gax.CallOption ListLocations []gax.CallOption CancelOperation []gax.CallOption DeleteOperation []gax.CallOption GetOperation []gax.CallOption ListOperations []gax.CallOption } func defaultManagedKafkaConnectGRPCClientOptions() []option.ClientOption { return []option.ClientOption{ internaloption.WithDefaultEndpoint("managedkafka.googleapis.com:443"), internaloption.WithDefaultEndpointTemplate("managedkafka.UNIVERSE_DOMAIN:443"), internaloption.WithDefaultMTLSEndpoint("managedkafka.mtls.googleapis.com:443"), internaloption.WithDefaultUniverseDomain("googleapis.com"), internaloption.WithDefaultAudience("https://managedkafka.googleapis.com/"), internaloption.WithDefaultScopes(DefaultAuthScopes()...), internaloption.EnableJwtWithScope(), internaloption.EnableNewAuthLibrary(), option.WithGRPCDialOption(grpc.WithDefaultCallOptions( grpc.MaxCallRecvMsgSize(math.MaxInt32))), } } func defaultManagedKafkaConnectCallOptions() *ManagedKafkaConnectCallOptions { return &ManagedKafkaConnectCallOptions{ ListConnectClusters: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), gax.WithRetry(func() gax.Retryer { return gax.OnCodes([]codes.Code{ codes.Unavailable, }, gax.Backoff{ Initial: 1000 * time.Millisecond, Max: 10000 * time.Millisecond, Multiplier: 1.30, }) }), }, GetConnectCluster: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), gax.WithRetry(func() gax.Retryer { return gax.OnCodes([]codes.Code{ codes.Unavailable, }, gax.Backoff{ Initial: 1000 * time.Millisecond, Max: 10000 * time.Millisecond, Multiplier: 1.30, }) }), }, CreateConnectCluster: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, UpdateConnectCluster: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, DeleteConnectCluster: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, ListConnectors: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), gax.WithRetry(func() gax.Retryer { return gax.OnCodes([]codes.Code{ codes.Unavailable, }, gax.Backoff{ Initial: 1000 * time.Millisecond, Max: 10000 * time.Millisecond, Multiplier: 1.30, }) }), }, GetConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), gax.WithRetry(func() gax.Retryer { return gax.OnCodes([]codes.Code{ codes.Unavailable, }, gax.Backoff{ Initial: 1000 * time.Millisecond, Max: 10000 * time.Millisecond, Multiplier: 1.30, }) }), }, CreateConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, UpdateConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, DeleteConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, PauseConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, ResumeConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, RestartConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, StopConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, GetLocation: []gax.CallOption{}, ListLocations: []gax.CallOption{}, CancelOperation: []gax.CallOption{}, DeleteOperation: []gax.CallOption{}, GetOperation: []gax.CallOption{}, ListOperations: []gax.CallOption{}, } } func defaultManagedKafkaConnectRESTCallOptions() *ManagedKafkaConnectCallOptions { return &ManagedKafkaConnectCallOptions{ ListConnectClusters: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), gax.WithRetry(func() gax.Retryer { return gax.OnHTTPCodes(gax.Backoff{ Initial: 1000 * time.Millisecond, Max: 10000 * time.Millisecond, Multiplier: 1.30, }, http.StatusServiceUnavailable) }), }, GetConnectCluster: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), gax.WithRetry(func() gax.Retryer { return gax.OnHTTPCodes(gax.Backoff{ Initial: 1000 * time.Millisecond, Max: 10000 * time.Millisecond, Multiplier: 1.30, }, http.StatusServiceUnavailable) }), }, CreateConnectCluster: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, UpdateConnectCluster: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, DeleteConnectCluster: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, ListConnectors: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), gax.WithRetry(func() gax.Retryer { return gax.OnHTTPCodes(gax.Backoff{ Initial: 1000 * time.Millisecond, Max: 10000 * time.Millisecond, Multiplier: 1.30, }, http.StatusServiceUnavailable) }), }, GetConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), gax.WithRetry(func() gax.Retryer { return gax.OnHTTPCodes(gax.Backoff{ Initial: 1000 * time.Millisecond, Max: 10000 * time.Millisecond, Multiplier: 1.30, }, http.StatusServiceUnavailable) }), }, CreateConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, UpdateConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, DeleteConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, PauseConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, ResumeConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, RestartConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, StopConnector: []gax.CallOption{ gax.WithTimeout(60000 * time.Millisecond), }, GetLocation: []gax.CallOption{}, ListLocations: []gax.CallOption{}, CancelOperation: []gax.CallOption{}, DeleteOperation: []gax.CallOption{}, GetOperation: []gax.CallOption{}, ListOperations: []gax.CallOption{}, } } // internalManagedKafkaConnectClient is an interface that defines the methods available from Managed Service for Apache Kafka API. type internalManagedKafkaConnectClient interface { Close() error setGoogleClientInfo(...string) Connection() *grpc.ClientConn ListConnectClusters(context.Context, *managedkafkapb.ListConnectClustersRequest, ...gax.CallOption) *ConnectClusterIterator GetConnectCluster(context.Context, *managedkafkapb.GetConnectClusterRequest, ...gax.CallOption) (*managedkafkapb.ConnectCluster, error) CreateConnectCluster(context.Context, *managedkafkapb.CreateConnectClusterRequest, ...gax.CallOption) (*CreateConnectClusterOperation, error) CreateConnectClusterOperation(name string) *CreateConnectClusterOperation UpdateConnectCluster(context.Context, *managedkafkapb.UpdateConnectClusterRequest, ...gax.CallOption) (*UpdateConnectClusterOperation, error) UpdateConnectClusterOperation(name string) *UpdateConnectClusterOperation DeleteConnectCluster(context.Context, *managedkafkapb.DeleteConnectClusterRequest, ...gax.CallOption) (*DeleteConnectClusterOperation, error) DeleteConnectClusterOperation(name string) *DeleteConnectClusterOperation ListConnectors(context.Context, *managedkafkapb.ListConnectorsRequest, ...gax.CallOption) *ConnectorIterator GetConnector(context.Context, *managedkafkapb.GetConnectorRequest, ...gax.CallOption) (*managedkafkapb.Connector, error) CreateConnector(context.Context, *managedkafkapb.CreateConnectorRequest, ...gax.CallOption) (*managedkafkapb.Connector, error) UpdateConnector(context.Context, *managedkafkapb.UpdateConnectorRequest, ...gax.CallOption) (*managedkafkapb.Connector, error) DeleteConnector(context.Context, *managedkafkapb.DeleteConnectorRequest, ...gax.CallOption) error PauseConnector(context.Context, *managedkafkapb.PauseConnectorRequest, ...gax.CallOption) (*managedkafkapb.PauseConnectorResponse, error) ResumeConnector(context.Context, *managedkafkapb.ResumeConnectorRequest, ...gax.CallOption) (*managedkafkapb.ResumeConnectorResponse, error) RestartConnector(context.Context, *managedkafkapb.RestartConnectorRequest, ...gax.CallOption) (*managedkafkapb.RestartConnectorResponse, error) StopConnector(context.Context, *managedkafkapb.StopConnectorRequest, ...gax.CallOption) (*managedkafkapb.StopConnectorResponse, error) GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator } // ManagedKafkaConnectClient is a client for interacting with Managed Service for Apache Kafka API. // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. // // The service that a client application uses to manage Apache Kafka Connect // clusters and connectors. type ManagedKafkaConnectClient struct { // The internal transport-dependent client. internalClient internalManagedKafkaConnectClient // The call options for this service. CallOptions *ManagedKafkaConnectCallOptions // LROClient is used internally to handle long-running operations. // It is exposed so that its CallOptions can be modified if required. // Users should not Close this client. LROClient *lroauto.OperationsClient } // Wrapper methods routed to the internal client. // Close closes the connection to the API service. The user should invoke this when // the client is no longer required. func (c *ManagedKafkaConnectClient) Close() error { return c.internalClient.Close() } // setGoogleClientInfo sets the name and version of the application in // the `x-goog-api-client` header passed on each request. Intended for // use by Google-written clients. func (c *ManagedKafkaConnectClient) setGoogleClientInfo(keyval ...string) { c.internalClient.setGoogleClientInfo(keyval...) } // Connection returns a connection to the API service. // // Deprecated: Connections are now pooled so this method does not always // return the same resource. func (c *ManagedKafkaConnectClient) Connection() *grpc.ClientConn { return c.internalClient.Connection() } // ListConnectClusters lists the Kafka Connect clusters in a given project and location. func (c *ManagedKafkaConnectClient) ListConnectClusters(ctx context.Context, req *managedkafkapb.ListConnectClustersRequest, opts ...gax.CallOption) *ConnectClusterIterator { return c.internalClient.ListConnectClusters(ctx, req, opts...) } // GetConnectCluster returns the properties of a single Kafka Connect cluster. func (c *ManagedKafkaConnectClient) GetConnectCluster(ctx context.Context, req *managedkafkapb.GetConnectClusterRequest, opts ...gax.CallOption) (*managedkafkapb.ConnectCluster, error) { return c.internalClient.GetConnectCluster(ctx, req, opts...) } // CreateConnectCluster creates a new Kafka Connect cluster in a given project and location. func (c *ManagedKafkaConnectClient) CreateConnectCluster(ctx context.Context, req *managedkafkapb.CreateConnectClusterRequest, opts ...gax.CallOption) (*CreateConnectClusterOperation, error) { return c.internalClient.CreateConnectCluster(ctx, req, opts...) } // CreateConnectClusterOperation returns a new CreateConnectClusterOperation from a given name. // The name must be that of a previously created CreateConnectClusterOperation, possibly from a different process. func (c *ManagedKafkaConnectClient) CreateConnectClusterOperation(name string) *CreateConnectClusterOperation { return c.internalClient.CreateConnectClusterOperation(name) } // UpdateConnectCluster updates the properties of a single Kafka Connect cluster. func (c *ManagedKafkaConnectClient) UpdateConnectCluster(ctx context.Context, req *managedkafkapb.UpdateConnectClusterRequest, opts ...gax.CallOption) (*UpdateConnectClusterOperation, error) { return c.internalClient.UpdateConnectCluster(ctx, req, opts...) } // UpdateConnectClusterOperation returns a new UpdateConnectClusterOperation from a given name. // The name must be that of a previously created UpdateConnectClusterOperation, possibly from a different process. func (c *ManagedKafkaConnectClient) UpdateConnectClusterOperation(name string) *UpdateConnectClusterOperation { return c.internalClient.UpdateConnectClusterOperation(name) } // DeleteConnectCluster deletes a single Connect cluster. func (c *ManagedKafkaConnectClient) DeleteConnectCluster(ctx context.Context, req *managedkafkapb.DeleteConnectClusterRequest, opts ...gax.CallOption) (*DeleteConnectClusterOperation, error) { return c.internalClient.DeleteConnectCluster(ctx, req, opts...) } // DeleteConnectClusterOperation returns a new DeleteConnectClusterOperation from a given name. // The name must be that of a previously created DeleteConnectClusterOperation, possibly from a different process. func (c *ManagedKafkaConnectClient) DeleteConnectClusterOperation(name string) *DeleteConnectClusterOperation { return c.internalClient.DeleteConnectClusterOperation(name) } // ListConnectors lists the connectors in a given Connect cluster. func (c *ManagedKafkaConnectClient) ListConnectors(ctx context.Context, req *managedkafkapb.ListConnectorsRequest, opts ...gax.CallOption) *ConnectorIterator { return c.internalClient.ListConnectors(ctx, req, opts...) } // GetConnector returns the properties of a single connector. func (c *ManagedKafkaConnectClient) GetConnector(ctx context.Context, req *managedkafkapb.GetConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.Connector, error) { return c.internalClient.GetConnector(ctx, req, opts...) } // CreateConnector creates a new connector in a given Connect cluster. func (c *ManagedKafkaConnectClient) CreateConnector(ctx context.Context, req *managedkafkapb.CreateConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.Connector, error) { return c.internalClient.CreateConnector(ctx, req, opts...) } // UpdateConnector updates the properties of a connector. func (c *ManagedKafkaConnectClient) UpdateConnector(ctx context.Context, req *managedkafkapb.UpdateConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.Connector, error) { return c.internalClient.UpdateConnector(ctx, req, opts...) } // DeleteConnector deletes a connector. func (c *ManagedKafkaConnectClient) DeleteConnector(ctx context.Context, req *managedkafkapb.DeleteConnectorRequest, opts ...gax.CallOption) error { return c.internalClient.DeleteConnector(ctx, req, opts...) } // PauseConnector pauses the connector and its tasks. func (c *ManagedKafkaConnectClient) PauseConnector(ctx context.Context, req *managedkafkapb.PauseConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.PauseConnectorResponse, error) { return c.internalClient.PauseConnector(ctx, req, opts...) } // ResumeConnector resumes the connector and its tasks. func (c *ManagedKafkaConnectClient) ResumeConnector(ctx context.Context, req *managedkafkapb.ResumeConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.ResumeConnectorResponse, error) { return c.internalClient.ResumeConnector(ctx, req, opts...) } // RestartConnector restarts the connector. func (c *ManagedKafkaConnectClient) RestartConnector(ctx context.Context, req *managedkafkapb.RestartConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.RestartConnectorResponse, error) { return c.internalClient.RestartConnector(ctx, req, opts...) } // StopConnector stops the connector. func (c *ManagedKafkaConnectClient) StopConnector(ctx context.Context, req *managedkafkapb.StopConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.StopConnectorResponse, error) { return c.internalClient.StopConnector(ctx, req, opts...) } // GetLocation gets information about a location. func (c *ManagedKafkaConnectClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { return c.internalClient.GetLocation(ctx, req, opts...) } // ListLocations lists information about the supported locations for this service. func (c *ManagedKafkaConnectClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { return c.internalClient.ListLocations(ctx, req, opts...) } // CancelOperation is a utility method from google.longrunning.Operations. func (c *ManagedKafkaConnectClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { return c.internalClient.CancelOperation(ctx, req, opts...) } // DeleteOperation is a utility method from google.longrunning.Operations. func (c *ManagedKafkaConnectClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { return c.internalClient.DeleteOperation(ctx, req, opts...) } // GetOperation is a utility method from google.longrunning.Operations. func (c *ManagedKafkaConnectClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { return c.internalClient.GetOperation(ctx, req, opts...) } // ListOperations is a utility method from google.longrunning.Operations. func (c *ManagedKafkaConnectClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { return c.internalClient.ListOperations(ctx, req, opts...) } // managedKafkaConnectGRPCClient is a client for interacting with Managed Service for Apache Kafka API over gRPC transport. // // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. type managedKafkaConnectGRPCClient struct { // Connection pool of gRPC connections to the service. connPool gtransport.ConnPool // Points back to the CallOptions field of the containing ManagedKafkaConnectClient CallOptions **ManagedKafkaConnectCallOptions // The gRPC API client. managedKafkaConnectClient managedkafkapb.ManagedKafkaConnectClient // LROClient is used internally to handle long-running operations. // It is exposed so that its CallOptions can be modified if required. // Users should not Close this client. LROClient **lroauto.OperationsClient operationsClient longrunningpb.OperationsClient locationsClient locationpb.LocationsClient // The x-goog-* metadata to be sent with each request. xGoogHeaders []string logger *slog.Logger } // NewManagedKafkaConnectClient creates a new managed kafka connect client based on gRPC. // The returned client must be Closed when it is done being used to clean up its underlying connections. // // The service that a client application uses to manage Apache Kafka Connect // clusters and connectors. func NewManagedKafkaConnectClient(ctx context.Context, opts ...option.ClientOption) (*ManagedKafkaConnectClient, error) { clientOpts := defaultManagedKafkaConnectGRPCClientOptions() if newManagedKafkaConnectClientHook != nil { hookOpts, err := newManagedKafkaConnectClientHook(ctx, clientHookParams{}) if err != nil { return nil, err } clientOpts = append(clientOpts, hookOpts...) } connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) if err != nil { return nil, err } client := ManagedKafkaConnectClient{CallOptions: defaultManagedKafkaConnectCallOptions()} c := &managedKafkaConnectGRPCClient{ connPool: connPool, managedKafkaConnectClient: managedkafkapb.NewManagedKafkaConnectClient(connPool), CallOptions: &client.CallOptions, logger: internaloption.GetLogger(opts), operationsClient: longrunningpb.NewOperationsClient(connPool), locationsClient: locationpb.NewLocationsClient(connPool), } c.setGoogleClientInfo() client.internalClient = c client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) if err != nil { // This error "should not happen", since we are just reusing old connection pool // and never actually need to dial. // If this does happen, we could leak connp. However, we cannot close conn: // If the user invoked the constructor with option.WithGRPCConn, // we would close a connection that's still in use. // TODO: investigate error conditions. return nil, err } c.LROClient = &client.LROClient return &client, nil } // Connection returns a connection to the API service. // // Deprecated: Connections are now pooled so this method does not always // return the same resource. func (c *managedKafkaConnectGRPCClient) Connection() *grpc.ClientConn { return c.connPool.Conn() } // setGoogleClientInfo sets the name and version of the application in // the `x-goog-api-client` header passed on each request. Intended for // use by Google-written clients. func (c *managedKafkaConnectGRPCClient) setGoogleClientInfo(keyval ...string) { kv := append([]string{"gl-go", gax.GoVersion}, keyval...) kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) c.xGoogHeaders = []string{ "x-goog-api-client", gax.XGoogHeader(kv...), } } // Close closes the connection to the API service. The user should invoke this when // the client is no longer required. func (c *managedKafkaConnectGRPCClient) Close() error { return c.connPool.Close() } // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. type managedKafkaConnectRESTClient struct { // The http endpoint to connect to. endpoint string // The http client. httpClient *http.Client // LROClient is used internally to handle long-running operations. // It is exposed so that its CallOptions can be modified if required. // Users should not Close this client. LROClient **lroauto.OperationsClient // The x-goog-* headers to be sent with each request. xGoogHeaders []string // Points back to the CallOptions field of the containing ManagedKafkaConnectClient CallOptions **ManagedKafkaConnectCallOptions logger *slog.Logger } // NewManagedKafkaConnectRESTClient creates a new managed kafka connect rest client. // // The service that a client application uses to manage Apache Kafka Connect // clusters and connectors. func NewManagedKafkaConnectRESTClient(ctx context.Context, opts ...option.ClientOption) (*ManagedKafkaConnectClient, error) { clientOpts := append(defaultManagedKafkaConnectRESTClientOptions(), opts...) httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) if err != nil { return nil, err } callOpts := defaultManagedKafkaConnectRESTCallOptions() c := &managedKafkaConnectRESTClient{ endpoint: endpoint, httpClient: httpClient, CallOptions: &callOpts, logger: internaloption.GetLogger(opts), } c.setGoogleClientInfo() lroOpts := []option.ClientOption{ option.WithHTTPClient(httpClient), option.WithEndpoint(endpoint), } opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...) if err != nil { return nil, err } c.LROClient = &opClient return &ManagedKafkaConnectClient{internalClient: c, CallOptions: callOpts}, nil } func defaultManagedKafkaConnectRESTClientOptions() []option.ClientOption { return []option.ClientOption{ internaloption.WithDefaultEndpoint("https://managedkafka.googleapis.com"), internaloption.WithDefaultEndpointTemplate("https://managedkafka.UNIVERSE_DOMAIN"), internaloption.WithDefaultMTLSEndpoint("https://managedkafka.mtls.googleapis.com"), internaloption.WithDefaultUniverseDomain("googleapis.com"), internaloption.WithDefaultAudience("https://managedkafka.googleapis.com/"), internaloption.WithDefaultScopes(DefaultAuthScopes()...), internaloption.EnableNewAuthLibrary(), } } // setGoogleClientInfo sets the name and version of the application in // the `x-goog-api-client` header passed on each request. Intended for // use by Google-written clients. func (c *managedKafkaConnectRESTClient) setGoogleClientInfo(keyval ...string) { kv := append([]string{"gl-go", gax.GoVersion}, keyval...) kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion) c.xGoogHeaders = []string{ "x-goog-api-client", gax.XGoogHeader(kv...), } } // Close closes the connection to the API service. The user should invoke this when // the client is no longer required. func (c *managedKafkaConnectRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil return nil } // Connection returns a connection to the API service. // // Deprecated: This method always returns nil. func (c *managedKafkaConnectRESTClient) Connection() *grpc.ClientConn { return nil } func (c *managedKafkaConnectGRPCClient) ListConnectClusters(ctx context.Context, req *managedkafkapb.ListConnectClustersRequest, opts ...gax.CallOption) *ConnectClusterIterator { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).ListConnectClusters[0:len((*c.CallOptions).ListConnectClusters):len((*c.CallOptions).ListConnectClusters)], opts...) it := &ConnectClusterIterator{} req = proto.Clone(req).(*managedkafkapb.ListConnectClustersRequest) it.InternalFetch = func(pageSize int, pageToken string) ([]*managedkafkapb.ConnectCluster, string, error) { resp := &managedkafkapb.ListConnectClustersResponse{} if pageToken != "" { req.PageToken = pageToken } if pageSize > math.MaxInt32 { req.PageSize = math.MaxInt32 } else if pageSize != 0 { req.PageSize = int32(pageSize) } err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.ListConnectClusters, req, settings.GRPC, c.logger, "ListConnectClusters") return err }, opts...) if err != nil { return nil, "", err } it.Response = resp return resp.GetConnectClusters(), resp.GetNextPageToken(), nil } fetch := func(pageSize int, pageToken string) (string, error) { items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) if err != nil { return "", err } it.items = append(it.items, items...) return nextPageToken, nil } it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) it.pageInfo.MaxSize = int(req.GetPageSize()) it.pageInfo.Token = req.GetPageToken() return it } func (c *managedKafkaConnectGRPCClient) GetConnectCluster(ctx context.Context, req *managedkafkapb.GetConnectClusterRequest, opts ...gax.CallOption) (*managedkafkapb.ConnectCluster, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).GetConnectCluster[0:len((*c.CallOptions).GetConnectCluster):len((*c.CallOptions).GetConnectCluster)], opts...) var resp *managedkafkapb.ConnectCluster err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.GetConnectCluster, req, settings.GRPC, c.logger, "GetConnectCluster") return err }, opts...) if err != nil { return nil, err } return resp, nil } func (c *managedKafkaConnectGRPCClient) CreateConnectCluster(ctx context.Context, req *managedkafkapb.CreateConnectClusterRequest, opts ...gax.CallOption) (*CreateConnectClusterOperation, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).CreateConnectCluster[0:len((*c.CallOptions).CreateConnectCluster):len((*c.CallOptions).CreateConnectCluster)], opts...) var resp *longrunningpb.Operation err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.CreateConnectCluster, req, settings.GRPC, c.logger, "CreateConnectCluster") return err }, opts...) if err != nil { return nil, err } return &CreateConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, resp), }, nil } func (c *managedKafkaConnectGRPCClient) UpdateConnectCluster(ctx context.Context, req *managedkafkapb.UpdateConnectClusterRequest, opts ...gax.CallOption) (*UpdateConnectClusterOperation, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "connect_cluster.name", url.QueryEscape(req.GetConnectCluster().GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).UpdateConnectCluster[0:len((*c.CallOptions).UpdateConnectCluster):len((*c.CallOptions).UpdateConnectCluster)], opts...) var resp *longrunningpb.Operation err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.UpdateConnectCluster, req, settings.GRPC, c.logger, "UpdateConnectCluster") return err }, opts...) if err != nil { return nil, err } return &UpdateConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, resp), }, nil } func (c *managedKafkaConnectGRPCClient) DeleteConnectCluster(ctx context.Context, req *managedkafkapb.DeleteConnectClusterRequest, opts ...gax.CallOption) (*DeleteConnectClusterOperation, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).DeleteConnectCluster[0:len((*c.CallOptions).DeleteConnectCluster):len((*c.CallOptions).DeleteConnectCluster)], opts...) var resp *longrunningpb.Operation err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.DeleteConnectCluster, req, settings.GRPC, c.logger, "DeleteConnectCluster") return err }, opts...) if err != nil { return nil, err } return &DeleteConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, resp), }, nil } func (c *managedKafkaConnectGRPCClient) ListConnectors(ctx context.Context, req *managedkafkapb.ListConnectorsRequest, opts ...gax.CallOption) *ConnectorIterator { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).ListConnectors[0:len((*c.CallOptions).ListConnectors):len((*c.CallOptions).ListConnectors)], opts...) it := &ConnectorIterator{} req = proto.Clone(req).(*managedkafkapb.ListConnectorsRequest) it.InternalFetch = func(pageSize int, pageToken string) ([]*managedkafkapb.Connector, string, error) { resp := &managedkafkapb.ListConnectorsResponse{} if pageToken != "" { req.PageToken = pageToken } if pageSize > math.MaxInt32 { req.PageSize = math.MaxInt32 } else if pageSize != 0 { req.PageSize = int32(pageSize) } err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.ListConnectors, req, settings.GRPC, c.logger, "ListConnectors") return err }, opts...) if err != nil { return nil, "", err } it.Response = resp return resp.GetConnectors(), resp.GetNextPageToken(), nil } fetch := func(pageSize int, pageToken string) (string, error) { items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) if err != nil { return "", err } it.items = append(it.items, items...) return nextPageToken, nil } it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) it.pageInfo.MaxSize = int(req.GetPageSize()) it.pageInfo.Token = req.GetPageToken() return it } func (c *managedKafkaConnectGRPCClient) GetConnector(ctx context.Context, req *managedkafkapb.GetConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.Connector, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).GetConnector[0:len((*c.CallOptions).GetConnector):len((*c.CallOptions).GetConnector)], opts...) var resp *managedkafkapb.Connector err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.GetConnector, req, settings.GRPC, c.logger, "GetConnector") return err }, opts...) if err != nil { return nil, err } return resp, nil } func (c *managedKafkaConnectGRPCClient) CreateConnector(ctx context.Context, req *managedkafkapb.CreateConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.Connector, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).CreateConnector[0:len((*c.CallOptions).CreateConnector):len((*c.CallOptions).CreateConnector)], opts...) var resp *managedkafkapb.Connector err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.CreateConnector, req, settings.GRPC, c.logger, "CreateConnector") return err }, opts...) if err != nil { return nil, err } return resp, nil } func (c *managedKafkaConnectGRPCClient) UpdateConnector(ctx context.Context, req *managedkafkapb.UpdateConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.Connector, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "connector.name", url.QueryEscape(req.GetConnector().GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).UpdateConnector[0:len((*c.CallOptions).UpdateConnector):len((*c.CallOptions).UpdateConnector)], opts...) var resp *managedkafkapb.Connector err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.UpdateConnector, req, settings.GRPC, c.logger, "UpdateConnector") return err }, opts...) if err != nil { return nil, err } return resp, nil } func (c *managedKafkaConnectGRPCClient) DeleteConnector(ctx context.Context, req *managedkafkapb.DeleteConnectorRequest, opts ...gax.CallOption) error { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).DeleteConnector[0:len((*c.CallOptions).DeleteConnector):len((*c.CallOptions).DeleteConnector)], opts...) err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error _, err = executeRPC(ctx, c.managedKafkaConnectClient.DeleteConnector, req, settings.GRPC, c.logger, "DeleteConnector") return err }, opts...) return err } func (c *managedKafkaConnectGRPCClient) PauseConnector(ctx context.Context, req *managedkafkapb.PauseConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.PauseConnectorResponse, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).PauseConnector[0:len((*c.CallOptions).PauseConnector):len((*c.CallOptions).PauseConnector)], opts...) var resp *managedkafkapb.PauseConnectorResponse err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.PauseConnector, req, settings.GRPC, c.logger, "PauseConnector") return err }, opts...) if err != nil { return nil, err } return resp, nil } func (c *managedKafkaConnectGRPCClient) ResumeConnector(ctx context.Context, req *managedkafkapb.ResumeConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.ResumeConnectorResponse, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).ResumeConnector[0:len((*c.CallOptions).ResumeConnector):len((*c.CallOptions).ResumeConnector)], opts...) var resp *managedkafkapb.ResumeConnectorResponse err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.ResumeConnector, req, settings.GRPC, c.logger, "ResumeConnector") return err }, opts...) if err != nil { return nil, err } return resp, nil } func (c *managedKafkaConnectGRPCClient) RestartConnector(ctx context.Context, req *managedkafkapb.RestartConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.RestartConnectorResponse, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).RestartConnector[0:len((*c.CallOptions).RestartConnector):len((*c.CallOptions).RestartConnector)], opts...) var resp *managedkafkapb.RestartConnectorResponse err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.RestartConnector, req, settings.GRPC, c.logger, "RestartConnector") return err }, opts...) if err != nil { return nil, err } return resp, nil } func (c *managedKafkaConnectGRPCClient) StopConnector(ctx context.Context, req *managedkafkapb.StopConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.StopConnectorResponse, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).StopConnector[0:len((*c.CallOptions).StopConnector):len((*c.CallOptions).StopConnector)], opts...) var resp *managedkafkapb.StopConnectorResponse err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.managedKafkaConnectClient.StopConnector, req, settings.GRPC, c.logger, "StopConnector") return err }, opts...) if err != nil { return nil, err } return resp, nil } func (c *managedKafkaConnectGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) var resp *locationpb.Location err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation") return err }, opts...) if err != nil { return nil, err } return resp, nil } func (c *managedKafkaConnectGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) it := &LocationIterator{} req = proto.Clone(req).(*locationpb.ListLocationsRequest) it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { resp := &locationpb.ListLocationsResponse{} if pageToken != "" { req.PageToken = pageToken } if pageSize > math.MaxInt32 { req.PageSize = math.MaxInt32 } else if pageSize != 0 { req.PageSize = int32(pageSize) } err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations") return err }, opts...) if err != nil { return nil, "", err } it.Response = resp return resp.GetLocations(), resp.GetNextPageToken(), nil } fetch := func(pageSize int, pageToken string) (string, error) { items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) if err != nil { return "", err } it.items = append(it.items, items...) return nextPageToken, nil } it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) it.pageInfo.MaxSize = int(req.GetPageSize()) it.pageInfo.Token = req.GetPageToken() return it } func (c *managedKafkaConnectGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation") return err }, opts...) return err } func (c *managedKafkaConnectGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation") return err }, opts...) return err } func (c *managedKafkaConnectGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) var resp *longrunningpb.Operation err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation") return err }, opts...) if err != nil { return nil, err } return resp, nil } func (c *managedKafkaConnectGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) it := &OperationIterator{} req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { resp := &longrunningpb.ListOperationsResponse{} if pageToken != "" { req.PageToken = pageToken } if pageSize > math.MaxInt32 { req.PageSize = math.MaxInt32 } else if pageSize != 0 { req.PageSize = int32(pageSize) } err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { var err error resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations") return err }, opts...) if err != nil { return nil, "", err } it.Response = resp return resp.GetOperations(), resp.GetNextPageToken(), nil } fetch := func(pageSize int, pageToken string) (string, error) { items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) if err != nil { return "", err } it.items = append(it.items, items...) return nextPageToken, nil } it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) it.pageInfo.MaxSize = int(req.GetPageSize()) it.pageInfo.Token = req.GetPageToken() return it } // ListConnectClusters lists the Kafka Connect clusters in a given project and location. func (c *managedKafkaConnectRESTClient) ListConnectClusters(ctx context.Context, req *managedkafkapb.ListConnectClustersRequest, opts ...gax.CallOption) *ConnectClusterIterator { it := &ConnectClusterIterator{} req = proto.Clone(req).(*managedkafkapb.ListConnectClustersRequest) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} it.InternalFetch = func(pageSize int, pageToken string) ([]*managedkafkapb.ConnectCluster, string, error) { resp := &managedkafkapb.ListConnectClustersResponse{} if pageToken != "" { req.PageToken = pageToken } if pageSize > math.MaxInt32 { req.PageSize = math.MaxInt32 } else if pageSize != 0 { req.PageSize = int32(pageSize) } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, "", err } baseUrl.Path += fmt.Sprintf("/v1/%v/connectClusters", req.GetParent()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") if req.GetFilter() != "" { params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) } if req.GetOrderBy() != "" { params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) } if req.GetPageSize() != 0 { params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) } if req.GetPageToken() != "" { params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) } baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := append(c.xGoogHeaders, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) if err != nil { return err } httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListConnectClusters") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, "", e } it.Response = resp return resp.GetConnectClusters(), resp.GetNextPageToken(), nil } fetch := func(pageSize int, pageToken string) (string, error) { items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) if err != nil { return "", err } it.items = append(it.items, items...) return nextPageToken, nil } it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) it.pageInfo.MaxSize = int(req.GetPageSize()) it.pageInfo.Token = req.GetPageToken() return it } // GetConnectCluster returns the properties of a single Kafka Connect cluster. func (c *managedKafkaConnectRESTClient) GetConnectCluster(ctx context.Context, req *managedkafkapb.GetConnectClusterRequest, opts ...gax.CallOption) (*managedkafkapb.ConnectCluster, error) { baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) opts = append((*c.CallOptions).GetConnectCluster[0:len((*c.CallOptions).GetConnectCluster):len((*c.CallOptions).GetConnectCluster)], opts...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &managedkafkapb.ConnectCluster{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetConnectCluster") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } return resp, nil } // CreateConnectCluster creates a new Kafka Connect cluster in a given project and location. func (c *managedKafkaConnectRESTClient) CreateConnectCluster(ctx context.Context, req *managedkafkapb.CreateConnectClusterRequest, opts ...gax.CallOption) (*CreateConnectClusterOperation, error) { m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} body := req.GetConnectCluster() jsonReq, err := m.Marshal(body) if err != nil { return nil, err } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v/connectClusters", req.GetParent()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") params.Add("connectClusterId", fmt.Sprintf("%v", req.GetConnectClusterId())) if req.GetRequestId() != "" { params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) } baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &longrunningpb.Operation{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateConnectCluster") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } override := fmt.Sprintf("/v1/%s", resp.GetName()) return &CreateConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, resp), pollPath: override, }, nil } // UpdateConnectCluster updates the properties of a single Kafka Connect cluster. func (c *managedKafkaConnectRESTClient) UpdateConnectCluster(ctx context.Context, req *managedkafkapb.UpdateConnectClusterRequest, opts ...gax.CallOption) (*UpdateConnectClusterOperation, error) { m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} body := req.GetConnectCluster() jsonReq, err := m.Marshal(body) if err != nil { return nil, err } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetConnectCluster().GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") if req.GetRequestId() != "" { params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) } if req.GetUpdateMask() != nil { field, err := protojson.Marshal(req.GetUpdateMask()) if err != nil { return nil, err } params.Add("updateMask", string(field[1:len(field)-1])) } baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "connect_cluster.name", url.QueryEscape(req.GetConnectCluster().GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &longrunningpb.Operation{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateConnectCluster") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } override := fmt.Sprintf("/v1/%s", resp.GetName()) return &UpdateConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, resp), pollPath: override, }, nil } // DeleteConnectCluster deletes a single Connect cluster. func (c *managedKafkaConnectRESTClient) DeleteConnectCluster(ctx context.Context, req *managedkafkapb.DeleteConnectClusterRequest, opts ...gax.CallOption) (*DeleteConnectClusterOperation, error) { baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") if req.GetRequestId() != "" { params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) } baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &longrunningpb.Operation{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteConnectCluster") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } override := fmt.Sprintf("/v1/%s", resp.GetName()) return &DeleteConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, resp), pollPath: override, }, nil } // ListConnectors lists the connectors in a given Connect cluster. func (c *managedKafkaConnectRESTClient) ListConnectors(ctx context.Context, req *managedkafkapb.ListConnectorsRequest, opts ...gax.CallOption) *ConnectorIterator { it := &ConnectorIterator{} req = proto.Clone(req).(*managedkafkapb.ListConnectorsRequest) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} it.InternalFetch = func(pageSize int, pageToken string) ([]*managedkafkapb.Connector, string, error) { resp := &managedkafkapb.ListConnectorsResponse{} if pageToken != "" { req.PageToken = pageToken } if pageSize > math.MaxInt32 { req.PageSize = math.MaxInt32 } else if pageSize != 0 { req.PageSize = int32(pageSize) } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, "", err } baseUrl.Path += fmt.Sprintf("/v1/%v/connectors", req.GetParent()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") if req.GetPageSize() != 0 { params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) } if req.GetPageToken() != "" { params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) } baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := append(c.xGoogHeaders, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) if err != nil { return err } httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListConnectors") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, "", e } it.Response = resp return resp.GetConnectors(), resp.GetNextPageToken(), nil } fetch := func(pageSize int, pageToken string) (string, error) { items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) if err != nil { return "", err } it.items = append(it.items, items...) return nextPageToken, nil } it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) it.pageInfo.MaxSize = int(req.GetPageSize()) it.pageInfo.Token = req.GetPageToken() return it } // GetConnector returns the properties of a single connector. func (c *managedKafkaConnectRESTClient) GetConnector(ctx context.Context, req *managedkafkapb.GetConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.Connector, error) { baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) opts = append((*c.CallOptions).GetConnector[0:len((*c.CallOptions).GetConnector):len((*c.CallOptions).GetConnector)], opts...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &managedkafkapb.Connector{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetConnector") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } return resp, nil } // CreateConnector creates a new connector in a given Connect cluster. func (c *managedKafkaConnectRESTClient) CreateConnector(ctx context.Context, req *managedkafkapb.CreateConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.Connector, error) { m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} body := req.GetConnector() jsonReq, err := m.Marshal(body) if err != nil { return nil, err } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v/connectors", req.GetParent()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") params.Add("connectorId", fmt.Sprintf("%v", req.GetConnectorId())) baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) opts = append((*c.CallOptions).CreateConnector[0:len((*c.CallOptions).CreateConnector):len((*c.CallOptions).CreateConnector)], opts...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &managedkafkapb.Connector{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateConnector") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } return resp, nil } // UpdateConnector updates the properties of a connector. func (c *managedKafkaConnectRESTClient) UpdateConnector(ctx context.Context, req *managedkafkapb.UpdateConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.Connector, error) { m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} body := req.GetConnector() jsonReq, err := m.Marshal(body) if err != nil { return nil, err } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetConnector().GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") if req.GetUpdateMask() != nil { field, err := protojson.Marshal(req.GetUpdateMask()) if err != nil { return nil, err } params.Add("updateMask", string(field[1:len(field)-1])) } baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "connector.name", url.QueryEscape(req.GetConnector().GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) opts = append((*c.CallOptions).UpdateConnector[0:len((*c.CallOptions).UpdateConnector):len((*c.CallOptions).UpdateConnector)], opts...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &managedkafkapb.Connector{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateConnector") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } return resp, nil } // DeleteConnector deletes a connector. func (c *managedKafkaConnectRESTClient) DeleteConnector(ctx context.Context, req *managedkafkapb.DeleteConnectorRequest, opts ...gax.CallOption) error { baseUrl, err := url.Parse(c.endpoint) if err != nil { return err } baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteConnector") return err }, opts...) } // PauseConnector pauses the connector and its tasks. func (c *managedKafkaConnectRESTClient) PauseConnector(ctx context.Context, req *managedkafkapb.PauseConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.PauseConnectorResponse, error) { m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} jsonReq, err := m.Marshal(req) if err != nil { return nil, err } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v:pause", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) opts = append((*c.CallOptions).PauseConnector[0:len((*c.CallOptions).PauseConnector):len((*c.CallOptions).PauseConnector)], opts...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &managedkafkapb.PauseConnectorResponse{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "PauseConnector") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } return resp, nil } // ResumeConnector resumes the connector and its tasks. func (c *managedKafkaConnectRESTClient) ResumeConnector(ctx context.Context, req *managedkafkapb.ResumeConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.ResumeConnectorResponse, error) { m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} jsonReq, err := m.Marshal(req) if err != nil { return nil, err } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v:resume", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) opts = append((*c.CallOptions).ResumeConnector[0:len((*c.CallOptions).ResumeConnector):len((*c.CallOptions).ResumeConnector)], opts...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &managedkafkapb.ResumeConnectorResponse{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ResumeConnector") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } return resp, nil } // RestartConnector restarts the connector. func (c *managedKafkaConnectRESTClient) RestartConnector(ctx context.Context, req *managedkafkapb.RestartConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.RestartConnectorResponse, error) { m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} jsonReq, err := m.Marshal(req) if err != nil { return nil, err } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v:restart", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) opts = append((*c.CallOptions).RestartConnector[0:len((*c.CallOptions).RestartConnector):len((*c.CallOptions).RestartConnector)], opts...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &managedkafkapb.RestartConnectorResponse{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RestartConnector") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } return resp, nil } // StopConnector stops the connector. func (c *managedKafkaConnectRESTClient) StopConnector(ctx context.Context, req *managedkafkapb.StopConnectorRequest, opts ...gax.CallOption) (*managedkafkapb.StopConnectorResponse, error) { m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} jsonReq, err := m.Marshal(req) if err != nil { return nil, err } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v:stop", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) opts = append((*c.CallOptions).StopConnector[0:len((*c.CallOptions).StopConnector):len((*c.CallOptions).StopConnector)], opts...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &managedkafkapb.StopConnectorResponse{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "StopConnector") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } return resp, nil } // GetLocation gets information about a location. func (c *managedKafkaConnectRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &locationpb.Location{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } return resp, nil } // ListLocations lists information about the supported locations for this service. func (c *managedKafkaConnectRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { it := &LocationIterator{} req = proto.Clone(req).(*locationpb.ListLocationsRequest) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { resp := &locationpb.ListLocationsResponse{} if pageToken != "" { req.PageToken = pageToken } if pageSize > math.MaxInt32 { req.PageSize = math.MaxInt32 } else if pageSize != 0 { req.PageSize = int32(pageSize) } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, "", err } baseUrl.Path += fmt.Sprintf("/v1/%v/locations", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") if req.GetFilter() != "" { params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) } if req.GetPageSize() != 0 { params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) } if req.GetPageToken() != "" { params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) } baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := append(c.xGoogHeaders, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) if err != nil { return err } httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, "", e } it.Response = resp return resp.GetLocations(), resp.GetNextPageToken(), nil } fetch := func(pageSize int, pageToken string) (string, error) { items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) if err != nil { return "", err } it.items = append(it.items, items...) return nextPageToken, nil } it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) it.pageInfo.MaxSize = int(req.GetPageSize()) it.pageInfo.Token = req.GetPageToken() return it } // CancelOperation is a utility method from google.longrunning.Operations. func (c *managedKafkaConnectRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} jsonReq, err := m.Marshal(req) if err != nil { return err } baseUrl, err := url.Parse(c.endpoint) if err != nil { return err } baseUrl.Path += fmt.Sprintf("/v1/%v:cancel", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelOperation") return err }, opts...) } // DeleteOperation is a utility method from google.longrunning.Operations. func (c *managedKafkaConnectRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { baseUrl, err := url.Parse(c.endpoint) if err != nil { return err } baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation") return err }, opts...) } // GetOperation is a utility method from google.longrunning.Operations. func (c *managedKafkaConnectRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, err } baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} hds = append(c.xGoogHeaders, hds...) hds = append(hds, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} resp := &longrunningpb.Operation{} e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) if err != nil { return err } httpReq = httpReq.WithContext(ctx) httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, e } return resp, nil } // ListOperations is a utility method from google.longrunning.Operations. func (c *managedKafkaConnectRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { it := &OperationIterator{} req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { resp := &longrunningpb.ListOperationsResponse{} if pageToken != "" { req.PageToken = pageToken } if pageSize > math.MaxInt32 { req.PageSize = math.MaxInt32 } else if pageSize != 0 { req.PageSize = int32(pageSize) } baseUrl, err := url.Parse(c.endpoint) if err != nil { return nil, "", err } baseUrl.Path += fmt.Sprintf("/v1/%v/operations", req.GetName()) params := url.Values{} params.Add("$alt", "json;enum-encoding=int") if req.GetFilter() != "" { params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) } if req.GetPageSize() != 0 { params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) } if req.GetPageToken() != "" { params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) } baseUrl.RawQuery = params.Encode() // Build HTTP headers from client and context metadata. hds := append(c.xGoogHeaders, "Content-Type", "application/json") headers := gax.BuildHeaders(ctx, hds...) e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { if settings.Path != "" { baseUrl.Path = settings.Path } httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) if err != nil { return err } httpReq.Header = headers buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations") if err != nil { return err } if err := unm.Unmarshal(buf, resp); err != nil { return err } return nil }, opts...) if e != nil { return nil, "", e } it.Response = resp return resp.GetOperations(), resp.GetNextPageToken(), nil } fetch := func(pageSize int, pageToken string) (string, error) { items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) if err != nil { return "", err } it.items = append(it.items, items...) return nextPageToken, nil } it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) it.pageInfo.MaxSize = int(req.GetPageSize()) it.pageInfo.Token = req.GetPageToken() return it } // CreateConnectClusterOperation returns a new CreateConnectClusterOperation from a given name. // The name must be that of a previously created CreateConnectClusterOperation, possibly from a different process. func (c *managedKafkaConnectGRPCClient) CreateConnectClusterOperation(name string) *CreateConnectClusterOperation { return &CreateConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), } } // CreateConnectClusterOperation returns a new CreateConnectClusterOperation from a given name. // The name must be that of a previously created CreateConnectClusterOperation, possibly from a different process. func (c *managedKafkaConnectRESTClient) CreateConnectClusterOperation(name string) *CreateConnectClusterOperation { override := fmt.Sprintf("/v1/%s", name) return &CreateConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), pollPath: override, } } // DeleteConnectClusterOperation returns a new DeleteConnectClusterOperation from a given name. // The name must be that of a previously created DeleteConnectClusterOperation, possibly from a different process. func (c *managedKafkaConnectGRPCClient) DeleteConnectClusterOperation(name string) *DeleteConnectClusterOperation { return &DeleteConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), } } // DeleteConnectClusterOperation returns a new DeleteConnectClusterOperation from a given name. // The name must be that of a previously created DeleteConnectClusterOperation, possibly from a different process. func (c *managedKafkaConnectRESTClient) DeleteConnectClusterOperation(name string) *DeleteConnectClusterOperation { override := fmt.Sprintf("/v1/%s", name) return &DeleteConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), pollPath: override, } } // UpdateConnectClusterOperation returns a new UpdateConnectClusterOperation from a given name. // The name must be that of a previously created UpdateConnectClusterOperation, possibly from a different process. func (c *managedKafkaConnectGRPCClient) UpdateConnectClusterOperation(name string) *UpdateConnectClusterOperation { return &UpdateConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), } } // UpdateConnectClusterOperation returns a new UpdateConnectClusterOperation from a given name. // The name must be that of a previously created UpdateConnectClusterOperation, possibly from a different process. func (c *managedKafkaConnectRESTClient) UpdateConnectClusterOperation(name string) *UpdateConnectClusterOperation { override := fmt.Sprintf("/v1/%s", name) return &UpdateConnectClusterOperation{ lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), pollPath: override, } }