Package apiregistry is an auto-generated package for the Cloud API Registry API.
NOTE: This package is in beta. It is not stable, and may be subject to changes.
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:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
// go get cloud.google.com/go/apiregistry/apiv1@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 := apiregistry.NewCloudApiRegistryClient(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 := &apiregistrypb.GetMcpServerRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/apiregistry/apiv1/apiregistrypb#GetMcpServerRequest. } resp, err := c.GetMcpServer(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context
The ctx passed to NewCloudApiRegistryClient 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() []stringDefaultAuthScopes reports the default set of authentication scopes to use with this package.
CloudApiRegistryCallOptions
type CloudApiRegistryCallOptions struct {
GetMcpServer []gax.CallOption
ListMcpServers []gax.CallOption
GetMcpTool []gax.CallOption
ListMcpTools []gax.CallOption
GetLocation []gax.CallOption
ListLocations []gax.CallOption
}CloudApiRegistryCallOptions contains the retry settings for each method of CloudApiRegistryClient.
CloudApiRegistryClient
type CloudApiRegistryClient struct {
// The call options for this service.
CallOptions *CloudApiRegistryCallOptions
// contains filtered or unexported fields
}CloudApiRegistryClient is a client for interacting with Cloud API Registry API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The Cloud API Registry service provides a central registry for managing API Data.
func NewCloudApiRegistryClient
func NewCloudApiRegistryClient(ctx context.Context, opts ...option.ClientOption) (*CloudApiRegistryClient, error)NewCloudApiRegistryClient creates a new cloud api registry client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
The Cloud API Registry service provides a central registry for managing API Data.
Example
package main
import (
"context"
apiregistry "cloud.google.com/go/apiregistry/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 := apiregistry.NewCloudApiRegistryClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewCloudApiRegistryRESTClient
func NewCloudApiRegistryRESTClient(ctx context.Context, opts ...option.ClientOption) (*CloudApiRegistryClient, error)NewCloudApiRegistryRESTClient creates a new cloud api registry rest client.
The Cloud API Registry service provides a central registry for managing API Data.
Example
package main
import (
"context"
apiregistry "cloud.google.com/go/apiregistry/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 := apiregistry.NewCloudApiRegistryRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*CloudApiRegistryClient) Close
func (c *CloudApiRegistryClient) Close() errorClose closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*CloudApiRegistryClient) Connection (deprecated)
func (c *CloudApiRegistryClient) Connection() *grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*CloudApiRegistryClient) GetLocation
func (c *CloudApiRegistryClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error)GetLocation gets information about a location.
Example
package main
import (
"context"
apiregistry "cloud.google.com/go/apiregistry/apiv1"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
)
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 := apiregistry.NewCloudApiRegistryClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &locationpb.GetLocationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
}
resp, err := c.GetLocation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudApiRegistryClient) GetMcpServer
func (c *CloudApiRegistryClient) GetMcpServer(ctx context.Context, req *apiregistrypb.GetMcpServerRequest, opts ...gax.CallOption) (*apiregistrypb.McpServer, error)GetMcpServer gets a single McpServer.
Example
package main
import (
"context"
apiregistry "cloud.google.com/go/apiregistry/apiv1"
apiregistrypb "cloud.google.com/go/apiregistry/apiv1/apiregistrypb"
)
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 := apiregistry.NewCloudApiRegistryClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apiregistrypb.GetMcpServerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apiregistry/apiv1/apiregistrypb#GetMcpServerRequest.
}
resp, err := c.GetMcpServer(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudApiRegistryClient) GetMcpTool
func (c *CloudApiRegistryClient) GetMcpTool(ctx context.Context, req *apiregistrypb.GetMcpToolRequest, opts ...gax.CallOption) (*apiregistrypb.McpTool, error)GetMcpTool gets a single McpTool.
Example
package main
import (
"context"
apiregistry "cloud.google.com/go/apiregistry/apiv1"
apiregistrypb "cloud.google.com/go/apiregistry/apiv1/apiregistrypb"
)
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 := apiregistry.NewCloudApiRegistryClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apiregistrypb.GetMcpToolRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apiregistry/apiv1/apiregistrypb#GetMcpToolRequest.
}
resp, err := c.GetMcpTool(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudApiRegistryClient) ListLocations
func (c *CloudApiRegistryClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIteratorListLocations lists information about the supported locations for this service.
Examples
package main
import (
"context"
apiregistry "cloud.google.com/go/apiregistry/apiv1"
"google.golang.org/api/iterator"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
)
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 := apiregistry.NewCloudApiRegistryClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &locationpb.ListLocationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
}
it := c.ListLocations(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.(*locationpb.ListLocationsResponse)
}
}
all
package main
import (
"context"
apiregistry "cloud.google.com/go/apiregistry/apiv1"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
)
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 := apiregistry.NewCloudApiRegistryClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &locationpb.ListLocationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
}
for resp, err := range c.ListLocations(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*CloudApiRegistryClient) ListMcpServers
func (c *CloudApiRegistryClient) ListMcpServers(ctx context.Context, req *apiregistrypb.ListMcpServersRequest, opts ...gax.CallOption) *McpServerIteratorListMcpServers lists McpServers in a given Project.
Examples
package main
import (
"context"
apiregistry "cloud.google.com/go/apiregistry/apiv1"
apiregistrypb "cloud.google.com/go/apiregistry/apiv1/apiregistrypb"
"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 := apiregistry.NewCloudApiRegistryClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apiregistrypb.ListMcpServersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apiregistry/apiv1/apiregistrypb#ListMcpServersRequest.
}
it := c.ListMcpServers(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.(*apiregistrypb.ListMcpServersResponse)
}
}
all
package main
import (
"context"
apiregistry "cloud.google.com/go/apiregistry/apiv1"
apiregistrypb "cloud.google.com/go/apiregistry/apiv1/apiregistrypb"
)
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 := apiregistry.NewCloudApiRegistryClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apiregistrypb.ListMcpServersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apiregistry/apiv1/apiregistrypb#ListMcpServersRequest.
}
for resp, err := range c.ListMcpServers(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*CloudApiRegistryClient) ListMcpTools
func (c *CloudApiRegistryClient) ListMcpTools(ctx context.Context, req *apiregistrypb.ListMcpToolsRequest, opts ...gax.CallOption) *McpToolIteratorListMcpTools lists McpTools in a given McpServer.
Examples
package main
import (
"context"
apiregistry "cloud.google.com/go/apiregistry/apiv1"
apiregistrypb "cloud.google.com/go/apiregistry/apiv1/apiregistrypb"
"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 := apiregistry.NewCloudApiRegistryClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apiregistrypb.ListMcpToolsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apiregistry/apiv1/apiregistrypb#ListMcpToolsRequest.
}
it := c.ListMcpTools(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.(*apiregistrypb.ListMcpToolsResponse)
}
}
all
package main
import (
"context"
apiregistry "cloud.google.com/go/apiregistry/apiv1"
apiregistrypb "cloud.google.com/go/apiregistry/apiv1/apiregistrypb"
)
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 := apiregistry.NewCloudApiRegistryClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apiregistrypb.ListMcpToolsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apiregistry/apiv1/apiregistrypb#ListMcpToolsRequest.
}
for resp, err := range c.ListMcpTools(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
LocationIterator
type LocationIterator 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 []*locationpb.Location, nextPageToken string, err error)
// contains filtered or unexported fields
}LocationIterator manages a stream of *locationpb.Location.
func (*LocationIterator) All
func (it *LocationIterator) All() iter.Seq2[*locationpb.Location, error]All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*LocationIterator) Next
func (it *LocationIterator) Next() (*locationpb.Location, 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 (*LocationIterator) PageInfo
func (it *LocationIterator) PageInfo() *iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
McpServerIterator
type McpServerIterator 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 []*apiregistrypb.McpServer, nextPageToken string, err error)
// contains filtered or unexported fields
}McpServerIterator manages a stream of *apiregistrypb.McpServer.
func (*McpServerIterator) All
func (it *McpServerIterator) All() iter.Seq2[*apiregistrypb.McpServer, error]All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*McpServerIterator) Next
func (it *McpServerIterator) Next() (*apiregistrypb.McpServer, 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 (*McpServerIterator) PageInfo
func (it *McpServerIterator) PageInfo() *iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
McpToolIterator
type McpToolIterator 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 []*apiregistrypb.McpTool, nextPageToken string, err error)
// contains filtered or unexported fields
}McpToolIterator manages a stream of *apiregistrypb.McpTool.
func (*McpToolIterator) All
func (it *McpToolIterator) All() iter.Seq2[*apiregistrypb.McpTool, error]All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*McpToolIterator) Next
func (it *McpToolIterator) Next() (*apiregistrypb.McpTool, 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 (*McpToolIterator) PageInfo
func (it *McpToolIterator) PageInfo() *iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.