...

Package inventory

import "cloud.google.com/go/kms/inventory/apiv1"
Overview
Index
Examples
Subdirectories

Overview ▾

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

	// 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.(*inventorypb.ListCryptoKeysResponse)
}

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.

Index ▾

func DefaultAuthScopes() []string
type CryptoKeyIterator
    func (it *CryptoKeyIterator) Next() (*kmspb.CryptoKey, error)
    func (it *CryptoKeyIterator) PageInfo() *iterator.PageInfo
type KeyDashboardCallOptions
type KeyDashboardClient
    func NewKeyDashboardClient(ctx context.Context, opts ...option.ClientOption) (*KeyDashboardClient, error)
    func NewKeyDashboardRESTClient(ctx context.Context, opts ...option.ClientOption) (*KeyDashboardClient, error)
    func (c *KeyDashboardClient) Close() error
    func (c *KeyDashboardClient) Connection() *grpc.ClientConn
    func (c *KeyDashboardClient) ListCryptoKeys(ctx context.Context, req *inventorypb.ListCryptoKeysRequest, opts ...gax.CallOption) *CryptoKeyIterator
type KeyTrackingCallOptions
type KeyTrackingClient
    func NewKeyTrackingClient(ctx context.Context, opts ...option.ClientOption) (*KeyTrackingClient, error)
    func NewKeyTrackingRESTClient(ctx context.Context, opts ...option.ClientOption) (*KeyTrackingClient, error)
    func (c *KeyTrackingClient) Close() error
    func (c *KeyTrackingClient) Connection() *grpc.ClientConn
    func (c *KeyTrackingClient) GetProtectedResourcesSummary(ctx context.Context, req *inventorypb.GetProtectedResourcesSummaryRequest, opts ...gax.CallOption) (*inventorypb.ProtectedResourcesSummary, error)
    func (c *KeyTrackingClient) SearchProtectedResources(ctx context.Context, req *inventorypb.SearchProtectedResourcesRequest, opts ...gax.CallOption) *ProtectedResourceIterator
type ProtectedResourceIterator
    func (it *ProtectedResourceIterator) Next() (*inventorypb.ProtectedResource, error)
    func (it *ProtectedResourceIterator) PageInfo() *iterator.PageInfo

Package files

auxiliary.go doc.go key_dashboard_client.go key_tracking_client.go version.go

func DefaultAuthScopes

func DefaultAuthScopes() []string

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

type CryptoKeyIterator

CryptoKeyIterator manages a stream of *kmspb.CryptoKey.

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
}

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 KeyDashboardCallOptions

KeyDashboardCallOptions contains the retry settings for each method of KeyDashboardClient.

type KeyDashboardCallOptions struct {
    ListCryptoKeys []gax.CallOption
}

type KeyDashboardClient

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.

type KeyDashboardClient struct {

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

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

Code:

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

Code:

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

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

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

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

Code:

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

    // 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.(*inventorypb.ListCryptoKeysResponse)
}

type KeyTrackingCallOptions

KeyTrackingCallOptions contains the retry settings for each method of KeyTrackingClient.

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

type KeyTrackingClient

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.

type KeyTrackingClient struct {

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

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

Code:

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

Code:

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

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

func (c *KeyTrackingClient) GetProtectedResourcesSummary(ctx context.Context, req *inventorypb.GetProtectedResourcesSummaryRequest, opts ...gax.CallOption) (*inventorypb.ProtectedResourcesSummary, error)

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

Code:

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

func (c *KeyTrackingClient) SearchProtectedResources(ctx context.Context, req *inventorypb.SearchProtectedResourcesRequest, opts ...gax.CallOption) *ProtectedResourceIterator

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

Example

Code:

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

    // 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.(*inventorypb.SearchProtectedResourcesResponse)
}

type ProtectedResourceIterator

ProtectedResourceIterator manages a stream of *inventorypb.ProtectedResource.

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
}

func (*ProtectedResourceIterator) Next

func (it *ProtectedResourceIterator) Next() (*inventorypb.ProtectedResource, 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 (*ProtectedResourceIterator) PageInfo

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

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

Subdirectories

Name Synopsis
..
inventorypb