Documentation ¶
Overview ¶
Package servicedirectory is an auto-generated package for the Service Directory API.
Service Directory is a platform for discovering, publishing, and connecting services.
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.
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 := servicedirectory.NewLookupClient(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 := servicedirectory.NewLookupClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.ResolveServiceRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#ResolveServiceRequest. } resp, err := c.ResolveService(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context ¶
The ctx passed to NewLookupClient 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 EndpointIterator
- type LocationIterator
- type LookupCallOptions
- type LookupClient
- func (c *LookupClient) Close() error
- func (c *LookupClient) Connection() *grpc.ClientConndeprecated
- func (c *LookupClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, ...) (*locationpb.Location, error)
- func (c *LookupClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, ...) *LocationIterator
- func (c *LookupClient) ResolveService(ctx context.Context, req *servicedirectorypb.ResolveServiceRequest, ...) (*servicedirectorypb.ResolveServiceResponse, error)
- type NamespaceIterator
- type RegistrationCallOptions
- type RegistrationClient
- func (c *RegistrationClient) Close() error
- func (c *RegistrationClient) Connection() *grpc.ClientConndeprecated
- func (c *RegistrationClient) CreateEndpoint(ctx context.Context, req *servicedirectorypb.CreateEndpointRequest, ...) (*servicedirectorypb.Endpoint, error)
- func (c *RegistrationClient) CreateNamespace(ctx context.Context, req *servicedirectorypb.CreateNamespaceRequest, ...) (*servicedirectorypb.Namespace, error)
- func (c *RegistrationClient) CreateService(ctx context.Context, req *servicedirectorypb.CreateServiceRequest, ...) (*servicedirectorypb.Service, error)
- func (c *RegistrationClient) DeleteEndpoint(ctx context.Context, req *servicedirectorypb.DeleteEndpointRequest, ...) error
- func (c *RegistrationClient) DeleteNamespace(ctx context.Context, req *servicedirectorypb.DeleteNamespaceRequest, ...) error
- func (c *RegistrationClient) DeleteService(ctx context.Context, req *servicedirectorypb.DeleteServiceRequest, ...) error
- func (c *RegistrationClient) GetEndpoint(ctx context.Context, req *servicedirectorypb.GetEndpointRequest, ...) (*servicedirectorypb.Endpoint, error)
- func (c *RegistrationClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
- func (c *RegistrationClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, ...) (*locationpb.Location, error)
- func (c *RegistrationClient) GetNamespace(ctx context.Context, req *servicedirectorypb.GetNamespaceRequest, ...) (*servicedirectorypb.Namespace, error)
- func (c *RegistrationClient) GetService(ctx context.Context, req *servicedirectorypb.GetServiceRequest, ...) (*servicedirectorypb.Service, error)
- func (c *RegistrationClient) ListEndpoints(ctx context.Context, req *servicedirectorypb.ListEndpointsRequest, ...) *EndpointIterator
- func (c *RegistrationClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, ...) *LocationIterator
- func (c *RegistrationClient) ListNamespaces(ctx context.Context, req *servicedirectorypb.ListNamespacesRequest, ...) *NamespaceIterator
- func (c *RegistrationClient) ListServices(ctx context.Context, req *servicedirectorypb.ListServicesRequest, ...) *ServiceIterator
- func (c *RegistrationClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
- func (c *RegistrationClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, ...) (*iampb.TestIamPermissionsResponse, error)
- func (c *RegistrationClient) UpdateEndpoint(ctx context.Context, req *servicedirectorypb.UpdateEndpointRequest, ...) (*servicedirectorypb.Endpoint, error)
- func (c *RegistrationClient) UpdateNamespace(ctx context.Context, req *servicedirectorypb.UpdateNamespaceRequest, ...) (*servicedirectorypb.Namespace, error)
- func (c *RegistrationClient) UpdateService(ctx context.Context, req *servicedirectorypb.UpdateServiceRequest, ...) (*servicedirectorypb.Service, error)
- type ServiceIterator
Examples ¶
- LookupClient.GetLocation
- LookupClient.ListLocations
- LookupClient.ResolveService
- NewLookupClient
- NewLookupRESTClient
- NewRegistrationClient
- NewRegistrationRESTClient
- RegistrationClient.CreateEndpoint
- RegistrationClient.CreateNamespace
- RegistrationClient.CreateService
- RegistrationClient.DeleteEndpoint
- RegistrationClient.DeleteNamespace
- RegistrationClient.DeleteService
- RegistrationClient.GetEndpoint
- RegistrationClient.GetIamPolicy
- RegistrationClient.GetLocation
- RegistrationClient.GetNamespace
- RegistrationClient.GetService
- RegistrationClient.ListEndpoints
- RegistrationClient.ListLocations
- RegistrationClient.ListNamespaces
- RegistrationClient.ListServices
- RegistrationClient.SetIamPolicy
- RegistrationClient.TestIamPermissions
- RegistrationClient.UpdateEndpoint
- RegistrationClient.UpdateNamespace
- RegistrationClient.UpdateService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type EndpointIterator ¶
type EndpointIterator 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 []*servicedirectorypb.Endpoint, nextPageToken string, err error) // contains filtered or unexported fields }
EndpointIterator manages a stream of *servicedirectorypb.Endpoint.
func (*EndpointIterator) Next ¶
func (it *EndpointIterator) Next() (*servicedirectorypb.Endpoint, 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 (*EndpointIterator) PageInfo ¶
func (it *EndpointIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type LocationIterator ¶ added in v1.11.0
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) Next ¶ added in v1.11.0
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 ¶ added in v1.11.0
func (it *LocationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type LookupCallOptions ¶
type LookupCallOptions struct { ResolveService []gax.CallOption GetLocation []gax.CallOption ListLocations []gax.CallOption }
LookupCallOptions contains the retry settings for each method of LookupClient.
type LookupClient ¶
type LookupClient struct { // The call options for this service. CallOptions *LookupCallOptions // contains filtered or unexported fields }
LookupClient is a client for interacting with Service Directory API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service Directory API for looking up service data at runtime.
func NewLookupClient ¶
func NewLookupClient(ctx context.Context, opts ...option.ClientOption) (*LookupClient, error)
NewLookupClient creates a new lookup service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Service Directory API for looking up service data at runtime.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" ) 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 := servicedirectory.NewLookupClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewLookupRESTClient ¶ added in v1.3.0
func NewLookupRESTClient(ctx context.Context, opts ...option.ClientOption) (*LookupClient, error)
NewLookupRESTClient creates a new lookup service rest client.
Service Directory API for looking up service data at runtime.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" ) 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 := servicedirectory.NewLookupRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*LookupClient) Close ¶
func (c *LookupClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*LookupClient) Connection
deprecated
func (c *LookupClient) 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 (*LookupClient) GetLocation ¶ added in v1.11.0
func (c *LookupClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error)
GetLocation gets information about a location.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" 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 := servicedirectory.NewLookupClient(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 }
Output:
func (*LookupClient) ListLocations ¶ added in v1.11.0
func (c *LookupClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator
ListLocations lists information about the supported locations for this service.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" "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 := servicedirectory.NewLookupClient(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 } }
Output:
func (*LookupClient) ResolveService ¶
func (c *LookupClient) ResolveService(ctx context.Context, req *servicedirectorypb.ResolveServiceRequest, opts ...gax.CallOption) (*servicedirectorypb.ResolveServiceResponse, error)
ResolveService returns a service and its associated endpoints. Resolving a service is not considered an active developer method.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewLookupClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.ResolveServiceRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#ResolveServiceRequest. } resp, err := c.ResolveService(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type NamespaceIterator ¶
type NamespaceIterator 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 []*servicedirectorypb.Namespace, nextPageToken string, err error) // contains filtered or unexported fields }
NamespaceIterator manages a stream of *servicedirectorypb.Namespace.
func (*NamespaceIterator) Next ¶
func (it *NamespaceIterator) Next() (*servicedirectorypb.Namespace, 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 (*NamespaceIterator) PageInfo ¶
func (it *NamespaceIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type RegistrationCallOptions ¶
type RegistrationCallOptions struct { CreateNamespace []gax.CallOption ListNamespaces []gax.CallOption GetNamespace []gax.CallOption UpdateNamespace []gax.CallOption DeleteNamespace []gax.CallOption CreateService []gax.CallOption ListServices []gax.CallOption GetService []gax.CallOption UpdateService []gax.CallOption DeleteService []gax.CallOption CreateEndpoint []gax.CallOption ListEndpoints []gax.CallOption GetEndpoint []gax.CallOption UpdateEndpoint []gax.CallOption DeleteEndpoint []gax.CallOption GetIamPolicy []gax.CallOption SetIamPolicy []gax.CallOption TestIamPermissions []gax.CallOption GetLocation []gax.CallOption ListLocations []gax.CallOption }
RegistrationCallOptions contains the retry settings for each method of RegistrationClient.
type RegistrationClient ¶
type RegistrationClient struct { // The call options for this service. CallOptions *RegistrationCallOptions // contains filtered or unexported fields }
RegistrationClient is a client for interacting with Service Directory API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Service Directory API for registering services. It defines the following resource model:
The API has a collection of Namespace resources, named projects/*/locations/*/namespaces/*. Each Namespace has a collection of Service resources, named projects/*/locations/*/namespaces/*/services/*. Each Service has a collection of Endpoint resources, named projects/*/locations/*/namespaces/*/services/*/endpoints/*.
func NewRegistrationClient ¶
func NewRegistrationClient(ctx context.Context, opts ...option.ClientOption) (*RegistrationClient, error)
NewRegistrationClient creates a new registration service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Service Directory API for registering services. It defines the following resource model:
The API has a collection of Namespace resources, named projects/*/locations/*/namespaces/*. Each Namespace has a collection of Service resources, named projects/*/locations/*/namespaces/*/services/*. Each Service has a collection of Endpoint resources, named projects/*/locations/*/namespaces/*/services/*/endpoints/*.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func NewRegistrationRESTClient ¶ added in v1.3.0
func NewRegistrationRESTClient(ctx context.Context, opts ...option.ClientOption) (*RegistrationClient, error)
NewRegistrationRESTClient creates a new registration service rest client.
Service Directory API for registering services. It defines the following resource model:
The API has a collection of Namespace resources, named projects/*/locations/*/namespaces/*. Each Namespace has a collection of Service resources, named projects/*/locations/*/namespaces/*/services/*. Each Service has a collection of Endpoint resources, named projects/*/locations/*/namespaces/*/services/*/endpoints/*.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" ) 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 := servicedirectory.NewRegistrationRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c }
Output:
func (*RegistrationClient) Close ¶
func (c *RegistrationClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*RegistrationClient) Connection
deprecated
func (c *RegistrationClient) 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 (*RegistrationClient) CreateEndpoint ¶
func (c *RegistrationClient) CreateEndpoint(ctx context.Context, req *servicedirectorypb.CreateEndpointRequest, opts ...gax.CallOption) (*servicedirectorypb.Endpoint, error)
CreateEndpoint creates an endpoint, and returns the new endpoint.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.CreateEndpointRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#CreateEndpointRequest. } resp, err := c.CreateEndpoint(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RegistrationClient) CreateNamespace ¶
func (c *RegistrationClient) CreateNamespace(ctx context.Context, req *servicedirectorypb.CreateNamespaceRequest, opts ...gax.CallOption) (*servicedirectorypb.Namespace, error)
CreateNamespace creates a namespace, and returns the new namespace.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.CreateNamespaceRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#CreateNamespaceRequest. } resp, err := c.CreateNamespace(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RegistrationClient) CreateService ¶
func (c *RegistrationClient) CreateService(ctx context.Context, req *servicedirectorypb.CreateServiceRequest, opts ...gax.CallOption) (*servicedirectorypb.Service, error)
CreateService creates a service, and returns the new service.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.CreateServiceRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#CreateServiceRequest. } resp, err := c.CreateService(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RegistrationClient) DeleteEndpoint ¶
func (c *RegistrationClient) DeleteEndpoint(ctx context.Context, req *servicedirectorypb.DeleteEndpointRequest, opts ...gax.CallOption) error
DeleteEndpoint deletes an endpoint.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.DeleteEndpointRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#DeleteEndpointRequest. } err = c.DeleteEndpoint(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*RegistrationClient) DeleteNamespace ¶
func (c *RegistrationClient) DeleteNamespace(ctx context.Context, req *servicedirectorypb.DeleteNamespaceRequest, opts ...gax.CallOption) error
DeleteNamespace deletes a namespace. This also deletes all services and endpoints in the namespace.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.DeleteNamespaceRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#DeleteNamespaceRequest. } err = c.DeleteNamespace(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*RegistrationClient) DeleteService ¶
func (c *RegistrationClient) DeleteService(ctx context.Context, req *servicedirectorypb.DeleteServiceRequest, opts ...gax.CallOption) error
DeleteService deletes a service. This also deletes all endpoints associated with the service.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.DeleteServiceRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#DeleteServiceRequest. } err = c.DeleteService(ctx, req) if err != nil { // TODO: Handle error. } }
Output:
func (*RegistrationClient) GetEndpoint ¶
func (c *RegistrationClient) GetEndpoint(ctx context.Context, req *servicedirectorypb.GetEndpointRequest, opts ...gax.CallOption) (*servicedirectorypb.Endpoint, error)
GetEndpoint gets an endpoint.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.GetEndpointRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#GetEndpointRequest. } resp, err := c.GetEndpoint(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RegistrationClient) GetIamPolicy ¶
func (c *RegistrationClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
GetIamPolicy gets the IAM Policy for a resource
Example ¶
package main import ( "context" iampb "cloud.google.com/go/iam/apiv1/iampb" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &iampb.GetIamPolicyRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest. } resp, err := c.GetIamPolicy(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RegistrationClient) GetLocation ¶ added in v1.11.0
func (c *RegistrationClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error)
GetLocation gets information about a location.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" 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 := servicedirectory.NewRegistrationClient(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 }
Output:
func (*RegistrationClient) GetNamespace ¶
func (c *RegistrationClient) GetNamespace(ctx context.Context, req *servicedirectorypb.GetNamespaceRequest, opts ...gax.CallOption) (*servicedirectorypb.Namespace, error)
GetNamespace gets a namespace.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.GetNamespaceRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#GetNamespaceRequest. } resp, err := c.GetNamespace(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RegistrationClient) GetService ¶
func (c *RegistrationClient) GetService(ctx context.Context, req *servicedirectorypb.GetServiceRequest, opts ...gax.CallOption) (*servicedirectorypb.Service, error)
GetService gets a service.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.GetServiceRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#GetServiceRequest. } resp, err := c.GetService(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RegistrationClient) ListEndpoints ¶
func (c *RegistrationClient) ListEndpoints(ctx context.Context, req *servicedirectorypb.ListEndpointsRequest, opts ...gax.CallOption) *EndpointIterator
ListEndpoints lists all endpoints.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" "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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.ListEndpointsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#ListEndpointsRequest. } it := c.ListEndpoints(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*RegistrationClient) ListLocations ¶ added in v1.11.0
func (c *RegistrationClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator
ListLocations lists information about the supported locations for this service.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" "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 := servicedirectory.NewRegistrationClient(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 } }
Output:
func (*RegistrationClient) ListNamespaces ¶
func (c *RegistrationClient) ListNamespaces(ctx context.Context, req *servicedirectorypb.ListNamespacesRequest, opts ...gax.CallOption) *NamespaceIterator
ListNamespaces lists all namespaces.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" "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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.ListNamespacesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#ListNamespacesRequest. } it := c.ListNamespaces(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*RegistrationClient) ListServices ¶
func (c *RegistrationClient) ListServices(ctx context.Context, req *servicedirectorypb.ListServicesRequest, opts ...gax.CallOption) *ServiceIterator
ListServices lists all services belonging to a namespace.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" "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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.ListServicesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#ListServicesRequest. } it := c.ListServices(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } }
Output:
func (*RegistrationClient) SetIamPolicy ¶
func (c *RegistrationClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
SetIamPolicy sets the IAM Policy for a resource
Example ¶
package main import ( "context" iampb "cloud.google.com/go/iam/apiv1/iampb" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &iampb.SetIamPolicyRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest. } resp, err := c.SetIamPolicy(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RegistrationClient) TestIamPermissions ¶
func (c *RegistrationClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
TestIamPermissions tests IAM permissions for a resource (namespace, service or service workload only).
Example ¶
package main import ( "context" iampb "cloud.google.com/go/iam/apiv1/iampb" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &iampb.TestIamPermissionsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest. } resp, err := c.TestIamPermissions(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RegistrationClient) UpdateEndpoint ¶
func (c *RegistrationClient) UpdateEndpoint(ctx context.Context, req *servicedirectorypb.UpdateEndpointRequest, opts ...gax.CallOption) (*servicedirectorypb.Endpoint, error)
UpdateEndpoint updates an endpoint.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.UpdateEndpointRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#UpdateEndpointRequest. } resp, err := c.UpdateEndpoint(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RegistrationClient) UpdateNamespace ¶
func (c *RegistrationClient) UpdateNamespace(ctx context.Context, req *servicedirectorypb.UpdateNamespaceRequest, opts ...gax.CallOption) (*servicedirectorypb.Namespace, error)
UpdateNamespace updates a namespace.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.UpdateNamespaceRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#UpdateNamespaceRequest. } resp, err := c.UpdateNamespace(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
func (*RegistrationClient) UpdateService ¶
func (c *RegistrationClient) UpdateService(ctx context.Context, req *servicedirectorypb.UpdateServiceRequest, opts ...gax.CallOption) (*servicedirectorypb.Service, error)
UpdateService updates a service.
Example ¶
package main import ( "context" servicedirectory "cloud.google.com/go/servicedirectory/apiv1beta1" servicedirectorypb "cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb" ) 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 := servicedirectory.NewRegistrationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &servicedirectorypb.UpdateServiceRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/servicedirectory/apiv1beta1/servicedirectorypb#UpdateServiceRequest. } resp, err := c.UpdateService(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
type ServiceIterator ¶
type ServiceIterator 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 []*servicedirectorypb.Service, nextPageToken string, err error) // contains filtered or unexported fields }
ServiceIterator manages a stream of *servicedirectorypb.Service.
func (*ServiceIterator) Next ¶
func (it *ServiceIterator) Next() (*servicedirectorypb.Service, 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 (*ServiceIterator) PageInfo ¶
func (it *ServiceIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.