API Keys API v2 - Package cloud.google.com/go/apikeys/apiv2 (v1.2.7)

Package apikeys is an auto-generated package for the API Keys API.

Manages the API keys associated with developer projects.

General documentation

For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview . Some information on this page includes:

Example usage

To get started with this package, create a client.

 // go get cloud.google.com/go/apikeys/apiv2@latest 
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
 // This snippet has been automatically generated and should be regarded as a code template only. 
 // It will require modifications to work: 
 // - It may require correct/in-range values for request initialization. 
 // - It may require specifying regional endpoints when creating the service client as shown in: 
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
 NewClient 
 ( 
 ctx 
 ) 
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
 } 
 defer 
  
 c 
 . 
 Close 
 () 

The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.

Using the Client

The following is an example of making an API call with the newly created client, mentioned above.

 req 
  
 := 
  
& apikeyspb 
 . 
 CreateKeyRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/apikeys/apiv2/apikeyspb#CreateKeyRequest. 
 } 
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateKey 
 ( 
 ctx 
 , 
  
 req 
 ) 
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
 } 
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
 } 
 // TODO: Use resp. 
 _ 
  
 = 
  
 resp 

Use of Context

The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

Functions

func DefaultAuthScopes

  func 
  
 DefaultAuthScopes 
 () 
  
 [] 
  string 
 
 

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

CallOptions

  type 
  
 CallOptions 
  
 struct 
  
 { 
  
 CreateKey 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListKeys 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetKey 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetKeyString 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UpdateKey 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 DeleteKey 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UndeleteKey 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 LookupKey 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetOperation 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

CallOptions contains the retry settings for each method of Client.

Client

  type 
  
 Client 
  
 struct 
  
 { 
  
 // The call options for this service. 
  
 CallOptions 
  
 * 
  CallOptions 
 
  
 // 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 
 
  
 // contains filtered or unexported fields 
 } 
 

Client is a client for interacting with API Keys API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Manages the API keys associated with projects.

func NewClient

  func 
  
 NewClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  Client 
 
 , 
  
  error 
 
 ) 
 

NewClient creates a new api keys client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

Manages the API keys associated with projects.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func NewRESTClient

  func 
  
 NewRESTClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  Client 
 
 , 
  
  error 
 
 ) 
 

NewRESTClient creates a new api keys rest client.

Manages the API keys associated with projects.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewRESTClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func (*Client) Close

  func 
  
 ( 
 c 
  
 * 
  Client 
 
 ) 
  
 Close 
 () 
  
  error 
 
 

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*Client) Connection (deprecated)

  func 
  
 ( 
 c 
  
 * 
  Client 
 
 ) 
  
 Connection 
 () 
  
 * 
 grpc 
 . 
 ClientConn 
 

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not always return the same resource.

func (*Client) CreateKey

CreateKey creates a new API key.

NOTE: Key is a global resource; hence the only supported value for location is global.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
  
 apikeyspb 
  
 "cloud.google.com/go/apikeys/apiv2/apikeyspb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& apikeyspb 
 . 
 CreateKeyRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/apikeys/apiv2/apikeyspb#CreateKeyRequest. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateKey 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*Client) CreateKeyOperation

  func 
  
 ( 
 c 
  
 * 
  Client 
 
 ) 
  
 CreateKeyOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  CreateKeyOperation 
 
 

CreateKeyOperation returns a new CreateKeyOperation from a given name. The name must be that of a previously created CreateKeyOperation, possibly from a different process.

func (*Client) DeleteKey

DeleteKey deletes an API key. Deleted key can be retrieved within 30 days of deletion. Afterward, key will be purged from the project.

NOTE: Key is a global resource; hence the only supported value for location is global.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
  
 apikeyspb 
  
 "cloud.google.com/go/apikeys/apiv2/apikeyspb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& apikeyspb 
 . 
 DeleteKeyRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/apikeys/apiv2/apikeyspb#DeleteKeyRequest. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 DeleteKey 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*Client) DeleteKeyOperation

  func 
  
 ( 
 c 
  
 * 
  Client 
 
 ) 
  
 DeleteKeyOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  DeleteKeyOperation 
 
 

DeleteKeyOperation returns a new DeleteKeyOperation from a given name. The name must be that of a previously created DeleteKeyOperation, possibly from a different process.

func (*Client) GetKey

GetKey gets the metadata for an API key. The key string of the API key isn’t included in the response.

NOTE: Key is a global resource; hence the only supported value for location is global.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
  
 apikeyspb 
  
 "cloud.google.com/go/apikeys/apiv2/apikeyspb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& apikeyspb 
 . 
 GetKeyRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/apikeys/apiv2/apikeyspb#GetKeyRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetKey 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*Client) GetKeyString

GetKeyString get the key string for an API key.

