Back to godoc.org

Package kms

v0.66.0
Latest Go to latest

The latest major version is .

Published: Sep 15, 2020 | License: Apache-2.0 | Module: cloud.google.com/go

Overview

Package kms is an auto-generated package for the Cloud Key Management Service (KMS) API.

Manages keys and performs cryptographic operations in a central cloud service, for direct use by other cloud resources and applications.

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.

For information about setting deadlines, reusing contexts, and more please visit pkg.go.dev/cloud.google.com/go.

Index

Examples

func DefaultAuthScopes

func DefaultAuthScopes() []string

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

type CryptoKeyIterator

type CryptoKeyIterator 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 []*kmspb.CryptoKey, nextPageToken string, err error)
	// contains filtered or unexported fields
}

CryptoKeyIterator manages a stream of *kmspb.CryptoKey.

func (*CryptoKeyIterator) Next

func (it *CryptoKeyIterator) Next() (*kmspb.CryptoKey, 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 (*CryptoKeyIterator) PageInfo

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

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

type CryptoKeyVersionIterator

type CryptoKeyVersionIterator 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 []*kmspb.CryptoKeyVersion, nextPageToken string, err error)
	// contains filtered or unexported fields
}

CryptoKeyVersionIterator manages a stream of *kmspb.CryptoKeyVersion.

func (*CryptoKeyVersionIterator) Next

func (it *CryptoKeyVersionIterator) Next() (*kmspb.CryptoKeyVersion, 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 (*CryptoKeyVersionIterator) PageInfo

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

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

type ImportJobIterator

type ImportJobIterator 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 []*kmspb.ImportJob, nextPageToken string, err error)
	// contains filtered or unexported fields
}

ImportJobIterator manages a stream of *kmspb.ImportJob.

func (*ImportJobIterator) Next

