Package apigateway is an auto-generated package for the API Gateway 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:
- 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/apigateway/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 := apigateway.NewClient(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 := &apigatewaypb.CreateApiRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/apigateway/apiv1/apigatewaypb#CreateApiRequest. } op, err := c.CreateApi(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context
The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
Functions
func DefaultAuthScopes
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
ApiConfigIterator
type ApiConfigIterator 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 []*apigatewaypb.ApiConfig, nextPageToken string, err error)
// contains filtered or unexported fields
}
ApiConfigIterator manages a stream of *apigatewaypb.ApiConfig.
func (*ApiConfigIterator) All
func (it *ApiConfigIterator) All() iter.Seq2[*apigatewaypb.ApiConfig, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ApiConfigIterator) Next
func (it *ApiConfigIterator) Next() (*apigatewaypb.ApiConfig, 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 (*ApiConfigIterator) PageInfo
func (it *ApiConfigIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ApiIterator
type ApiIterator 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 []*apigatewaypb.Api, nextPageToken string, err error)
// contains filtered or unexported fields
}
ApiIterator manages a stream of *apigatewaypb.Api.
func (*ApiIterator) All
func (it *ApiIterator) All() iter.Seq2[*apigatewaypb.Api, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ApiIterator) Next
func (it *ApiIterator) Next() (*apigatewaypb.Api, 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 (*ApiIterator) PageInfo
func (it *ApiIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
CallOptions
type CallOptions struct {
ListGateways []gax.CallOption
GetGateway []gax.CallOption
CreateGateway []gax.CallOption
UpdateGateway []gax.CallOption
DeleteGateway []gax.CallOption
ListApis []gax.CallOption
GetApi []gax.CallOption
CreateApi []gax.CallOption
UpdateApi []gax.CallOption
DeleteApi []gax.CallOption
ListApiConfigs []gax.CallOption
GetApiConfig []gax.CallOption
CreateApiConfig []gax.CallOption
UpdateApiConfig []gax.CallOption
DeleteApiConfig []gax.CallOption
}
CallOptions contains the retry settings for each method of Client.
Client
type Client struct {
// The call options for this service.
CallOptions *CallOptions
// LROClient is used internally to handle long-running operations.
// It is exposed so that its CallOptions can be modified if required.
// Users should not Close this client.
LROClient *lroauto.OperationsClient
// contains filtered or unexported fields
}
Client is a client for interacting with API Gateway API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The API Gateway Service is the interface for managing API Gateways.
func NewClient
NewClient creates a new api gateway service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
The API Gateway Service is the interface for managing API Gateways.
Example
package main
import (
"context"
apigateway "cloud.google.com/go/apigateway/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 := apigateway.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewRESTClient
NewRESTClient creates a new api gateway service rest client.
The API Gateway Service is the interface for managing API Gateways.
Example
package main
import (
"context"
apigateway "cloud.google.com/go/apigateway/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 := apigateway.NewRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*Client) Close
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*Client) Connection (deprecated)
func (c *Client) 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 (*Client) CreateApi
func (c *Client) CreateApi(ctx context.Context, req *apigatewaypb.CreateApiRequest, opts ...gax.CallOption) (*CreateApiOperation, error)
CreateApi creates a new Api in a given project and location.
Example
package main
import (
"context"
apigateway "cloud.google.com/go/apigateway/apiv1"
apigatewaypb "cloud.google.com/go/apigateway/apiv1/apigatewaypb"
)
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 := apigateway.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apigatewaypb.CreateApiRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apigateway/apiv1/apigatewaypb#CreateApiRequest.
}
op, err := c.CreateApi(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) CreateApiConfig
func (c *Client) CreateApiConfig(ctx context.Context, req *apigatewaypb.CreateApiConfigRequest, opts ...gax.CallOption) (*CreateApiConfigOperation, error)
CreateApiConfig creates a new ApiConfig in a given project and location.
Example
package main
import (
"context"
apigateway "cloud.google.com/go/apigateway/apiv1"
apigatewaypb "cloud.google.com/go/apigateway/apiv1/apigatewaypb"
)
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 := apigateway.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apigatewaypb.CreateApiConfigRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apigateway/apiv1/apigatewaypb#CreateApiConfigRequest.
}
op, err := c.CreateApiConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) CreateApiConfigOperation
func (c *Client) CreateApiConfigOperation(name string) *CreateApiConfigOperation
CreateApiConfigOperation returns a new CreateApiConfigOperation from a given name. The name must be that of a previously created CreateApiConfigOperation, possibly from a different process.
func (*Client) CreateApiOperation
func (c *Client) CreateApiOperation(name string) *CreateApiOperation
CreateApiOperation returns a new CreateApiOperation from a given name. The name must be that of a previously created CreateApiOperation, possibly from a different process.
func (*Client) CreateGateway
func (c *Client) CreateGateway(ctx context.Context, req *apigatewaypb.CreateGatewayRequest, opts ...gax.CallOption) (*CreateGatewayOperation, error)
CreateGateway creates a new Gateway in a given project and location.
Example
package main
import (
"context"
apigateway "cloud.google.com/go/apigateway/apiv1"
apigatewaypb "cloud.google.com/go/apigateway/apiv1/apigatewaypb"
)
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 := apigateway.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apigatewaypb.CreateGatewayRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apigateway/apiv1/apigatewaypb#CreateGatewayRequest.
}
op, err := c.CreateGateway(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) CreateGatewayOperation
func (c *Client) CreateGatewayOperation(name string) *CreateGatewayOperation
CreateGatewayOperation returns a new CreateGatewayOperation from a given name. The name must be that of a previously created CreateGatewayOperation, possibly from a different process.
func (*Client) DeleteApi
func (c *Client) DeleteApi(ctx context.Context, req *apigatewaypb.DeleteApiRequest, opts ...gax.CallOption) (*DeleteApiOperation, error)
DeleteApi deletes a single Api.
Example
package main
import (
"context"
apigateway "cloud.google.com/go/apigateway/apiv1"
apigatewaypb "cloud.google.com/go/apigateway/apiv1/apigatewaypb"
)
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 := apigateway.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apigatewaypb.DeleteApiRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apigateway/apiv1/apigatewaypb#DeleteApiRequest.
}
op, err := c.DeleteApi(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*Client) DeleteApiConfig
func (c *Client) DeleteApiConfig(ctx context.Context, req *apigatewaypb.DeleteApiConfigRequest, opts ...gax.CallOption) (*DeleteApiConfigOperation, error)
DeleteApiConfig deletes a single ApiConfig.
Example
package main
import (
"context"
apigateway "cloud.google.com/go/apigateway/apiv1"
apigatewaypb "cloud.google.com/go/apigateway/apiv1/apigatewaypb"
)
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 := apigateway.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apigatewaypb.DeleteApiConfigRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apigateway/apiv1/apigatewaypb#DeleteApiConfigRequest.
}
op, err := c.DeleteApiConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*Client) DeleteApiConfigOperation
func (c *Client) DeleteApiConfigOperation(name string) *DeleteApiConfigOperation
DeleteApiConfigOperation returns a new DeleteApiConfigOperation from a given name. The name must be that of a previously created DeleteApiConfigOperation, possibly from a different process.
func (*Client) DeleteApiOperation
func (c *Client) DeleteApiOperation(name string) *DeleteApiOperation
DeleteApiOperation returns a new DeleteApiOperation from a given name. The name must be that of a previously created DeleteApiOperation, possibly from a different process.
func (*Client) DeleteGateway
func (c *Client) DeleteGateway(ctx context.Context, req *apigatewaypb.DeleteGatewayRequest, opts ...gax.CallOption) (*DeleteGatewayOperation, error)
DeleteGateway deletes a single Gateway.
Example
package main
import (
"context"
apigateway "cloud.google.com/go/apigateway/apiv1"
apigatewaypb "cloud.google.com/go/apigateway/apiv1/apigatewaypb"
)
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 := apigateway.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apigatewaypb.DeleteGatewayRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apigateway/apiv1/apigatewaypb#DeleteGatewayRequest.
}
op, err := c.DeleteGateway(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*Client) DeleteGatewayOperation
func (c *Client) DeleteGatewayOperation(name string) *DeleteGatewayOperation
DeleteGatewayOperation returns a new DeleteGatewayOperation from a given name. The name must be that of a previously created DeleteGatewayOperation, possibly from a different process.
func (*Client) GetApi
func (c *Client) GetApi(ctx context.Context, req *apigatewaypb.GetApiRequest, opts ...gax.CallOption) (*apigatewaypb.Api, error)
GetApi gets details of a single Api.
Example
package main
import (
"context"
apigateway "cloud.google.com/go/apigateway/apiv1"
apigatewaypb "cloud.google.com/go/apigateway/apiv1/apigatewaypb"
)
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 := apigateway.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apigatewaypb.GetApiRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apigateway/apiv1/apigatewaypb#GetApiRequest.
}
resp, err := c.GetApi(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) GetApiConfig
func (c *Client) GetApiConfig(ctx context.Context, req *apigatewaypb.GetApiConfigRequest, opts ...gax.CallOption) (*apigatewaypb.ApiConfig, error)
GetApiConfig gets details of a single ApiConfig.
Example
package main
import (
"context"
apigateway "cloud.google.com/go/apigateway/apiv1"
apigatewaypb "cloud.google.com/go/apigateway/apiv1/apigatewaypb"
)
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 := apigateway.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &apigatewaypb.GetApiConfigRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/apigateway/apiv1/apigatewaypb#GetApiConfigRequest.
}
resp, err := c.GetApiConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) GetGateway
func (c *Client) GetGateway(ctx context.Context, req *apigatewaypb.GetGatewayRequest, opts ...