NOTE: Key is a global resource; hence the only supported value for location is global.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
  
 apikeyspb 
  
 "cloud.google.com/go/apikeys/apiv2/apikeyspb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& apikeyspb 
 . 
 GetKeyStringRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/apikeys/apiv2/apikeyspb#GetKeyStringRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetKeyString 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*Client) GetOperation

GetOperation is a utility method from google.longrunning.Operations.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
  
 longrunningpb 
  
 "cloud.google.com/go/longrunning/autogen/longrunningpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& longrunningpb 
 . 
  GetOperationRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetOperation 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*Client) ListKeys

ListKeys lists the API keys owned by a project. The key string of the API key isn’t included in the response.

NOTE: Key is a global resource; hence the only supported value for location is global.

Examples

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
  
 apikeyspb 
  
 "cloud.google.com/go/apikeys/apiv2/apikeyspb" 
  
 "google.golang.org/api/iterator" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& apikeyspb 
 . 
 ListKeysRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/apikeys/apiv2/apikeyspb#ListKeysRequest. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 ListKeys 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
  Next 
 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 // If you need to access the underlying RPC response, 
  
 // you can do so by casting the `Response` as below. 
  
 // Otherwise, remove this line. Only populated after 
  
 // first call to Next(). Not safe for concurrent access. 
  
 _ 
  
 = 
  
 it 
 . 
 Response 
 .( 
 * 
 apikeyspb 
 . 
 ListKeysResponse 
 ) 
  
 } 
 } 
 