func (it *ImportJobIterator) Next() (*kmspb.ImportJob, 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 (*ImportJobIterator) PageInfo

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

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

type KeyManagementCallOptions

type KeyManagementCallOptions struct {
	ListKeyRings                  []gax.CallOption
	ListCryptoKeys                []gax.CallOption
	ListCryptoKeyVersions         []gax.CallOption
	ListImportJobs                []gax.CallOption
	GetKeyRing                    []gax.CallOption
	GetCryptoKey                  []gax.CallOption
	GetCryptoKeyVersion           []gax.CallOption
	GetPublicKey                  []gax.CallOption
	GetImportJob                  []gax.CallOption
	CreateKeyRing                 []gax.CallOption
	CreateCryptoKey               []gax.CallOption
	CreateCryptoKeyVersion        []gax.CallOption
	ImportCryptoKeyVersion        []gax.CallOption
	CreateImportJob               []gax.CallOption
	UpdateCryptoKey               []gax.CallOption
	UpdateCryptoKeyVersion        []gax.CallOption
	Encrypt                       []gax.CallOption
	Decrypt                       []gax.CallOption
	AsymmetricSign                []gax.CallOption
	AsymmetricDecrypt             []gax.CallOption
	UpdateCryptoKeyPrimaryVersion []gax.CallOption
	DestroyCryptoKeyVersion       []gax.CallOption
	RestoreCryptoKeyVersion       []gax.CallOption
}

KeyManagementCallOptions contains the retry settings for each method of KeyManagementClient.

type KeyManagementClient

type KeyManagementClient struct {

	// The call options for this service.
	CallOptions *KeyManagementCallOptions
	// contains filtered or unexported fields
}

KeyManagementClient is a client for interacting with Cloud Key Management Service (KMS) API.

Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

func NewKeyManagementClient

func NewKeyManagementClient(ctx context.Context, opts ...option.ClientOption) (*KeyManagementClient, error)

NewKeyManagementClient creates a new key management service client.

Google Cloud Key Management Service

Manages cryptographic keys and operations using those keys. Implements a REST model with the following objects:

KeyRing

CryptoKey

CryptoKeyVersion

ImportJob

If you are using manual gRPC libraries, see Using gRPC with Cloud KMS (at https://cloud.google.com/kms/docs/grpc).

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
)

func main() {
	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use client.
	_ = c
}

func (*KeyManagementClient) AsymmetricDecrypt

func (c *KeyManagementClient) AsymmetricDecrypt(ctx context.Context, req *kmspb.AsymmetricDecryptRequest, opts ...gax.CallOption) (*kmspb.AsymmetricDecryptResponse, error)

AsymmetricDecrypt decrypts data that was encrypted with a public key retrieved from GetPublicKey corresponding to a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_DECRYPT.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.AsymmetricDecryptRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.AsymmetricDecrypt(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) AsymmetricSign

func (c *KeyManagementClient) AsymmetricSign(ctx context.Context, req *kmspb.AsymmetricSignRequest, opts ...gax.CallOption) (*kmspb.AsymmetricSignResponse, error)

AsymmetricSign signs data using a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from GetPublicKey.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.AsymmetricSignRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.AsymmetricSign(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) Close

func (c *KeyManagementClient) Close() error

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

func (*KeyManagementClient) Connection

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

Connection returns a connection to the API service.

Deprecated.

func (*KeyManagementClient) CreateCryptoKey

func (c *KeyManagementClient) CreateCryptoKey(ctx context.Context, req *kmspb.CreateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error)

CreateCryptoKey create a new CryptoKey within a KeyRing.

CryptoKey.purpose and CryptoKey.version_template.algorithm are required.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.CreateCryptoKeyRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.CreateCryptoKey(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) CreateCryptoKeyVersion

func (c *KeyManagementClient) CreateCryptoKeyVersion(ctx context.Context, req *kmspb.CreateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)

CreateCryptoKeyVersion create a new CryptoKeyVersion in a CryptoKey.

The server will assign the next sequential id. If unset, state will be set to ENABLED.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.CreateCryptoKeyVersionRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.CreateCryptoKeyVersion(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) CreateImportJob

func (c *KeyManagementClient) CreateImportJob(ctx context.Context, req *kmspb.CreateImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error)

CreateImportJob create a new ImportJob within a KeyRing.

ImportJob.import_method is required.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.CreateImportJobRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.CreateImportJob(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) CreateKeyRing

func (c *KeyManagementClient) CreateKeyRing(ctx context.Context, req *kmspb.CreateKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error)

CreateKeyRing create a new KeyRing in a given Project and Location.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.CreateKeyRingRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.CreateKeyRing(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) CryptoKeyIAM

func (c *KeyManagementClient) CryptoKeyIAM(cryptoKey *kmspb.CryptoKey) *iam.Handle

CryptoKeyIAM returns a handle to inspect and change permissions of a CryptoKey.

Deprecated: Please use ResourceIAM and provide the CryptoKey.Name as input.

func (*KeyManagementClient) Decrypt

func (c *KeyManagementClient) Decrypt(ctx context.Context, req *kmspb.DecryptRequest, opts ...gax.CallOption) (*kmspb.DecryptResponse, error)

Decrypt decrypts data that was protected by Encrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.DecryptRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.Decrypt(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) DestroyCryptoKeyVersion

func (c *KeyManagementClient) DestroyCryptoKeyVersion(ctx context.Context, req *kmspb.DestroyCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)

DestroyCryptoKeyVersion schedule a CryptoKeyVersion for destruction.

Upon calling this method, CryptoKeyVersion.state will be set to DESTROY_SCHEDULED and destroy_time will be set to a time 24 hours in the future, at which point the state will be changed to DESTROYED, and the key material will be irrevocably destroyed.

Before the destroy_time is reached, RestoreCryptoKeyVersion may be called to reverse the process.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.DestroyCryptoKeyVersionRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.DestroyCryptoKeyVersion(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) Encrypt

func (c *KeyManagementClient) Encrypt(ctx context.Context, req *kmspb.EncryptRequest, opts ...gax.CallOption) (*kmspb.EncryptResponse, error)

Encrypt encrypts data, so that it can only be recovered by a call to Decrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.EncryptRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.Encrypt(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) GetCryptoKey

func (c *KeyManagementClient) GetCryptoKey(ctx context.Context, req *kmspb.GetCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error)

GetCryptoKey returns metadata for a given CryptoKey, as well as its primary CryptoKeyVersion.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.GetCryptoKeyRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetCryptoKey(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) GetCryptoKeyVersion

func (c *KeyManagementClient) GetCryptoKeyVersion(ctx context.Context, req *kmspb.GetCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)

GetCryptoKeyVersion returns metadata for a given CryptoKeyVersion.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.GetCryptoKeyVersionRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetCryptoKeyVersion(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) GetImportJob

func (c *KeyManagementClient) GetImportJob(ctx context.Context, req *kmspb.GetImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error)

GetImportJob returns metadata for a given ImportJob.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.GetImportJobRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetImportJob(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) GetKeyRing

func (c *KeyManagementClient) GetKeyRing(ctx context.Context, req *kmspb.GetKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error)

GetKeyRing returns metadata for a given KeyRing.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.GetKeyRingRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetKeyRing(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) GetPublicKey

func (c *KeyManagementClient) GetPublicKey(ctx context.Context, req *kmspb.GetPublicKeyRequest, opts ...gax.CallOption) (*kmspb.PublicKey, error)

GetPublicKey returns the public key for the given CryptoKeyVersion. The CryptoKey.purpose must be ASYMMETRIC_SIGN or ASYMMETRIC_DECRYPT.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.GetPublicKeyRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetPublicKey(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) ImportCryptoKeyVersion

func (c *KeyManagementClient) ImportCryptoKeyVersion(ctx context.Context, req *kmspb.ImportCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)

ImportCryptoKeyVersion imports a new CryptoKeyVersion into an existing CryptoKey using the wrapped key material provided in the request.

The version ID will be assigned the next sequential id within the CryptoKey.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.ImportCryptoKeyVersionRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.ImportCryptoKeyVersion(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) KeyRingIAM

func (c *KeyManagementClient) KeyRingIAM(keyRing *kmspb.KeyRing) *iam.Handle

KeyRingIAM returns a handle to inspect and change permissions of a KeyRing.

Deprecated: Please use ResourceIAM and provide the KeyRing.Name as input.

func (*KeyManagementClient) ListCryptoKeyVersions

func (c *KeyManagementClient) ListCryptoKeyVersions(ctx context.Context, req *kmspb.ListCryptoKeyVersionsRequest, opts ...gax.CallOption) *CryptoKeyVersionIterator

ListCryptoKeyVersions lists CryptoKeyVersions.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	"google.golang.org/api/iterator"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.ListCryptoKeyVersionsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListCryptoKeyVersions(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*KeyManagementClient) ListCryptoKeys

func (c *KeyManagementClient) ListCryptoKeys(ctx context.Context, req *kmspb.ListCryptoKeysRequest, opts ...gax.CallOption) *CryptoKeyIterator

ListCryptoKeys lists CryptoKeys.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	"google.golang.org/api/iterator"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.ListCryptoKeysRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListCryptoKeys(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*KeyManagementClient) ListImportJobs

func (c *KeyManagementClient) ListImportJobs(ctx context.Context, req *kmspb.ListImportJobsRequest, opts ...gax.CallOption) *ImportJobIterator

ListImportJobs lists ImportJobs.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	"google.golang.org/api/iterator"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.ListImportJobsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListImportJobs(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*KeyManagementClient) ListKeyRings

func (c *KeyManagementClient) ListKeyRings(ctx context.Context, req *kmspb.ListKeyRingsRequest, opts ...gax.CallOption) *KeyRingIterator

ListKeyRings lists KeyRings.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	"google.golang.org/api/iterator"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.ListKeyRingsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListKeyRings(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*KeyManagementClient) ResourceIAM

func (c *KeyManagementClient) ResourceIAM(resourcePath string) *iam.Handle

ResourceIAM returns a handle to inspect and change permissions of the resource indicated by the given resource path.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
)

func main() {
	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	// TODO: fill in key ring resource path
	keyRing := "projects/[PROJECT_ID]/locations/[LOCATION]/keyRings/[KEY_RING]"
	handle := c.ResourceIAM(keyRing)

	policy, err := handle.Policy(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use policy.
	_ = policy
}

func (*KeyManagementClient) RestoreCryptoKeyVersion

func (c *KeyManagementClient) RestoreCryptoKeyVersion(ctx context.Context, req *kmspb.RestoreCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)

RestoreCryptoKeyVersion restore a CryptoKeyVersion in the DESTROY_SCHEDULED state.

Upon restoration of the CryptoKeyVersion, state will be set to DISABLED, and destroy_time will be cleared.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.RestoreCryptoKeyVersionRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.RestoreCryptoKeyVersion(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) UpdateCryptoKey

func (c *KeyManagementClient) UpdateCryptoKey(ctx context.Context, req *kmspb.UpdateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error)

UpdateCryptoKey update a CryptoKey.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.UpdateCryptoKeyRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateCryptoKey(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) UpdateCryptoKeyPrimaryVersion

func (c *KeyManagementClient) UpdateCryptoKeyPrimaryVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyPrimaryVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error)

UpdateCryptoKeyPrimaryVersion update the version of a CryptoKey that will be used in Encrypt.

Returns an error if called on an asymmetric key.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.UpdateCryptoKeyPrimaryVersionRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateCryptoKeyPrimaryVersion(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyManagementClient) UpdateCryptoKeyVersion

func (c *KeyManagementClient) UpdateCryptoKeyVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)

UpdateCryptoKeyVersion update a CryptoKeyVersion's metadata.

state may be changed between ENABLED and DISABLED using this method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to move between other states.

Example

Code:

package main

import (
	kms "cloud.google.com/go/kms/apiv1"
	"context"
	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
)

func main() {
	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"

	ctx := context.Background()
	c, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &kmspb.UpdateCryptoKeyVersionRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateCryptoKeyVersion(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

type KeyRingIterator

type KeyRingIterator 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 []*kmspb.KeyRing, nextPageToken string, err error)
	// contains filtered or unexported fields
}

KeyRingIterator manages a stream of *kmspb.KeyRing.

func (*KeyRingIterator) Next

func (it *KeyRingIterator) Next() (*kmspb.KeyRing, 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 (*KeyRingIterator) PageInfo

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

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier