KMS Inventory API v1 - Package cloud.google.com/go/kms/inventory/apiv1 (v1.15.8)

Package inventory is an auto-generated package for the KMS Inventory API.

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.

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 := inventory.NewKeyDashboardClient(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.

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 := inventory.NewKeyDashboardClient(ctx)
if err != nil {
    // TODO: Handle error.
}
defer c.Close()

req := &inventorypb.ListCryptoKeysRequest{
    // TODO: Fill request struct fields.
    // See https://pkg.go.dev/cloud.google.com/go/kms/inventory/apiv1/inventorypb#ListCryptoKeysRequest.
}
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
}

Use of Context

The ctx passed to NewKeyDashboardClient 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.

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.

KeyDashboardCallOptions

type KeyDashboardCallOptions struct {
	ListCryptoKeys []gax.CallOption
}

KeyDashboardCallOptions contains the retry settings for each method of KeyDashboardClient.

KeyDashboardClient

type KeyDashboardClient struct {

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

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

Provides a cross-region view of all Cloud KMS keys in a given Cloud project.

func NewKeyDashboardClient

func NewKeyDashboardClient(ctx context.Context, opts ...option.ClientOption) (*KeyDashboardClient, error)

NewKeyDashboardClient creates a new key dashboard service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

Provides a cross-region view of all Cloud KMS keys in a given Cloud project.

Example

package main

import (
	"context"

	inventory "cloud.google.com/go/kms/inventory/apiv1"
)

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 := inventory.NewKeyDashboardClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func NewKeyDashboardRESTClient

func NewKeyDashboardRESTClient(ctx context.Context, opts ...option.ClientOption) (*KeyDashboardClient, error)

NewKeyDashboardRESTClient creates a new key dashboard service rest client.

Provides a cross-region view of all Cloud KMS keys in a given Cloud project.

Example

package main

import (
	"context"

	inventory "cloud.google.com/go/kms/inventory/apiv1"
)

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 := inventory.NewKeyDashboardRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func (*KeyDashboardClient) Close

func (c *KeyDashboardClient) Close() error

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

func (*KeyDashboardClient) Connection (deprecated)

func (c *KeyDashboardClient) 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 (*KeyDashboardClient) ListCryptoKeys

ListCryptoKeys returns cryptographic keys managed by Cloud KMS in a given Cloud project. Note that this data is sourced from snapshots, meaning it may not completely reflect the actual state of key metadata at call time.

Example

package main

import (
	"context"

	inventory "cloud.google.com/go/kms/inventory/apiv1"
	inventorypb "cloud.google.com/go/kms/inventory/apiv1/inventorypb"
	"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 := inventory.NewKeyDashboardClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &inventorypb.ListCryptoKeysRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/kms/inventory/apiv1/inventorypb#ListCryptoKeysRequest.
	}
	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
	}
}

KeyTrackingCallOptions

type KeyTrackingCallOptions struct {
	GetProtectedResourcesSummary []gax.CallOption
	SearchProtectedResources     []gax.CallOption
}

KeyTrackingCallOptions contains the retry settings for each method of KeyTrackingClient.

KeyTrackingClient

type KeyTrackingClient struct {

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

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

Returns information about the resources in an org that are protected by a given Cloud KMS key via CMEK.

func NewKeyTrackingClient

func NewKeyTrackingClient(ctx context.Context, opts ...option.ClientOption) (*KeyTrackingClient, error)

NewKeyTrackingClient creates a new key tracking service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

Returns information about the resources in an org that are protected by a given Cloud KMS key via CMEK.

Example

package main

import (
	"context"

	inventory "cloud.google.com/go/kms/inventory/apiv1"
)

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 := inventory.NewKeyTrackingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func NewKeyTrackingRESTClient

func NewKeyTrackingRESTClient(ctx context.Context, opts ...option.ClientOption) (*KeyTrackingClient, error)

NewKeyTrackingRESTClient creates a new key tracking service rest client.

Returns information about the resources in an org that are protected by a given Cloud KMS key via CMEK.

Example

package main

import (
	"context"

	inventory "cloud.google.com/go/kms/inventory/apiv1"
)

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 := inventory.NewKeyTrackingRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func (*KeyTrackingClient) Close

func (c *KeyTrackingClient) Close() error

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

func (*KeyTrackingClient) Connection (deprecated)

func (c *KeyTrackingClient) 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 (*KeyTrackingClient) GetProtectedResourcesSummary

GetProtectedResourcesSummary returns aggregate information about the resources protected by the given Cloud KMS CryptoKey. Only resources within the same Cloud organization as the key will be returned. The project that holds the key must be part of an organization in order for this call to succeed.

Example

package main

import (
	"context"

	inventory "cloud.google.com/go/kms/inventory/apiv1"
	inventorypb "cloud.google.com/go/kms/inventory/apiv1/inventorypb"
)

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 := inventory.NewKeyTrackingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &inventorypb.GetProtectedResourcesSummaryRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/kms/inventory/apiv1/inventorypb#GetProtectedResourcesSummaryRequest.
	}
	resp, err := c.GetProtectedResourcesSummary(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*KeyTrackingClient) SearchProtectedResources

SearchProtectedResources returns metadata about the resources protected by the given Cloud KMS CryptoKey in the given Cloud organization.

Example

package main

import (
	"context"

	inventory "cloud.google.com/go/kms/inventory/apiv1"
	inventorypb "cloud.google.com/go/kms/inventory/apiv1/inventorypb"
	"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 := inventory.NewKeyTrackingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &inventorypb.SearchProtectedResourcesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/kms/inventory/apiv1/inventorypb#SearchProtectedResourcesRequest.
	}
	it := c.SearchProtectedResources(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

ProtectedResourceIterator

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

ProtectedResourceIterator manages a stream of *inventorypb.ProtectedResource.

func (*ProtectedResourceIterator) Next

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

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

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