all
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
  
 apikeyspb 
  
 "cloud.google.com/go/apikeys/apiv2/apikeyspb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& apikeyspb 
 . 
 ListKeysRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/apikeys/apiv2/apikeyspb#ListKeysRequest. 
  
 } 
  
 for 
  
 resp 
 , 
  
 err 
  
 := 
  
 range 
  
 c 
 . 
 ListKeys 
 ( 
 ctx 
 , 
  
 req 
 ). 
  All 
 
 () 
  
 { 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error and break/return/continue. Iteration will stop after any error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 

func (*Client) LookupKey

LookupKey find the parent project and resource name of the API key that matches the key string in the request. If the API key has been purged, resource name will not be set. The service account must have the apikeys.keys.lookup permission on the parent project.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
  
 apikeyspb 
  
 "cloud.google.com/go/apikeys/apiv2/apikeyspb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& apikeyspb 
 . 
 LookupKeyRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/apikeys/apiv2/apikeyspb#LookupKeyRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 LookupKey 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*Client) UndeleteKey

UndeleteKey undeletes an API key which was deleted within 30 days.

NOTE: Key is a global resource; hence the only supported value for location is global.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
  
 apikeyspb 
  
 "cloud.google.com/go/apikeys/apiv2/apikeyspb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& apikeyspb 
 . 
 UndeleteKeyRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/apikeys/apiv2/apikeyspb#UndeleteKeyRequest. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UndeleteKey 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*Client) UndeleteKeyOperation

  func 
  
 ( 
 c 
  
 * 
  Client 
 
 ) 
  
 UndeleteKeyOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  UndeleteKeyOperation 
 
 

UndeleteKeyOperation returns a new UndeleteKeyOperation from a given name. The name must be that of a previously created UndeleteKeyOperation, possibly from a different process.

func (*Client) UpdateKey

UpdateKey patches the modifiable fields of an API key. The key string of the API key isn’t included in the response.

NOTE: Key is a global resource; hence the only supported value for location is global.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 apikeys 
  
 "cloud.google.com/go/apikeys/apiv2" 
  
 apikeyspb 
  
 "cloud.google.com/go/apikeys/apiv2/apikeyspb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 apikeys 
 . 
  NewClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& apikeyspb 
 . 
 UpdateKeyRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/apikeys/apiv2/apikeyspb#UpdateKeyRequest. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UpdateKey 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*Client) UpdateKeyOperation

  func 
  
 ( 
 c 
  
 * 
  Client 
 
 ) 
  
 UpdateKeyOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  UpdateKeyOperation 
 
 

UpdateKeyOperation returns a new UpdateKeyOperation from a given name. The name must be that of a previously created UpdateKeyOperation, possibly from a different process.

CreateKeyOperation

  type 
  
 CreateKeyOperation 
  
 struct 
  
 { 
  
 // contains filtered or unexported fields 
 } 
 

CreateKeyOperation manages a long-running operation from CreateKey.

func (*CreateKeyOperation) Done

  func 
  
 ( 
 op 
  
 * 
  CreateKeyOperation 
 
 ) 
  
 Done 
 () 
  
  bool 
 
 

Done reports whether the long-running operation has completed.

  func 
  
 ( 
 op 
  
 * 
  CreateKeyOperation 
 
 ) 
  
 Metadata 
 () 
  
 ( 
 * 
  emptypb 
 
 . 
  Empty 
 
 , 
  
  error 
 
 ) 
 

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 (*CreateKeyOperation) Name

  func 
  
 ( 
 op 
  
 * 
  CreateKeyOperation 
 
 ) 
  
 Name 
 () 
  
  string 
 
 

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 (*CreateKeyOperation) Poll

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 (*CreateKeyOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

DeleteKeyOperation

  type 
  
 DeleteKeyOperation 
  
 struct 
  
 { 
  
 // contains filtered or unexported fields 
 } 
 

DeleteKeyOperation manages a long-running operation from DeleteKey.

func (*DeleteKeyOperation) Done

  func 
  
 ( 
 op 
  
 * 
  DeleteKeyOperation 
 
 ) 
  
 Done 
 () 
  
  bool 
 
 

Done reports whether the long-running operation has completed.

  func 
  
 ( 
 op 
  
 * 
  DeleteKeyOperation 
 
 ) 
  
 Metadata 
 () 
  
 ( 
 * 
  emptypb 
 
 . 
  Empty 
 
 , 
  
  error 
 
 ) 
 

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 (*DeleteKeyOperation) Name

  func 
  
 ( 
 op 
  
 * 
  DeleteKeyOperation 
 
 ) 
  
 Name 
 () 
  
  string 
 
 

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 (*DeleteKeyOperation) Poll

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 (*DeleteKeyOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

KeyIterator

  type 
  
 KeyIterator 
  
 struct 
  
 { 
  
 // 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 
  
 [] 
 * 
  apikeyspb 
 
 . 
  Key 
 
 , 
  
 nextPageToken 
  
  string 
 
 , 
  
 err 
  
  error 
 
 ) 
  
 // contains filtered or unexported fields 
 } 
 

KeyIterator manages a stream of *apikeyspb.Key.

func (*KeyIterator) All

  func 
  
 ( 
 it 
  
 * 
  KeyIterator 
 
 ) 
  
 All 
 () 
  
 iter 
 . 
 Seq2 
 [ 
 * 
 apikeyspb 
 . 
 Key 
 , 
  
 error 
 ] 
 

All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.

func (*KeyIterator) Next

  func 
  
 ( 
 it 
  
 * 
  KeyIterator 
 
 ) 
  
 Next 
 () 
  
 ( 
 * 
  apikeyspb 
 
 . 
  Key 
 
 , 
  
  error 
 
 ) 
 

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 (*KeyIterator) PageInfo

  func 
  
 ( 
 it 
  
 * 
  KeyIterator 
 
 ) 
  
 PageInfo 
 () 
  
 * 
 iterator 
 . 
 PageInfo 
 

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

UndeleteKeyOperation

  type 
  
 UndeleteKeyOperation 
  
 struct 
  
 { 
  
 // contains filtered or unexported fields 
 } 
 

UndeleteKeyOperation manages a long-running operation from UndeleteKey.

func (*UndeleteKeyOperation) Done

  func 
  
 ( 
 op 
  
 * 
  UndeleteKeyOperation 
 
 ) 
  
 Done 
 () 
  
  bool 
 
 

Done reports whether the long-running operation has completed.

  func 
  
 ( 
 op 
  
 * 
  UndeleteKeyOperation 
 
 ) 
  
 Metadata 
 () 
  
 ( 
 * 
  emptypb 
 
 . 
  Empty 
 
 , 
  
  error 
 
 ) 
 

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 (*UndeleteKeyOperation) Name

  func 
  
 ( 
 op 
  
 * 
  UndeleteKeyOperation 
 
 ) 
  
 Name 
 () 
  
  string 
 
 

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 (*UndeleteKeyOperation) Poll

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 (*UndeleteKeyOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

UpdateKeyOperation

  type 
  
 UpdateKeyOperation 
  
 struct 
  
 { 
  
 // contains filtered or unexported fields 
 } 
 

UpdateKeyOperation manages a long-running operation from UpdateKey.

func (*UpdateKeyOperation) Done

  func 
  
 ( 
 op 
  
 * 
  UpdateKeyOperation 
 
 ) 
  
 Done 
 () 
  
  bool 
 
 

Done reports whether the long-running operation has completed.

  func 
  
 ( 
 op 
  
 * 
  UpdateKeyOperation 
 
 ) 
  
 Metadata 
 () 
  
 ( 
 * 
  emptypb 
 
 . 
  Empty 
 
 , 
  
  error 
 
 ) 
 

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 (*UpdateKeyOperation) Name

  func 
  
 ( 
 op 
  
 * 
  UpdateKeyOperation 
 
 ) 
  
 Name 
 () 
  
  string 
 
 

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 (*UpdateKeyOperation) Poll

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 (*UpdateKeyOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

Create a Mobile Website
View Site in Mobile | Classic
Share by: