blob: 1b80358425263552c3cb7f45b2e0f3ebebd84d96 [file] [log] [blame]
// Copyright 2023 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 cloudbuild
import (
"bytes"
"context"
"fmt"
"io"
"math"
"net/http"
"net/url"
"time"
cloudbuildpb "cloud.google.com/go/cloudbuild/apiv2/cloudbuildpb"
iampb "cloud.google.com/go/iam/apiv1/iampb"
"cloud.google.com/go/longrunning"
lroauto "cloud.google.com/go/longrunning/autogen"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
gax "github.com/googleapis/gax-go/v2"
"google.golang.org/api/googleapi"
"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"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
var newRepositoryManagerClientHook clientHook
// RepositoryManagerCallOptions contains the retry settings for each method of RepositoryManagerClient.
type RepositoryManagerCallOptions struct {
CreateConnection []gax.CallOption
GetConnection []gax.CallOption
ListConnections []gax.CallOption
UpdateConnection []gax.CallOption
DeleteConnection []gax.CallOption
CreateRepository []gax.CallOption
BatchCreateRepositories []gax.CallOption
GetRepository []gax.CallOption
ListRepositories []gax.CallOption
DeleteRepository []gax.CallOption
FetchReadWriteToken []gax.CallOption
FetchReadToken []gax.CallOption
FetchLinkableRepositories []gax.CallOption
FetchGitRefs []gax.CallOption
GetIamPolicy []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
CancelOperation []gax.CallOption
GetOperation []gax.CallOption
}
func defaultRepositoryManagerGRPCClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("cloudbuild.googleapis.com:443"),
internaloption.WithDefaultMTLSEndpoint("cloudbuild.mtls.googleapis.com:443"),
internaloption.WithDefaultAudience("https://cloudbuild.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
internaloption.EnableJwtWithScope(),
option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(math.MaxInt32))),
}
}
func defaultRepositoryManagerCallOptions() *RepositoryManagerCallOptions {
return &RepositoryManagerCallOptions{
CreateConnection: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
GetConnection: []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,
})
}),
},
ListConnections: []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,
})
}),
},
UpdateConnection: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
DeleteConnection: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
CreateRepository: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
BatchCreateRepositories: []gax.CallOption{},
GetRepository: []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,
})
}),
},
ListRepositories: []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,
})
}),
},
DeleteRepository: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
FetchReadWriteToken: []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,
})
}),
},
FetchReadToken: []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,
})
}),
},
FetchLinkableRepositories: []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,
})
}),
},
FetchGitRefs: []gax.CallOption{},
GetIamPolicy: []gax.CallOption{},
SetIamPolicy: []gax.CallOption{},
TestIamPermissions: []gax.CallOption{},
CancelOperation: []gax.CallOption{},
GetOperation: []gax.CallOption{},
}
}
func defaultRepositoryManagerRESTCallOptions() *RepositoryManagerCallOptions {
return &RepositoryManagerCallOptions{
CreateConnection: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
GetConnection: []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)
}),
},
ListConnections: []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)
}),
},
UpdateConnection: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
DeleteConnection: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
CreateRepository: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
BatchCreateRepositories: []gax.CallOption{},
GetRepository: []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)
}),
},
ListRepositories: []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)
}),
},
DeleteRepository: []gax.CallOption{
gax.WithTimeout(60000 * time.Millisecond),
},
FetchReadWriteToken: []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)
}),
},
FetchReadToken: []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)
}),
},
FetchLinkableRepositories: []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)
}),
},
FetchGitRefs: []gax.CallOption{},
GetIamPolicy: []gax.CallOption{},
SetIamPolicy: []gax.CallOption{},
TestIamPermissions: []gax.CallOption{},
CancelOperation: []gax.CallOption{},
GetOperation: []gax.CallOption{},
}
}
// internalRepositoryManagerClient is an interface that defines the methods available from Cloud Build API.
type internalRepositoryManagerClient interface {
Close() error
setGoogleClientInfo(...string)
Connection() *grpc.ClientConn
CreateConnection(context.Context, *cloudbuildpb.CreateConnectionRequest, ...gax.CallOption) (*CreateConnectionOperation, error)
CreateConnectionOperation(name string) *CreateConnectionOperation
GetConnection(context.Context, *cloudbuildpb.GetConnectionRequest, ...gax.CallOption) (*cloudbuildpb.Connection, error)
ListConnections(context.Context, *cloudbuildpb.ListConnectionsRequest, ...gax.CallOption) *ConnectionIterator
UpdateConnection(context.Context, *cloudbuildpb.UpdateConnectionRequest, ...gax.CallOption) (*UpdateConnectionOperation, error)
UpdateConnectionOperation(name string) *UpdateConnectionOperation
DeleteConnection(context.Context, *cloudbuildpb.DeleteConnectionRequest, ...gax.CallOption) (*DeleteConnectionOperation, error)
DeleteConnectionOperation(name string) *DeleteConnectionOperation
CreateRepository(context.Context, *cloudbuildpb.CreateRepositoryRequest, ...gax.CallOption) (*CreateRepositoryOperation, error)
CreateRepositoryOperation(name string) *CreateRepositoryOperation
BatchCreateRepositories(context.Context, *cloudbuildpb.BatchCreateRepositoriesRequest, ...gax.CallOption) (*BatchCreateRepositoriesOperation, error)
BatchCreateRepositoriesOperation(name string) *BatchCreateRepositoriesOperation
GetRepository(context.Context, *cloudbuildpb.GetRepositoryRequest, ...gax.CallOption) (*cloudbuildpb.Repository, error)
ListRepositories(context.Context, *cloudbuildpb.ListRepositoriesRequest, ...gax.CallOption) *RepositoryIterator
DeleteRepository(context.Context, *cloudbuildpb.DeleteRepositoryRequest, ...gax.CallOption) (*DeleteRepositoryOperation, error)
DeleteRepositoryOperation(name string) *DeleteRepositoryOperation
FetchReadWriteToken(context.Context, *cloudbuildpb.FetchReadWriteTokenRequest, ...gax.CallOption) (*cloudbuildpb.FetchReadWriteTokenResponse, error)
FetchReadToken(context.Context, *cloudbuildpb.FetchReadTokenRequest, ...gax.CallOption) (*cloudbuildpb.FetchReadTokenResponse, error)
FetchLinkableRepositories(context.Context, *cloudbuildpb.FetchLinkableRepositoriesRequest, ...gax.CallOption) *RepositoryIterator
FetchGitRefs(context.Context, *cloudbuildpb.FetchGitRefsRequest, ...gax.CallOption) (*cloudbuildpb.FetchGitRefsResponse, error)
GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
}
// RepositoryManagerClient is a client for interacting with Cloud Build API.
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
//
// Manages connections to source code repositories.
type RepositoryManagerClient struct {
// The internal transport-dependent client.
internalClient internalRepositoryManagerClient
// The call options for this service.
CallOptions *RepositoryManagerCallOptions
// 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 *RepositoryManagerClient) 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 *RepositoryManagerClient) 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 *RepositoryManagerClient) Connection() *grpc.ClientConn {
return c.internalClient.Connection()
}
// CreateConnection creates a Connection.
func (c *RepositoryManagerClient) CreateConnection(ctx context.Context, req *cloudbuildpb.CreateConnectionRequest, opts ...gax.CallOption) (*CreateConnectionOperation, error) {
return c.internalClient.CreateConnection(ctx, req, opts...)
}
// CreateConnectionOperation returns a new CreateConnectionOperation from a given name.
// The name must be that of a previously created CreateConnectionOperation, possibly from a different process.
func (c *RepositoryManagerClient) CreateConnectionOperation(name string) *CreateConnectionOperation {
return c.internalClient.CreateConnectionOperation(name)
}
// GetConnection gets details of a single connection.
func (c *RepositoryManagerClient) GetConnection(ctx context.Context, req *cloudbuildpb.GetConnectionRequest, opts ...gax.CallOption) (*cloudbuildpb.Connection, error) {
return c.internalClient.GetConnection(ctx, req, opts...)
}
// ListConnections lists Connections in a given project and location.
func (c *RepositoryManagerClient) ListConnections(ctx context.Context, req *cloudbuildpb.ListConnectionsRequest, opts ...gax.CallOption) *ConnectionIterator {
return c.internalClient.ListConnections(ctx, req, opts...)
}
// UpdateConnection updates a single connection.
func (c *RepositoryManagerClient) UpdateConnection(ctx context.Context, req *cloudbuildpb.UpdateConnectionRequest, opts ...gax.CallOption) (*UpdateConnectionOperation, error) {
return c.internalClient.UpdateConnection(ctx, req, opts...)
}
// UpdateConnectionOperation returns a new UpdateConnectionOperation from a given name.
// The name must be that of a previously created UpdateConnectionOperation, possibly from a different process.
func (c *RepositoryManagerClient) UpdateConnectionOperation(name string) *UpdateConnectionOperation {
return c.internalClient.UpdateConnectionOperation(name)
}
// DeleteConnection deletes a single connection.
func (c *RepositoryManagerClient) DeleteConnection(ctx context.Context, req *cloudbuildpb.DeleteConnectionRequest, opts ...gax.CallOption) (*DeleteConnectionOperation, error) {
return c.internalClient.DeleteConnection(ctx, req, opts...)
}
// DeleteConnectionOperation returns a new DeleteConnectionOperation from a given name.
// The name must be that of a previously created DeleteConnectionOperation, possibly from a different process.
func (c *RepositoryManagerClient) DeleteConnectionOperation(name string) *DeleteConnectionOperation {
return c.internalClient.DeleteConnectionOperation(name)
}
// CreateRepository creates a Repository.
func (c *RepositoryManagerClient) CreateRepository(ctx context.Context, req *cloudbuildpb.CreateRepositoryRequest, opts ...gax.CallOption) (*CreateRepositoryOperation, error) {
return c.internalClient.CreateRepository(ctx, req, opts...)
}
// CreateRepositoryOperation returns a new CreateRepositoryOperation from a given name.
// The name must be that of a previously created CreateRepositoryOperation, possibly from a different process.
func (c *RepositoryManagerClient) CreateRepositoryOperation(name string) *CreateRepositoryOperation {
return c.internalClient.CreateRepositoryOperation(name)
}
// BatchCreateRepositories creates multiple repositories inside a connection.
func (c *RepositoryManagerClient) BatchCreateRepositories(ctx context.Context, req *cloudbuildpb.BatchCreateRepositoriesRequest, opts ...gax.CallOption) (*BatchCreateRepositoriesOperation, error) {
return c.internalClient.BatchCreateRepositories(ctx, req, opts...)
}
// BatchCreateRepositoriesOperation returns a new BatchCreateRepositoriesOperation from a given name.
// The name must be that of a previously created BatchCreateRepositoriesOperation, possibly from a different process.
func (c *RepositoryManagerClient) BatchCreateRepositoriesOperation(name string) *BatchCreateRepositoriesOperation {
return c.internalClient.BatchCreateRepositoriesOperation(name)
}
// GetRepository gets details of a single repository.
func (c *RepositoryManagerClient) GetRepository(ctx context.Context, req *cloudbuildpb.GetRepositoryRequest, opts ...gax.CallOption) (*cloudbuildpb.Repository, error) {
return c.internalClient.GetRepository(ctx, req, opts...)
}
// ListRepositories lists Repositories in a given connection.
func (c *RepositoryManagerClient) ListRepositories(ctx context.Context, req *cloudbuildpb.ListRepositoriesRequest, opts ...gax.CallOption) *RepositoryIterator {
return c.internalClient.ListRepositories(ctx, req, opts...)
}
// DeleteRepository deletes a single repository.
func (c *RepositoryManagerClient) DeleteRepository(ctx context.Context, req *cloudbuildpb.DeleteRepositoryRequest, opts ...gax.CallOption) (*DeleteRepositoryOperation, error) {
return c.internalClient.DeleteRepository(ctx, req, opts...)
}
// DeleteRepositoryOperation returns a new DeleteRepositoryOperation from a given name.
// The name must be that of a previously created DeleteRepositoryOperation, possibly from a different process.
func (c *RepositoryManagerClient) DeleteRepositoryOperation(name string) *DeleteRepositoryOperation {
return c.internalClient.DeleteRepositoryOperation(name)
}
// FetchReadWriteToken fetches read/write token of a given repository.
func (c *RepositoryManagerClient) FetchReadWriteToken(ctx context.Context, req *cloudbuildpb.FetchReadWriteTokenRequest, opts ...gax.CallOption) (*cloudbuildpb.FetchReadWriteTokenResponse, error) {
return c.internalClient.FetchReadWriteToken(ctx, req, opts...)
}
// FetchReadToken fetches read token of a given repository.
func (c *RepositoryManagerClient) FetchReadToken(ctx context.Context, req *cloudbuildpb.FetchReadTokenRequest, opts ...gax.CallOption) (*cloudbuildpb.FetchReadTokenResponse, error) {
return c.internalClient.FetchReadToken(ctx, req, opts...)
}
// FetchLinkableRepositories fetchLinkableRepositories get repositories from SCM that are
// accessible and could be added to the connection.
func (c *RepositoryManagerClient) FetchLinkableRepositories(ctx context.Context, req *cloudbuildpb.FetchLinkableRepositoriesRequest, opts ...gax.CallOption) *RepositoryIterator {
return c.internalClient.FetchLinkableRepositories(ctx, req, opts...)
}
// FetchGitRefs fetch the list of branches or tags for a given repository.
func (c *RepositoryManagerClient) FetchGitRefs(ctx context.Context, req *cloudbuildpb.FetchGitRefsRequest, opts ...gax.CallOption) (*cloudbuildpb.FetchGitRefsResponse, error) {
return c.internalClient.FetchGitRefs(ctx, req, opts...)
}
// GetIamPolicy gets the access control policy for a resource. Returns an empty policy
// if the resource exists and does not have a policy set.
func (c *RepositoryManagerClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
return c.internalClient.GetIamPolicy(ctx, req, opts...)
}
// SetIamPolicy sets the access control policy on the specified resource. Replaces
// any existing policy.
//
// Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
// errors.
func (c *RepositoryManagerClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
return c.internalClient.SetIamPolicy(ctx, req, opts...)
}
// TestIamPermissions returns permissions that a caller has on the specified resource. If the
// resource does not exist, this will return an empty set of
// permissions, not a NOT_FOUND error.
//
// Note: This operation is designed to be used for building
// permission-aware UIs and command-line tools, not for authorization
// checking. This operation may “fail open” without warning.
func (c *RepositoryManagerClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
return c.internalClient.TestIamPermissions(ctx, req, opts...)
}
// CancelOperation is a utility method from google.longrunning.Operations.
func (c *RepositoryManagerClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
return c.internalClient.CancelOperation(ctx, req, opts...)
}
// GetOperation is a utility method from google.longrunning.Operations.
func (c *RepositoryManagerClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
return c.internalClient.GetOperation(ctx, req, opts...)
}
// repositoryManagerGRPCClient is a client for interacting with Cloud Build API over gRPC transport.
//
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type repositoryManagerGRPCClient struct {
// Connection pool of gRPC connections to the service.
connPool gtransport.ConnPool
// Points back to the CallOptions field of the containing RepositoryManagerClient
CallOptions **RepositoryManagerCallOptions
// The gRPC API client.
repositoryManagerClient cloudbuildpb.RepositoryManagerClient
// 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
iamPolicyClient iampb.IAMPolicyClient
// The x-goog-* metadata to be sent with each request.
xGoogHeaders []string
}
// NewRepositoryManagerClient creates a new repository manager client based on gRPC.
// The returned client must be Closed when it is done being used to clean up its underlying connections.
//
// Manages connections to source code repositories.
func NewRepositoryManagerClient(ctx context.Context, opts ...option.ClientOption) (*RepositoryManagerClient, error) {
clientOpts := defaultRepositoryManagerGRPCClientOptions()
if newRepositoryManagerClientHook != nil {
hookOpts, err := newRepositoryManagerClientHook(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 := RepositoryManagerClient{CallOptions: defaultRepositoryManagerCallOptions()}
c := &repositoryManagerGRPCClient{
connPool: connPool,
repositoryManagerClient: cloudbuildpb.NewRepositoryManagerClient(connPool),
CallOptions: &client.CallOptions,
operationsClient: longrunningpb.NewOperationsClient(connPool),
iamPolicyClient: iampb.NewIAMPolicyClient(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 *repositoryManagerGRPCClient) 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 *repositoryManagerGRPCClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
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 *repositoryManagerGRPCClient) Close() error {
return c.connPool.Close()
}
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type repositoryManagerRESTClient 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 RepositoryManagerClient
CallOptions **RepositoryManagerCallOptions
}
// NewRepositoryManagerRESTClient creates a new repository manager rest client.
//
// Manages connections to source code repositories.
func NewRepositoryManagerRESTClient(ctx context.Context, opts ...option.ClientOption) (*RepositoryManagerClient, error) {
clientOpts := append(defaultRepositoryManagerRESTClientOptions(), opts...)
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
if err != nil {
return nil, err
}
callOpts := defaultRepositoryManagerRESTCallOptions()
c := &repositoryManagerRESTClient{
endpoint: endpoint,
httpClient: httpClient,
CallOptions: &callOpts,
}
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 &RepositoryManagerClient{internalClient: c, CallOptions: callOpts}, nil
}
func defaultRepositoryManagerRESTClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("https://cloudbuild.googleapis.com"),
internaloption.WithDefaultMTLSEndpoint("https://cloudbuild.mtls.googleapis.com"),
internaloption.WithDefaultAudience("https://cloudbuild.googleapis.com/"),
internaloption.WithDefaultScopes(DefaultAuthScopes()...),
}
}
// 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 *repositoryManagerRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
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 *repositoryManagerRESTClient) 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 *repositoryManagerRESTClient) Connection() *grpc.ClientConn {
return nil
}
func (c *repositoryManagerGRPCClient) CreateConnection(ctx context.Context, req *cloudbuildpb.CreateConnectionRequest, opts ...gax.CallOption) (*CreateConnectionOperation, 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).CreateConnection[0:len((*c.CallOptions).CreateConnection):len((*c.CallOptions).CreateConnection)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.repositoryManagerClient.CreateConnection(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &CreateConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *repositoryManagerGRPCClient) GetConnection(ctx context.Context, req *cloudbuildpb.GetConnectionRequest, opts ...gax.CallOption) (*cloudbuildpb.Connection, 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).GetConnection[0:len((*c.CallOptions).GetConnection):len((*c.CallOptions).GetConnection)], opts...)
var resp *cloudbuildpb.Connection
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.repositoryManagerClient.GetConnection(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *repositoryManagerGRPCClient) ListConnections(ctx context.Context, req *cloudbuildpb.ListConnectionsRequest, opts ...gax.CallOption) *ConnectionIterator {
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).ListConnections[0:len((*c.CallOptions).ListConnections):len((*c.CallOptions).ListConnections)], opts...)
it := &ConnectionIterator{}
req = proto.Clone(req).(*cloudbuildpb.ListConnectionsRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.Connection, string, error) {
resp := &cloudbuildpb.ListConnectionsResponse{}
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 = c.repositoryManagerClient.ListConnections(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, "", err
}
it.Response = resp
return resp.GetConnections(), 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 *repositoryManagerGRPCClient) UpdateConnection(ctx context.Context, req *cloudbuildpb.UpdateConnectionRequest, opts ...gax.CallOption) (*UpdateConnectionOperation, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "connection.name", url.QueryEscape(req.GetConnection().GetName()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).UpdateConnection[0:len((*c.CallOptions).UpdateConnection):len((*c.CallOptions).UpdateConnection)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.repositoryManagerClient.UpdateConnection(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &UpdateConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *repositoryManagerGRPCClient) DeleteConnection(ctx context.Context, req *cloudbuildpb.DeleteConnectionRequest, opts ...gax.CallOption) (*DeleteConnectionOperation, 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).DeleteConnection[0:len((*c.CallOptions).DeleteConnection):len((*c.CallOptions).DeleteConnection)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.repositoryManagerClient.DeleteConnection(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &DeleteConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *repositoryManagerGRPCClient) CreateRepository(ctx context.Context, req *cloudbuildpb.CreateRepositoryRequest, opts ...gax.CallOption) (*CreateRepositoryOperation, 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).CreateRepository[0:len((*c.CallOptions).CreateRepository):len((*c.CallOptions).CreateRepository)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.repositoryManagerClient.CreateRepository(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &CreateRepositoryOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *repositoryManagerGRPCClient) BatchCreateRepositories(ctx context.Context, req *cloudbuildpb.BatchCreateRepositoriesRequest, opts ...gax.CallOption) (*BatchCreateRepositoriesOperation, 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).BatchCreateRepositories[0:len((*c.CallOptions).BatchCreateRepositories):len((*c.CallOptions).BatchCreateRepositories)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.repositoryManagerClient.BatchCreateRepositories(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &BatchCreateRepositoriesOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *repositoryManagerGRPCClient) GetRepository(ctx context.Context, req *cloudbuildpb.GetRepositoryRequest, opts ...gax.CallOption) (*cloudbuildpb.Repository, 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).GetRepository[0:len((*c.CallOptions).GetRepository):len((*c.CallOptions).GetRepository)], opts...)
var resp *cloudbuildpb.Repository
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.repositoryManagerClient.GetRepository(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *repositoryManagerGRPCClient) ListRepositories(ctx context.Context, req *cloudbuildpb.ListRepositoriesRequest, opts ...gax.CallOption) *RepositoryIterator {
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).ListRepositories[0:len((*c.CallOptions).ListRepositories):len((*c.CallOptions).ListRepositories)], opts...)
it := &RepositoryIterator{}
req = proto.Clone(req).(*cloudbuildpb.ListRepositoriesRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.Repository, string, error) {
resp := &cloudbuildpb.ListRepositoriesResponse{}
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 = c.repositoryManagerClient.ListRepositories(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, "", err
}
it.Response = resp
return resp.GetRepositories(), 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 *repositoryManagerGRPCClient) DeleteRepository(ctx context.Context, req *cloudbuildpb.DeleteRepositoryRequest, opts ...gax.CallOption) (*DeleteRepositoryOperation, 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).DeleteRepository[0:len((*c.CallOptions).DeleteRepository):len((*c.CallOptions).DeleteRepository)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.repositoryManagerClient.DeleteRepository(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return &DeleteRepositoryOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
}, nil
}
func (c *repositoryManagerGRPCClient) FetchReadWriteToken(ctx context.Context, req *cloudbuildpb.FetchReadWriteTokenRequest, opts ...gax.CallOption) (*cloudbuildpb.FetchReadWriteTokenResponse, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "repository", url.QueryEscape(req.GetRepository()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).FetchReadWriteToken[0:len((*c.CallOptions).FetchReadWriteToken):len((*c.CallOptions).FetchReadWriteToken)], opts...)
var resp *cloudbuildpb.FetchReadWriteTokenResponse
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.repositoryManagerClient.FetchReadWriteToken(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *repositoryManagerGRPCClient) FetchReadToken(ctx context.Context, req *cloudbuildpb.FetchReadTokenRequest, opts ...gax.CallOption) (*cloudbuildpb.FetchReadTokenResponse, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "repository", url.QueryEscape(req.GetRepository()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).FetchReadToken[0:len((*c.CallOptions).FetchReadToken):len((*c.CallOptions).FetchReadToken)], opts...)
var resp *cloudbuildpb.FetchReadTokenResponse
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.repositoryManagerClient.FetchReadToken(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *repositoryManagerGRPCClient) FetchLinkableRepositories(ctx context.Context, req *cloudbuildpb.FetchLinkableRepositoriesRequest, opts ...gax.CallOption) *RepositoryIterator {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "connection", url.QueryEscape(req.GetConnection()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).FetchLinkableRepositories[0:len((*c.CallOptions).FetchLinkableRepositories):len((*c.CallOptions).FetchLinkableRepositories)], opts...)
it := &RepositoryIterator{}
req = proto.Clone(req).(*cloudbuildpb.FetchLinkableRepositoriesRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.Repository, string, error) {
resp := &cloudbuildpb.FetchLinkableRepositoriesResponse{}
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 = c.repositoryManagerClient.FetchLinkableRepositories(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, "", err
}
it.Response = resp
return resp.GetRepositories(), 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 *repositoryManagerGRPCClient) FetchGitRefs(ctx context.Context, req *cloudbuildpb.FetchGitRefsRequest, opts ...gax.CallOption) (*cloudbuildpb.FetchGitRefsResponse, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "repository", url.QueryEscape(req.GetRepository()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).FetchGitRefs[0:len((*c.CallOptions).FetchGitRefs):len((*c.CallOptions).FetchGitRefs)], opts...)
var resp *cloudbuildpb.FetchGitRefsResponse
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.repositoryManagerClient.FetchGitRefs(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *repositoryManagerGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
var resp *iampb.Policy
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.iamPolicyClient.GetIamPolicy(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *repositoryManagerGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
var resp *iampb.Policy
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.iamPolicyClient.SetIamPolicy(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *repositoryManagerGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
var resp *iampb.TestIamPermissionsResponse
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.iamPolicyClient.TestIamPermissions(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
func (c *repositoryManagerGRPCClient) 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 = c.operationsClient.CancelOperation(ctx, req, settings.GRPC...)
return err
}, opts...)
return err
}
func (c *repositoryManagerGRPCClient) 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 = c.operationsClient.GetOperation(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
// CreateConnection creates a Connection.
func (c *repositoryManagerRESTClient) CreateConnection(ctx context.Context, req *cloudbuildpb.CreateConnectionRequest, opts ...gax.CallOption) (*CreateConnectionOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetConnection()
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("/v2/%v/connections", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
params.Add("connectionId", fmt.Sprintf("%v", req.GetConnectionId()))
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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("/v2/%s", resp.GetName())
return &CreateConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// GetConnection gets details of a single connection.
func (c *repositoryManagerRESTClient) GetConnection(ctx context.Context, req *cloudbuildpb.GetConnectionRequest, opts ...gax.CallOption) (*cloudbuildpb.Connection, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v2/%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).GetConnection[0:len((*c.CallOptions).GetConnection):len((*c.CallOptions).GetConnection)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &cloudbuildpb.Connection{}
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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
}
// ListConnections lists Connections in a given project and location.
func (c *repositoryManagerRESTClient) ListConnections(ctx context.Context, req *cloudbuildpb.ListConnectionsRequest, opts ...gax.CallOption) *ConnectionIterator {
it := &ConnectionIterator{}
req = proto.Clone(req).(*cloudbuildpb.ListConnectionsRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.Connection, string, error) {
resp := &cloudbuildpb.ListConnectionsResponse{}
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("/v2/%v/connections", 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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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.GetConnections(), 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
}
// UpdateConnection updates a single connection.
func (c *repositoryManagerRESTClient) UpdateConnection(ctx context.Context, req *cloudbuildpb.UpdateConnectionRequest, opts ...gax.CallOption) (*UpdateConnectionOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetConnection()
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("/v2/%v", req.GetConnection().GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetAllowMissing() {
params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing()))
}
if req.GetEtag() != "" {
params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
}
if req.GetUpdateMask() != nil {
updateMask, err := protojson.Marshal(req.GetUpdateMask())
if err != nil {
return nil, err
}
params.Add("updateMask", string(updateMask[1:len(updateMask)-1]))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "connection.name", url.QueryEscape(req.GetConnection().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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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("/v2/%s", resp.GetName())
return &UpdateConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// DeleteConnection deletes a single connection.
func (c *repositoryManagerRESTClient) DeleteConnection(ctx context.Context, req *cloudbuildpb.DeleteConnectionRequest, opts ...gax.CallOption) (*DeleteConnectionOperation, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v2/%v", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetEtag() != "" {
params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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("/v2/%s", resp.GetName())
return &DeleteConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// CreateRepository creates a Repository.
func (c *repositoryManagerRESTClient) CreateRepository(ctx context.Context, req *cloudbuildpb.CreateRepositoryRequest, opts ...gax.CallOption) (*CreateRepositoryOperation, error) {
m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
body := req.GetRepository()
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("/v2/%v/repositories", req.GetParent())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
params.Add("repositoryId", fmt.Sprintf("%v", req.GetRepositoryId()))
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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("/v2/%s", resp.GetName())
return &CreateRepositoryOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// BatchCreateRepositories creates multiple repositories inside a connection.
func (c *repositoryManagerRESTClient) BatchCreateRepositories(ctx context.Context, req *cloudbuildpb.BatchCreateRepositoriesRequest, opts ...gax.CallOption) (*BatchCreateRepositoriesOperation, 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("/v2/%v/repositories:batchCreate", req.GetParent())
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", "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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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("/v2/%s", resp.GetName())
return &BatchCreateRepositoriesOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// GetRepository gets details of a single repository.
func (c *repositoryManagerRESTClient) GetRepository(ctx context.Context, req *cloudbuildpb.GetRepositoryRequest, opts ...gax.CallOption) (*cloudbuildpb.Repository, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v2/%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).GetRepository[0:len((*c.CallOptions).GetRepository):len((*c.CallOptions).GetRepository)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &cloudbuildpb.Repository{}
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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
}
// ListRepositories lists Repositories in a given connection.
func (c *repositoryManagerRESTClient) ListRepositories(ctx context.Context, req *cloudbuildpb.ListRepositoriesRequest, opts ...gax.CallOption) *RepositoryIterator {
it := &RepositoryIterator{}
req = proto.Clone(req).(*cloudbuildpb.ListRepositoriesRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.Repository, string, error) {
resp := &cloudbuildpb.ListRepositoriesResponse{}
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("/v2/%v/repositories", 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.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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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.GetRepositories(), 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
}
// DeleteRepository deletes a single repository.
func (c *repositoryManagerRESTClient) DeleteRepository(ctx context.Context, req *cloudbuildpb.DeleteRepositoryRequest, opts ...gax.CallOption) (*DeleteRepositoryOperation, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v2/%v", req.GetName())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetEtag() != "" {
params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
}
if req.GetValidateOnly() {
params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly()))
}
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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("/v2/%s", resp.GetName())
return &DeleteRepositoryOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, resp),
pollPath: override,
}, nil
}
// FetchReadWriteToken fetches read/write token of a given repository.
func (c *repositoryManagerRESTClient) FetchReadWriteToken(ctx context.Context, req *cloudbuildpb.FetchReadWriteTokenRequest, opts ...gax.CallOption) (*cloudbuildpb.FetchReadWriteTokenResponse, 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("/v2/%v:accessReadWriteToken", req.GetRepository())
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", "repository", url.QueryEscape(req.GetRepository()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).FetchReadWriteToken[0:len((*c.CallOptions).FetchReadWriteToken):len((*c.CallOptions).FetchReadWriteToken)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &cloudbuildpb.FetchReadWriteTokenResponse{}
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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
}
// FetchReadToken fetches read token of a given repository.
func (c *repositoryManagerRESTClient) FetchReadToken(ctx context.Context, req *cloudbuildpb.FetchReadTokenRequest, opts ...gax.CallOption) (*cloudbuildpb.FetchReadTokenResponse, 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("/v2/%v:accessReadToken", req.GetRepository())
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", "repository", url.QueryEscape(req.GetRepository()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).FetchReadToken[0:len((*c.CallOptions).FetchReadToken):len((*c.CallOptions).FetchReadToken)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &cloudbuildpb.FetchReadTokenResponse{}
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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
}
// FetchLinkableRepositories fetchLinkableRepositories get repositories from SCM that are
// accessible and could be added to the connection.
func (c *repositoryManagerRESTClient) FetchLinkableRepositories(ctx context.Context, req *cloudbuildpb.FetchLinkableRepositoriesRequest, opts ...gax.CallOption) *RepositoryIterator {
it := &RepositoryIterator{}
req = proto.Clone(req).(*cloudbuildpb.FetchLinkableRepositoriesRequest)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudbuildpb.Repository, string, error) {
resp := &cloudbuildpb.FetchLinkableRepositoriesResponse{}
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("/v2/%v:fetchLinkableRepositories", req.GetConnection())
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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.GetRepositories(), 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
}
// FetchGitRefs fetch the list of branches or tags for a given repository.
func (c *repositoryManagerRESTClient) FetchGitRefs(ctx context.Context, req *cloudbuildpb.FetchGitRefsRequest, opts ...gax.CallOption) (*cloudbuildpb.FetchGitRefsResponse, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v2/%v:fetchGitRefs", req.GetRepository())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetRefType() != 0 {
params.Add("refType", fmt.Sprintf("%v", req.GetRefType()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "repository", url.QueryEscape(req.GetRepository()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).FetchGitRefs[0:len((*c.CallOptions).FetchGitRefs):len((*c.CallOptions).FetchGitRefs)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &cloudbuildpb.FetchGitRefsResponse{}
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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
}
// GetIamPolicy gets the access control policy for a resource. Returns an empty policy
// if the resource exists and does not have a policy set.
func (c *repositoryManagerRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
baseUrl, err := url.Parse(c.endpoint)
if err != nil {
return nil, err
}
baseUrl.Path += fmt.Sprintf("/v2/%v:getIamPolicy", req.GetResource())
params := url.Values{}
params.Add("$alt", "json;enum-encoding=int")
if req.GetOptions().GetRequestedPolicyVersion() != 0 {
params.Add("options.requestedPolicyVersion", fmt.Sprintf("%v", req.GetOptions().GetRequestedPolicyVersion()))
}
baseUrl.RawQuery = params.Encode()
// Build HTTP headers from client and context metadata.
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &iampb.Policy{}
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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
}
// SetIamPolicy sets the access control policy on the specified resource. Replaces
// any existing policy.
//
// Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
// errors.
func (c *repositoryManagerRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, 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("/v2/%v:setIamPolicy", req.GetResource())
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", "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &iampb.Policy{}
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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
}
// TestIamPermissions returns permissions that a caller has on the specified resource. If the
// resource does not exist, this will return an empty set of
// permissions, not a NOT_FOUND error.
//
// Note: This operation is designed to be used for building
// permission-aware UIs and command-line tools, not for authorization
// checking. This operation may “fail open” without warning.
func (c *repositoryManagerRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, 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("/v2/%v:testIamPermissions", req.GetResource())
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", "resource", url.QueryEscape(req.GetResource()))}
hds = append(c.xGoogHeaders, hds...)
hds = append(hds, "Content-Type", "application/json")
headers := gax.BuildHeaders(ctx, hds...)
opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
resp := &iampb.TestIamPermissionsResponse{}
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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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
}
// CancelOperation is a utility method from google.longrunning.Operations.
func (c *repositoryManagerRESTClient) 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("/v2/%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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
// Returns nil if there is no error, otherwise wraps
// the response code and body into a non-nil error
return googleapi.CheckResponse(httpRsp)
}, opts...)
}
// GetOperation is a utility method from google.longrunning.Operations.
func (c *repositoryManagerRESTClient) 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("/v2/%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
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return err
}
defer httpRsp.Body.Close()
if err = googleapi.CheckResponse(httpRsp); err != nil {
return err
}
buf, err := io.ReadAll(httpRsp.Body)
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
}
// BatchCreateRepositoriesOperation manages a long-running operation from BatchCreateRepositories.
type BatchCreateRepositoriesOperation struct {
lro *longrunning.Operation
pollPath string
}
// BatchCreateRepositoriesOperation returns a new BatchCreateRepositoriesOperation from a given name.
// The name must be that of a previously created BatchCreateRepositoriesOperation, possibly from a different process.
func (c *repositoryManagerGRPCClient) BatchCreateRepositoriesOperation(name string) *BatchCreateRepositoriesOperation {
return &BatchCreateRepositoriesOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// BatchCreateRepositoriesOperation returns a new BatchCreateRepositoriesOperation from a given name.
// The name must be that of a previously created BatchCreateRepositoriesOperation, possibly from a different process.
func (c *repositoryManagerRESTClient) BatchCreateRepositoriesOperation(name string) *BatchCreateRepositoriesOperation {
override := fmt.Sprintf("/v2/%s", name)
return &BatchCreateRepositoriesOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *BatchCreateRepositoriesOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*cloudbuildpb.BatchCreateRepositoriesResponse, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp cloudbuildpb.BatchCreateRepositoriesResponse
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// Poll fetches the latest state of the long-running operation.
//
// Poll also fetches the latest metadata, which can be retrieved by Metadata.
//
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
// the operation has completed with failure, the error is returned and op.Done will return true.
// If Poll succeeds and the operation has completed successfully,
// op.Done will return true, and the response of the operation is returned.
// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (op *BatchCreateRepositoriesOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*cloudbuildpb.BatchCreateRepositoriesResponse, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp cloudbuildpb.BatchCreateRepositoriesResponse
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// Metadata returns metadata associated with the long-running operation.
// Metadata itself does not contact the server, but Poll does.
// To get the latest metadata, call this method after a successful call to Poll.
// If the metadata is not available, the returned metadata and error are both nil.
func (op *BatchCreateRepositoriesOperation) Metadata() (*cloudbuildpb.OperationMetadata, error) {
var meta cloudbuildpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *BatchCreateRepositoriesOperation) Done() bool {
return op.lro.Done()
}
// Name returns the name of the long-running operation.
// The name is assigned by the server and is unique within the service from which the operation is created.
func (op *BatchCreateRepositoriesOperation) Name() string {
return op.lro.Name()
}
// CreateConnectionOperation manages a long-running operation from CreateConnection.
type CreateConnectionOperation struct {
lro *longrunning.Operation
pollPath string
}
// CreateConnectionOperation returns a new CreateConnectionOperation from a given name.
// The name must be that of a previously created CreateConnectionOperation, possibly from a different process.
func (c *repositoryManagerGRPCClient) CreateConnectionOperation(name string) *CreateConnectionOperation {
return &CreateConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// CreateConnectionOperation returns a new CreateConnectionOperation from a given name.
// The name must be that of a previously created CreateConnectionOperation, possibly from a different process.
func (c *repositoryManagerRESTClient) CreateConnectionOperation(name string) *CreateConnectionOperation {
override := fmt.Sprintf("/v2/%s", name)
return &CreateConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *CreateConnectionOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*cloudbuildpb.Connection, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp cloudbuildpb.Connection
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// Poll fetches the latest state of the long-running operation.
//
// Poll also fetches the latest metadata, which can be retrieved by Metadata.
//
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
// the operation has completed with failure, the error is returned and op.Done will return true.
// If Poll succeeds and the operation has completed successfully,
// op.Done will return true, and the response of the operation is returned.
// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (op *CreateConnectionOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*cloudbuildpb.Connection, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp cloudbuildpb.Connection
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// Metadata returns metadata associated with the long-running operation.
// Metadata itself does not contact the server, but Poll does.
// To get the latest metadata, call this method after a successful call to Poll.
// If the metadata is not available, the returned metadata and error are both nil.
func (op *CreateConnectionOperation) Metadata() (*cloudbuildpb.OperationMetadata, error) {
var meta cloudbuildpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *CreateConnectionOperation) Done() bool {
return op.lro.Done()
}
// Name returns the name of the long-running operation.
// The name is assigned by the server and is unique within the service from which the operation is created.
func (op *CreateConnectionOperation) Name() string {
return op.lro.Name()
}
// CreateRepositoryOperation manages a long-running operation from CreateRepository.
type CreateRepositoryOperation struct {
lro *longrunning.Operation
pollPath string
}
// CreateRepositoryOperation returns a new CreateRepositoryOperation from a given name.
// The name must be that of a previously created CreateRepositoryOperation, possibly from a different process.
func (c *repositoryManagerGRPCClient) CreateRepositoryOperation(name string) *CreateRepositoryOperation {
return &CreateRepositoryOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// CreateRepositoryOperation returns a new CreateRepositoryOperation from a given name.
// The name must be that of a previously created CreateRepositoryOperation, possibly from a different process.
func (c *repositoryManagerRESTClient) CreateRepositoryOperation(name string) *CreateRepositoryOperation {
override := fmt.Sprintf("/v2/%s", name)
return &CreateRepositoryOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *CreateRepositoryOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*cloudbuildpb.Repository, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp cloudbuildpb.Repository
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// Poll fetches the latest state of the long-running operation.
//
// Poll also fetches the latest metadata, which can be retrieved by Metadata.
//
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
// the operation has completed with failure, the error is returned and op.Done will return true.
// If Poll succeeds and the operation has completed successfully,
// op.Done will return true, and the response of the operation is returned.
// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (op *CreateRepositoryOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*cloudbuildpb.Repository, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp cloudbuildpb.Repository
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// Metadata returns metadata associated with the long-running operation.
// Metadata itself does not contact the server, but Poll does.
// To get the latest metadata, call this method after a successful call to Poll.
// If the metadata is not available, the returned metadata and error are both nil.
func (op *CreateRepositoryOperation) Metadata() (*cloudbuildpb.OperationMetadata, error) {
var meta cloudbuildpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *CreateRepositoryOperation) Done() bool {
return op.lro.Done()
}
// Name returns the name of the long-running operation.
// The name is assigned by the server and is unique within the service from which the operation is created.
func (op *CreateRepositoryOperation) Name() string {
return op.lro.Name()
}
// DeleteConnectionOperation manages a long-running operation from DeleteConnection.
type DeleteConnectionOperation struct {
lro *longrunning.Operation
pollPath string
}
// DeleteConnectionOperation returns a new DeleteConnectionOperation from a given name.
// The name must be that of a previously created DeleteConnectionOperation, possibly from a different process.
func (c *repositoryManagerGRPCClient) DeleteConnectionOperation(name string) *DeleteConnectionOperation {
return &DeleteConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// DeleteConnectionOperation returns a new DeleteConnectionOperation from a given name.
// The name must be that of a previously created DeleteConnectionOperation, possibly from a different process.
func (c *repositoryManagerRESTClient) DeleteConnectionOperation(name string) *DeleteConnectionOperation {
override := fmt.Sprintf("/v2/%s", name)
return &DeleteConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *DeleteConnectionOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
}
// Poll fetches the latest state of the long-running operation.
//
// Poll also fetches the latest metadata, which can be retrieved by Metadata.
//
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
// the operation has completed with failure, the error is returned and op.Done will return true.
// If Poll succeeds and the operation has completed successfully,
// op.Done will return true, and the response of the operation is returned.
// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (op *DeleteConnectionOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
return op.lro.Poll(ctx, nil, opts...)
}
// Metadata returns metadata associated with the long-running operation.
// Metadata itself does not contact the server, but Poll does.
// To get the latest metadata, call this method after a successful call to Poll.
// If the metadata is not available, the returned metadata and error are both nil.
func (op *DeleteConnectionOperation) Metadata() (*cloudbuildpb.OperationMetadata, error) {
var meta cloudbuildpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *DeleteConnectionOperation) Done() bool {
return op.lro.Done()
}
// Name returns the name of the long-running operation.
// The name is assigned by the server and is unique within the service from which the operation is created.
func (op *DeleteConnectionOperation) Name() string {
return op.lro.Name()
}
// DeleteRepositoryOperation manages a long-running operation from DeleteRepository.
type DeleteRepositoryOperation struct {
lro *longrunning.Operation
pollPath string
}
// DeleteRepositoryOperation returns a new DeleteRepositoryOperation from a given name.
// The name must be that of a previously created DeleteRepositoryOperation, possibly from a different process.
func (c *repositoryManagerGRPCClient) DeleteRepositoryOperation(name string) *DeleteRepositoryOperation {
return &DeleteRepositoryOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// DeleteRepositoryOperation returns a new DeleteRepositoryOperation from a given name.
// The name must be that of a previously created DeleteRepositoryOperation, possibly from a different process.
func (c *repositoryManagerRESTClient) DeleteRepositoryOperation(name string) *DeleteRepositoryOperation {
override := fmt.Sprintf("/v2/%s", name)
return &DeleteRepositoryOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *DeleteRepositoryOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...)
}
// Poll fetches the latest state of the long-running operation.
//
// Poll also fetches the latest metadata, which can be retrieved by Metadata.
//
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
// the operation has completed with failure, the error is returned and op.Done will return true.
// If Poll succeeds and the operation has completed successfully,
// op.Done will return true, and the response of the operation is returned.
// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (op *DeleteRepositoryOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
return op.lro.Poll(ctx, nil, opts...)
}
// Metadata returns metadata associated with the long-running operation.
// Metadata itself does not contact the server, but Poll does.
// To get the latest metadata, call this method after a successful call to Poll.
// If the metadata is not available, the returned metadata and error are both nil.
func (op *DeleteRepositoryOperation) Metadata() (*cloudbuildpb.OperationMetadata, error) {
var meta cloudbuildpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *DeleteRepositoryOperation) Done() bool {
return op.lro.Done()
}
// Name returns the name of the long-running operation.
// The name is assigned by the server and is unique within the service from which the operation is created.
func (op *DeleteRepositoryOperation) Name() string {
return op.lro.Name()
}
// UpdateConnectionOperation manages a long-running operation from UpdateConnection.
type UpdateConnectionOperation struct {
lro *longrunning.Operation
pollPath string
}
// UpdateConnectionOperation returns a new UpdateConnectionOperation from a given name.
// The name must be that of a previously created UpdateConnectionOperation, possibly from a different process.
func (c *repositoryManagerGRPCClient) UpdateConnectionOperation(name string) *UpdateConnectionOperation {
return &UpdateConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
}
}
// UpdateConnectionOperation returns a new UpdateConnectionOperation from a given name.
// The name must be that of a previously created UpdateConnectionOperation, possibly from a different process.
func (c *repositoryManagerRESTClient) UpdateConnectionOperation(name string) *UpdateConnectionOperation {
override := fmt.Sprintf("/v2/%s", name)
return &UpdateConnectionOperation{
lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
pollPath: override,
}
}
// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
//
// See documentation of Poll for error-handling information.
func (op *UpdateConnectionOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*cloudbuildpb.Connection, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp cloudbuildpb.Connection
if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
return nil, err
}
return &resp, nil
}
// Poll fetches the latest state of the long-running operation.
//
// Poll also fetches the latest metadata, which can be retrieved by Metadata.
//
// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
// the operation has completed with failure, the error is returned and op.Done will return true.
// If Poll succeeds and the operation has completed successfully,
// op.Done will return true, and the response of the operation is returned.
// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (op *UpdateConnectionOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*cloudbuildpb.Connection, error) {
opts = append([]gax.CallOption{gax.WithPath(op.pollPath)}, opts...)
var resp cloudbuildpb.Connection
if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
return nil, err
}
if !op.Done() {
return nil, nil
}
return &resp, nil
}
// Metadata returns metadata associated with the long-running operation.
// Metadata itself does not contact the server, but Poll does.
// To get the latest metadata, call this method after a successful call to Poll.
// If the metadata is not available, the returned metadata and error are both nil.
func (op *UpdateConnectionOperation) Metadata() (*cloudbuildpb.OperationMetadata, error) {
var meta cloudbuildpb.OperationMetadata
if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
return nil, nil
} else if err != nil {
return nil, err
}
return &meta, nil
}
// Done reports whether the long-running operation has completed.
func (op *UpdateConnectionOperation) Done() bool {
return op.lro.Done()
}
// Name returns the name of the long-running operation.
// The name is assigned by the server and is unique within the service from which the operation is created.
func (op *UpdateConnectionOperation) Name() string {
return op.lro.Name()
}
// ConnectionIterator manages a stream of *cloudbuildpb.Connection.
type ConnectionIterator struct {
items []*cloudbuildpb.Connection
pageInfo *iterator.PageInfo
nextFunc func() error
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*cloudbuildpb.Connection, nextPageToken string, err error)
}
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func (it *ConnectionIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// Next returns the next result. Its second return value is iterator.Done if there are no more
// results. Once Next returns Done, all subsequent calls will return Done.
func (it *ConnectionIterator) Next() (*cloudbuildpb.Connection, error) {
var item *cloudbuildpb.Connection
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *ConnectionIterator) bufLen() int {
return len(it.items)
}
func (it *ConnectionIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}
// RepositoryIterator manages a stream of *cloudbuildpb.Repository.
type RepositoryIterator struct {
items []*cloudbuildpb.Repository
pageInfo *iterator.PageInfo
nextFunc func() error
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*cloudbuildpb.Repository, nextPageToken string, err error)
}
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func (it *RepositoryIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo
}
// Next returns the next result. Its second return value is iterator.Done if there are no more
// results. Once Next returns Done, all subsequent calls will return Done.
func (it *RepositoryIterator) Next() (*cloudbuildpb.Repository, error) {
var item *cloudbuildpb.Repository
if err := it.nextFunc(); err != nil {
return item, err
}
item = it.items[0]
it.items = it.items[1:]
return item, nil
}
func (it *RepositoryIterator) bufLen() int {
return len(it.items)
}
func (it *RepositoryIterator) takeBuf() interface{} {
b := it.items
it.items = nil
return b
}