Copyright 2020 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 secretmanager

import (
	
	
	
	
	

	
	gax 
	
	
	gtransport 
	secretmanagerpb 
	iampb 
	
	
	
)

var newClientHook clientHook
CallOptions contains the retry settings for each method of Client.
type CallOptions struct {
	ListSecrets          []gax.CallOption
	CreateSecret         []gax.CallOption
	AddSecretVersion     []gax.CallOption
	GetSecret            []gax.CallOption
	UpdateSecret         []gax.CallOption
	DeleteSecret         []gax.CallOption
	ListSecretVersions   []gax.CallOption
	GetSecretVersion     []gax.CallOption
	AccessSecretVersion  []gax.CallOption
	DisableSecretVersion []gax.CallOption
	EnableSecretVersion  []gax.CallOption
	DestroySecretVersion []gax.CallOption
	SetIamPolicy         []gax.CallOption
	GetIamPolicy         []gax.CallOption
	TestIamPermissions   []gax.CallOption
}

func () []option.ClientOption {
	return []option.ClientOption{
		option.WithEndpoint("secretmanager.googleapis.com:443"),
		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
		option.WithScopes(DefaultAuthScopes()...),
		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
	}
}

func () *CallOptions {
	return &CallOptions{
		ListSecrets:        []gax.CallOption{},
		CreateSecret:       []gax.CallOption{},
		AddSecretVersion:   []gax.CallOption{},
		GetSecret:          []gax.CallOption{},
		UpdateSecret:       []gax.CallOption{},
		DeleteSecret:       []gax.CallOption{},
		ListSecretVersions: []gax.CallOption{},
		GetSecretVersion:   []gax.CallOption{},
		AccessSecretVersion: []gax.CallOption{
			gax.WithRetry(func() gax.Retryer {
				return gax.OnCodes([]codes.Code{
					codes.Unavailable,
					codes.Unknown,
				}, gax.Backoff{
					Initial:    1000 * time.Millisecond,
					Max:        60000 * time.Millisecond,
					Multiplier: 1.30,
				})
			}),
		},
		DisableSecretVersion: []gax.CallOption{},
		EnableSecretVersion:  []gax.CallOption{},
		DestroySecretVersion: []gax.CallOption{},
		SetIamPolicy:         []gax.CallOption{},
		GetIamPolicy:         []gax.CallOption{},
		TestIamPermissions:   []gax.CallOption{},
	}
}
Client is a client for interacting with Secret Manager API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Connection pool of gRPC connections to the service.
flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
The call options for this service.
The x-goog-* metadata to be sent with each request.
NewClient creates a new secret manager service client. Secret Manager Service Manages secrets and operations using those secrets. Implements a REST model with the following objects: Secret SecretVersion
func ( context.Context,  ...option.ClientOption) (*Client, error) {
	 := defaultClientOptions()

	if newClientHook != nil {
		,  := newClientHook(, clientHookParams{})
		if  != nil {
			return nil, 
		}
		 = append(, ...)
	}

	,  := checkDisableDeadlines()
	if  != nil {
		return nil, 
	}

	,  := gtransport.DialPool(, append(, ...)...)
	if  != nil {
		return nil, 
	}
	 := &Client{
		connPool:         ,
		disableDeadlines: ,
		CallOptions:      defaultCallOptions(),

		client: secretmanagerpb.NewSecretManagerServiceClient(),
	}
	.setGoogleClientInfo()

	return , nil
}
Connection returns a connection to the API service. Deprecated.
func ( *Client) () *grpc.ClientConn {
	return .connPool.Conn()
}
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func ( *Client) () error {
	return .connPool.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 ( *Client) ( ...string) {
	 := append([]string{"gl-go", versionGo()}, ...)
	 = append(, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
	.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(...))
}
ListSecrets lists Secrets.
func ( *Client) ( context.Context,  *secretmanagerpb.ListSecretsRequest,  ...gax.CallOption) *SecretIterator {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(.GetParent())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.ListSecrets[0:len(.CallOptions.ListSecrets):len(.CallOptions.ListSecrets)], ...)
	 := &SecretIterator{}
	 = proto.Clone().(*secretmanagerpb.ListSecretsRequest)
	.InternalFetch = func( int,  string) ([]*secretmanagerpb.Secret, string, error) {
		var  *secretmanagerpb.ListSecretsResponse
		.PageToken = 
		if  > math.MaxInt32 {
			.PageSize = math.MaxInt32
		} else {
			.PageSize = int32()
		}
		 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
			var  error
			,  = .client.ListSecrets(, , .GRPC...)
			return 
		}, ...)
		if  != nil {
			return nil, "", 
		}

		.Response = 
		return .GetSecrets(), .GetNextPageToken(), nil
	}
	 := func( int,  string) (string, error) {
		, ,  := .InternalFetch(, )
		if  != nil {
			return "", 
		}
		.items = append(.items, ...)
		return , nil
	}
	.pageInfo, .nextFunc = iterator.NewPageInfo(, .bufLen, .takeBuf)
	.pageInfo.MaxSize = int(.GetPageSize())
	.pageInfo.Token = .GetPageToken()
	return 
}
CreateSecret creates a new Secret containing no SecretVersions.
func ( *Client) ( context.Context,  *secretmanagerpb.CreateSecretRequest,  ...gax.CallOption) (*secretmanagerpb.Secret, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(.GetParent())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.CreateSecret[0:len(.CallOptions.CreateSecret):len(.CallOptions.CreateSecret)], ...)
	var  *secretmanagerpb.Secret
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.CreateSecret(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
AddSecretVersion creates a new SecretVersion containing secret data and attaches it to an existing Secret.
func ( *Client) ( context.Context,  *secretmanagerpb.AddSecretVersionRequest,  ...gax.CallOption) (*secretmanagerpb.SecretVersion, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(.GetParent())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.AddSecretVersion[0:len(.CallOptions.AddSecretVersion):len(.CallOptions.AddSecretVersion)], ...)
	var  *secretmanagerpb.SecretVersion
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.AddSecretVersion(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
GetSecret gets metadata for a given Secret.
func ( *Client) ( context.Context,  *secretmanagerpb.GetSecretRequest,  ...gax.CallOption) (*secretmanagerpb.Secret, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.GetSecret[0:len(.CallOptions.GetSecret):len(.CallOptions.GetSecret)], ...)
	var  *secretmanagerpb.Secret
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.GetSecret(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
UpdateSecret updates metadata of an existing Secret.
func ( *Client) ( context.Context,  *secretmanagerpb.UpdateSecretRequest,  ...gax.CallOption) (*secretmanagerpb.Secret, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "secret.name", url.QueryEscape(.GetSecret().GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.UpdateSecret[0:len(.CallOptions.UpdateSecret):len(.CallOptions.UpdateSecret)], ...)
	var  *secretmanagerpb.Secret
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.UpdateSecret(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
DeleteSecret deletes a Secret.
func ( *Client) ( context.Context,  *secretmanagerpb.DeleteSecretRequest,  ...gax.CallOption) error {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.DeleteSecret[0:len(.CallOptions.DeleteSecret):len(.CallOptions.DeleteSecret)], ...)
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		_,  = .client.DeleteSecret(, , .GRPC...)
		return 
	}, ...)
	return 
}
ListSecretVersions lists SecretVersions. This call does not return secret data.
func ( *Client) ( context.Context,  *secretmanagerpb.ListSecretVersionsRequest,  ...gax.CallOption) *SecretVersionIterator {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(.GetParent())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.ListSecretVersions[0:len(.CallOptions.ListSecretVersions):len(.CallOptions.ListSecretVersions)], ...)
	 := &SecretVersionIterator{}
	 = proto.Clone().(*secretmanagerpb.ListSecretVersionsRequest)
	.InternalFetch = func( int,  string) ([]*secretmanagerpb.SecretVersion, string, error) {
		var  *secretmanagerpb.ListSecretVersionsResponse
		.PageToken = 
		if  > math.MaxInt32 {
			.PageSize = math.MaxInt32
		} else {
			.PageSize = int32()
		}
		 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
			var  error
			,  = .client.ListSecretVersions(, , .GRPC...)
			return 
		}, ...)
		if  != nil {
			return nil, "", 
		}

		.Response = 
		return .GetVersions(), .GetNextPageToken(), nil
	}
	 := func( int,  string) (string, error) {
		, ,  := .InternalFetch(, )
		if  != nil {
			return "", 
		}
		.items = append(.items, ...)
		return , nil
	}
	.pageInfo, .nextFunc = iterator.NewPageInfo(, .bufLen, .takeBuf)
	.pageInfo.MaxSize = int(.GetPageSize())
	.pageInfo.Token = .GetPageToken()
	return 
}
GetSecretVersion gets metadata for a SecretVersion. projects/secrets/versions/latest is an alias to the latest SecretVersion.
func ( *Client) ( context.Context,  *secretmanagerpb.GetSecretVersionRequest,  ...gax.CallOption) (*secretmanagerpb.SecretVersion, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.GetSecretVersion[0:len(.CallOptions.GetSecretVersion):len(.CallOptions.GetSecretVersion)], ...)
	var  *secretmanagerpb.SecretVersion
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.GetSecretVersion(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
AccessSecretVersion accesses a SecretVersion. This call returns the secret data. projects/secrets/versions/latest is an alias to the latest SecretVersion.
func ( *Client) ( context.Context,  *secretmanagerpb.AccessSecretVersionRequest,  ...gax.CallOption) (*secretmanagerpb.AccessSecretVersionResponse, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.AccessSecretVersion[0:len(.CallOptions.AccessSecretVersion):len(.CallOptions.AccessSecretVersion)], ...)
	var  *secretmanagerpb.AccessSecretVersionResponse
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.AccessSecretVersion(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
DisableSecretVersion disables a SecretVersion. Sets the state of the SecretVersion to DISABLED.
func ( *Client) ( context.Context,  *secretmanagerpb.DisableSecretVersionRequest,  ...gax.CallOption) (*secretmanagerpb.SecretVersion, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.DisableSecretVersion[0:len(.CallOptions.DisableSecretVersion):len(.CallOptions.DisableSecretVersion)], ...)
	var  *secretmanagerpb.SecretVersion
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.DisableSecretVersion(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
EnableSecretVersion enables a SecretVersion. Sets the state of the SecretVersion to ENABLED.
func ( *Client) ( context.Context,  *secretmanagerpb.EnableSecretVersionRequest,  ...gax.CallOption) (*secretmanagerpb.SecretVersion, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.EnableSecretVersion[0:len(.CallOptions.EnableSecretVersion):len(.CallOptions.EnableSecretVersion)], ...)
	var  *secretmanagerpb.SecretVersion
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.EnableSecretVersion(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
DestroySecretVersion destroys a SecretVersion. Sets the state of the SecretVersion to DESTROYED and irrevocably destroys the secret data.
func ( *Client) ( context.Context,  *secretmanagerpb.DestroySecretVersionRequest,  ...gax.CallOption) (*secretmanagerpb.SecretVersion, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(.GetName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.DestroySecretVersion[0:len(.CallOptions.DestroySecretVersion):len(.CallOptions.DestroySecretVersion)], ...)
	var  *secretmanagerpb.SecretVersion
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.DestroySecretVersion(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
SetIamPolicy sets the access control policy on the specified secret. Replaces any existing policy. Permissions on SecretVersions are enforced according to the policy set on the associated Secret.
func ( *Client) ( context.Context,  *iampb.SetIamPolicyRequest,  ...gax.CallOption) (*iampb.Policy, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(.GetResource())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.SetIamPolicy[0:len(.CallOptions.SetIamPolicy):len(.CallOptions.SetIamPolicy)], ...)
	var  *iampb.Policy
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.SetIamPolicy(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
GetIamPolicy gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set.
func ( *Client) ( context.Context,  *iampb.GetIamPolicyRequest,  ...gax.CallOption) (*iampb.Policy, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(.GetResource())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.GetIamPolicy[0:len(.CallOptions.GetIamPolicy):len(.CallOptions.GetIamPolicy)], ...)
	var  *iampb.Policy
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.GetIamPolicy(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
TestIamPermissions returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns 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 ( *Client) ( context.Context,  *iampb.TestIamPermissionsRequest,  ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
	if ,  := .Deadline(); ! && !.disableDeadlines {
		,  := context.WithTimeout(, 60000*time.Millisecond)
		defer ()
		 = 
	}
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(.GetResource())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.TestIamPermissions[0:len(.CallOptions.TestIamPermissions):len(.CallOptions.TestIamPermissions)], ...)
	var  *iampb.TestIamPermissionsResponse
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.TestIamPermissions(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
SecretIterator manages a stream of *secretmanagerpb.Secret.
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 []*secretmanagerpb.Secret, nextPageToken string, err error)
}
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func ( *SecretIterator) () *iterator.PageInfo {
	return .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 ( *SecretIterator) () (*secretmanagerpb.Secret, error) {
	var  *secretmanagerpb.Secret
	if  := .nextFunc();  != nil {
		return , 
	}
	 = .items[0]
	.items = .items[1:]
	return , nil
}

func ( *SecretIterator) () int {
	return len(.items)
}

func ( *SecretIterator) () interface{} {
	 := .items
	.items = nil
	return 
}
SecretVersionIterator manages a stream of *secretmanagerpb.SecretVersion.
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 []*secretmanagerpb.SecretVersion, nextPageToken string, err error)
}
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
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 ( *SecretVersionIterator) () (*secretmanagerpb.SecretVersion, error) {
	var  *secretmanagerpb.SecretVersion
	if  := .nextFunc();  != nil {
		return , 
	}
	 = .items[0]
	.items = .items[1:]
	return , nil
}

func ( *SecretVersionIterator) () int {
	return len(.items)
}

func ( *SecretVersionIterator) () interface{} {
	 := .items
	.items = nil
	return