ApiGatewayServiceClient

ApiGatewayServiceClient

The API Gateway Service is the interface for managing API Gateways.

Constructor

new ApiGatewayServiceClient(optionsopt, gaxInstanceopt)

Construct an instance of ApiGatewayServiceClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. The options accepted by the constructor are described in detail in this document. The common options are:

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

clientConfig gax.ClientConfig <optional>

Client configuration override. Follows the structure of gapicConfig.

fallback boolean | "rest" <optional>

Use HTTP fallback mode. Pass "rest" to use HTTP/1.1 REST API instead of gRPC. For more information, please check the documentation.

gaxInstance gax <optional>

loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new ApiGatewayServiceClient({fallback: 'rest'}, gax);

Members

apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

port

The port for this API service.

scopes

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

The DNS address for this API service.

Methods

apiConfigPath(project, api, api_config) → {string}

Return a fully-qualified apiConfig resource name string.

Parameters:
Name Type Description
project string
api string
api_config string
Returns:
Type Description
string

Resource name string.

apiPath(project, api) → {string}

Return a fully-qualified api resource name string.

Parameters:
Name Type Description
project string
api string
Returns:
Type Description
string

Resource name string.

(async) checkCreateApiConfigProgress(name) → {Promise}

Check the status of the long running operation returned by createApiConfig().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Parent resource of the API Config, of the form:
   *  `projects/* /locations/global/apis/*`
   */
  // const parent = 'abc123'
  /**
   *  Required. Identifier to assign to the API Config. Must be unique within scope of
   *  the parent resource.
   */
  // const apiConfigId = 'abc123'
  /**
   *  Required. API resource.
   */
  // const apiConfig = {}

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callCreateApiConfig() {
    // Construct request
    const request = {
      parent,
      apiConfigId,
      apiConfig,
    };

    // Run request
    const [operation] = await apigatewayClient.createApiConfig(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callCreateApiConfig();

(async) checkCreateApiProgress(name) → {Promise}

Check the status of the long running operation returned by createApi().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Parent resource of the API, of the form:
   *  `projects/* /locations/global`
   */
  // const parent = 'abc123'
  /**
   *  Required. Identifier to assign to the API. Must be unique within scope of
   *  the parent resource.
   */
  // const apiId = 'abc123'
  /**
   *  Required. API resource.
   */
  // const api = {}

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callCreateApi() {
    // Construct request
    const request = {
      parent,
      apiId,
      api,
    };

    // Run request
    const [operation] = await apigatewayClient.createApi(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callCreateApi();

(async) checkCreateGatewayProgress(name) → {Promise}

Check the status of the long running operation returned by createGateway().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Parent resource of the Gateway, of the form:
   *  `projects/* /locations/*`
   */
  // const parent = 'abc123'
  /**
   *  Required. Identifier to assign to the Gateway. Must be unique within scope of
   *  the parent resource.
   */
  // const gatewayId = 'abc123'
  /**
   *  Required. Gateway resource.
   */
  // const gateway = {}

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callCreateGateway() {
    // Construct request
    const request = {
      parent,
      gatewayId,
      gateway,
    };

    // Run request
    const [operation] = await apigatewayClient.createGateway(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callCreateGateway();

(async) checkDeleteApiConfigProgress(name) → {Promise}

Check the status of the long running operation returned by deleteApiConfig().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the form:
   *  `projects/* /locations/global/apis/* /configs/*`
   */
  // const name = 'abc123'

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callDeleteApiConfig() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const [operation] = await apigatewayClient.deleteApiConfig(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteApiConfig();

(async) checkDeleteApiProgress(name) → {Promise}

Check the status of the long running operation returned by deleteApi().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the form:
   *  `projects/* /locations/global/apis/*`
   */
  // const name = 'abc123'

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callDeleteApi() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const [operation] = await apigatewayClient.deleteApi(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteApi();

(async) checkDeleteGatewayProgress(name) → {Promise}

Check the status of the long running operation returned by deleteGateway().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the form:
   *  `projects/* /locations/* /gateways/*`
   */
  // const name = 'abc123'

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callDeleteGateway() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const [operation] = await apigatewayClient.deleteGateway(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteGateway();

(async) checkUpdateApiConfigProgress(name) → {Promise}

Check the status of the long running operation returned by updateApiConfig().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Field mask is used to specify the fields to be overwritten in the
   *  ApiConfig resource by the update.
   *  The fields specified in the update_mask are relative to the resource, not
   *  the full request. A field will be overwritten if it is in the mask. If the
   *  user does not provide a mask then all fields will be overwritten.
   */
  // const updateMask = {}
  /**
   *  Required. API Config resource.
   */
  // const apiConfig = {}

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callUpdateApiConfig() {
    // Construct request
    const request = {
      apiConfig,
    };

    // Run request
    const [operation] = await apigatewayClient.updateApiConfig(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callUpdateApiConfig();

(async) checkUpdateApiProgress(name) → {Promise}

Check the status of the long running operation returned by updateApi().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Field mask is used to specify the fields to be overwritten in the
   *  Api resource by the update.
   *  The fields specified in the update_mask are relative to the resource, not
   *  the full request. A field will be overwritten if it is in the mask. If the
   *  user does not provide a mask then all fields will be overwritten.
   */
  // const updateMask = {}
  /**
   *  Required. API resource.
   */
  // const api = {}

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callUpdateApi() {
    // Construct request
    const request = {
      api,
    };

    // Run request
    const [operation] = await apigatewayClient.updateApi(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callUpdateApi();

(async) checkUpdateGatewayProgress(name) → {Promise}

Check the status of the long running operation returned by updateGateway().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Field mask is used to specify the fields to be overwritten in the
   *  Gateway resource by the update.
   *  The fields specified in the update_mask are relative to the resource, not
   *  the full request. A field will be overwritten if it is in the mask. If the
   *  user does not provide a mask then all fields will be overwritten.
   */
  // const updateMask = {}
  /**
   *  Required. Gateway resource.
   */
  // const gateway = {}

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callUpdateGateway() {
    // Construct request
    const request = {
      gateway,
    };

    // Run request
    const [operation] = await apigatewayClient.updateGateway(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callUpdateGateway();

close() → {Promise}

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns:
Type Description
Promise

A promise that resolves when the client is closed.

gatewayPath(project, location, gateway) → {string}

Return a fully-qualified gateway resource name string.

Parameters:
Name Type Description
project string
location string
gateway string
Returns:
Type Description
string

Resource name string.

getProjectId() → {Promise}

Return the project ID used by this class.

Returns:
Type Description
Promise

A promise that resolves to string containing the project ID.

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns:
Type Description
Promise

A promise that resolves to an authenticated service stub.

listApiConfigsAsync(request, optionsopt) → {Object}

Equivalent to listApiConfigs, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. Parent resource of the API Config, of the form: projects/* /locations/global/apis/*

pageSize number

Page size.

pageToken string

Page token.

filter string

Filter.

orderBy string

Order by parameters.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing ApiConfig. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Parent resource of the API Config, of the form:
   *  `projects/* /locations/global/apis/*`
   */
  // const parent = 'abc123'
  /**
   *  Page size.
   */
  // const pageSize = 1234
  /**
   *  Page token.
   */
  // const pageToken = 'abc123'
  /**
   *  Filter.
   */
  // const filter = 'abc123'
  /**
   *  Order by parameters.
   */
  // const orderBy = 'abc123'

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callListApiConfigs() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = await apigatewayClient.listApiConfigsAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListApiConfigs();

listApiConfigsStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. Parent resource of the API Config, of the form: projects/* /locations/global/apis/*

pageSize number

Page size.

pageToken string

Page token.

filter string

Filter.

orderBy string

Order by parameters.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing ApiConfig on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listApiConfigsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listApisAsync(request, optionsopt) → {Object}

Equivalent to listApis, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. Parent resource of the API, of the form: projects/* /locations/global

pageSize number

Page size.

pageToken string

Page token.

filter string

Filter.

orderBy string

Order by parameters.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Api. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Parent resource of the API, of the form:
   *  `projects/* /locations/global`
   */
  // const parent = 'abc123'
  /**
   *  Page size.
   */
  // const pageSize = 1234
  /**
   *  Page token.
   */
  // const pageToken = 'abc123'
  /**
   *  Filter.
   */
  // const filter = 'abc123'
  /**
   *  Order by parameters.
   */
  // const orderBy = 'abc123'

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callListApis() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = await apigatewayClient.listApisAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListApis();

listApisStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. Parent resource of the API, of the form: projects/* /locations/global

pageSize number

Page size.

pageToken string

Page token.

filter string

Filter.

orderBy string

Order by parameters.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Api on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listApisAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listGatewaysAsync(request, optionsopt) → {Object}

Equivalent to listGateways, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. Parent resource of the Gateway, of the form: projects/* /locations/*

pageSize number

Page size.

pageToken string

Page token.

filter string

Filter.

orderBy string

Order by parameters.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Gateway. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
  /**
   * 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.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Parent resource of the Gateway, of the form:
   *  `projects/* /locations/*`
   */
  // const parent = 'abc123'
  /**
   *  Page size.
   */
  // const pageSize = 1234
  /**
   *  Page token.
   */
  // const pageToken = 'abc123'
  /**
   *  Filter.
   */
  // const filter = 'abc123'
  /**
   *  Order by parameters.
   */
  // const orderBy = 'abc123'

  // Imports the Apigateway library
  const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway').v1;

  // Instantiates a client
  const apigatewayClient = new ApiGatewayServiceClient();

  async function callListGateways() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = await apigatewayClient.listGatewaysAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListGateways();

listGatewaysStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. Parent resource of the Gateway, of the form: projects/* /locations/*

pageSize number

Page size.

pageToken string

Page token.

filter string

Filter.

orderBy string

Order by parameters.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Gateway on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listGatewaysAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

matchApiConfigFromApiConfigName(apiConfigName) → {string}

Parse the api_config from ApiConfig resource.

Parameters:
Name Type Description
apiConfigName string

A fully-qualified path representing ApiConfig resource.

Returns:
Type Description
string

A string representing the api_config.

matchApiFromApiConfigName(apiConfigName) → {string}

Parse the api from ApiConfig resource.

Parameters:
Name Type Description
apiConfigName string

A fully-qualified path representing ApiConfig resource.

Returns:
Type Description
string

A string representing the api.

matchApiFromApiName(apiName) → {string}

Parse the api from Api resource.

Parameters:
Name Type Description
apiName string

A fully-qualified path representing Api resource.

Returns:
Type Description
string

A string representing the api.

matchGatewayFromGatewayName(gatewayName) → {string}

Parse the gateway from Gateway resource.

Parameters:
Name Type Description
gatewayName string

A fully-qualified path representing Gateway resource.

Returns:
Type Description
string

A string representing the gateway.

matchLocationFromGatewayName(gatewayName) → {string}

Parse the location from Gateway resource.

Parameters:
Name Type Description
gatewayName string

A fully-qualified path representing Gateway resource.

Returns:
Type Description
string

A string representing the location.

matchProjectFromApiConfigName(apiConfigName) → {string}

Parse the project from ApiConfig resource.

Parameters:
Name Type Description
apiConfigName string

A fully-qualified path representing ApiConfig resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromApiName(apiName) → {string}

Parse the project from Api resource.

Parameters:
Name Type Description
apiName string

A fully-qualified path representing Api resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromGatewayName(gatewayName) → {string}

Parse the project from Gateway resource.

Parameters:
Name Type Description
gatewayName string

A fully-qualified path representing Gateway resource.

Returns:
Type Description
string

A string representing the project.