ReservationServiceClient

ReservationServiceClient

This API allows users to manage their BigQuery reservations.

A reservation provides computational resource guarantees, in the form of slots, to users. A slot is a unit of computational power in BigQuery, and serves as the basic unit of parallelism. In a scan of a multi-partitioned table, a single slot operates on a single partition of the table. A reservation resource exists as a child resource of the admin project and location, e.g.: projects/myproject/locations/US/reservations/reservationName.

A capacity commitment is a way to purchase compute capacity for BigQuery jobs (in the form of slots) with some committed period of usage. A capacity commitment resource exists as a child resource of the admin project and location, e.g.: projects/myproject/locations/US/capacityCommitments/id.

Constructor

new ReservationServiceClient(optionsopt, gaxInstanceopt)

Construct an instance of ReservationServiceClient.

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 ReservationServiceClient({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

assignmentPath(project, location, reservation, assignment) → {string}

Return a fully-qualified assignment resource name string.

Parameters:
Name Type Description
project string
location string
reservation string
assignment string
Returns:
Type Description
string

Resource name string.

biReservationPath(project, location) → {string}

Return a fully-qualified biReservation resource name string.

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

Resource name string.

capacityCommitmentPath(project, location, capacity_commitment) → {string}

Return a fully-qualified capacityCommitment resource name string.

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

Resource name string.

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.

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.

listAssignmentsAsync(request, optionsopt) → {Object}

Equivalent to listAssignments, 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. The parent resource name e.g.:

projects/myproject/locations/US/reservations/team1-prod

Or:

projects/myproject/locations/US/reservations/-

pageSize number

The maximum number of items to return per page.

pageToken string

The next_page_token value returned from a previous List request, if any.

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 Assignment. 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. The parent resource name e.g.:
   *  `projects/myproject/locations/US/reservations/team1-prod`
   *  Or:
   *  `projects/myproject/locations/US/reservations/-`
   */
  // const parent = 'abc123'
  /**
   *  The maximum number of items to return per page.
   */
  // const pageSize = 1234
  /**
   *  The next_page_token value returned from a previous List request, if any.
   */
  // const pageToken = 'abc123'

  // Imports the Reservation library
  const {ReservationServiceClient} = require('@google-cloud/bigquery-reservation').v1;

  // Instantiates a client
  const reservationClient = new ReservationServiceClient();

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

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

  callListAssignments();

listAssignmentsStream(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. The parent resource name e.g.:

projects/myproject/locations/US/reservations/team1-prod

Or:

projects/myproject/locations/US/reservations/-

pageSize number

The maximum number of items to return per page.

pageToken string

The next_page_token value returned from a previous List request, if any.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Assignment 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 listAssignmentsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listCapacityCommitmentsAsync(request, optionsopt) → {Object}

Equivalent to listCapacityCommitments, 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. Resource name of the parent reservation. E.g., projects/myproject/locations/US

pageSize number

The maximum number of items to return.

pageToken string

The next_page_token value returned from a previous List request, if any.

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 CapacityCommitment. 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. Resource name of the parent reservation. E.g.,
   *     `projects/myproject/locations/US`
   */
  // const parent = 'abc123'
  /**
   *  The maximum number of items to return.
   */
  // const pageSize = 1234
  /**
   *  The next_page_token value returned from a previous List request, if any.
   */
  // const pageToken = 'abc123'

  // Imports the Reservation library
  const {ReservationServiceClient} = require('@google-cloud/bigquery-reservation').v1;

  // Instantiates a client
  const reservationClient = new ReservationServiceClient();

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

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

  callListCapacityCommitments();

listCapacityCommitmentsStream(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. Resource name of the parent reservation. E.g., projects/myproject/locations/US

pageSize number

The maximum number of items to return.

pageToken string

The next_page_token value returned from a previous List request, if any.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing CapacityCommitment 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 listCapacityCommitmentsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listReservationsAsync(request, optionsopt) → {Object}

Equivalent to listReservations, 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. The parent resource name containing project and location, e.g.: projects/myproject/locations/US

pageSize number

The maximum number of items to return per page.

pageToken string

The next_page_token value returned from a previous List request, if any.

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 Reservation. 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. The parent resource name containing project and location, e.g.:
   *    `projects/myproject/locations/US`
   */
  // const parent = 'abc123'
  /**
   *  The maximum number of items to return per page.
   */
  // const pageSize = 1234
  /**
   *  The next_page_token value returned from a previous List request, if any.
   */
  // const pageToken = 'abc123'

  // Imports the Reservation library
  const {ReservationServiceClient} = require('@google-cloud/bigquery-reservation').v1;

  // Instantiates a client
  const reservationClient = new ReservationServiceClient();

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

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

  callListReservations();

listReservationsStream(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. The parent resource name containing project and location, e.g.: projects/myproject/locations/US

pageSize number

The maximum number of items to return per page.

pageToken string

The next_page_token value returned from a previous List request, if any.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Reservation 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 listReservationsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

locationPath(project, location) → {string}

Return a fully-qualified location resource name string.

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

Resource name string.

matchAssignmentFromAssignmentName(assignmentName) → {string}

Parse the assignment from Assignment resource.

Parameters:
Name Type Description
assignmentName string

A fully-qualified path representing Assignment resource.

Returns:
Type Description
string

A string representing the assignment.

matchCapacityCommitmentFromCapacityCommitmentName(capacityCommitmentName) → {string}

Parse the capacity_commitment from CapacityCommitment resource.

Parameters:
Name Type Description
capacityCommitmentName string

A fully-qualified path representing CapacityCommitment resource.

Returns:
Type Description
string

A string representing the capacity_commitment.

matchLocationFromAssignmentName(assignmentName) → {string}

Parse the location from Assignment resource.

Parameters:
Name Type Description
assignmentName string

A fully-qualified path representing Assignment resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromBiReservationName(biReservationName) → {string}

Parse the location from BiReservation resource.

Parameters:
Name Type Description
biReservationName string

A fully-qualified path representing BiReservation resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromCapacityCommitmentName(capacityCommitmentName) → {string}

Parse the location from CapacityCommitment resource.

Parameters:
Name Type Description
capacityCommitmentName string

A fully-qualified path representing CapacityCommitment resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromLocationName(locationName) → {string}

Parse the location from Location resource.

Parameters:
Name Type Description
locationName string

A fully-qualified path representing Location resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromReservationName(reservationName) → {string}

Parse the location from Reservation resource.

Parameters:
Name Type Description
reservationName string

A fully-qualified path representing Reservation resource.

Returns:
Type Description
string

A string representing the location.

matchProjectFromAssignmentName(assignmentName) → {string}

Parse the project from Assignment resource.

Parameters:
Name Type Description
assignmentName string

A fully-qualified path representing Assignment resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromBiReservationName(biReservationName) → {string}

Parse the project from BiReservation resource.

Parameters:
Name Type Description
biReservationName string

A fully-qualified path representing BiReservation resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromCapacityCommitmentName(capacityCommitmentName) → {string}

Parse the project from CapacityCommitment resource.

Parameters:
Name Type Description
capacityCommitmentName string

A fully-qualified path representing CapacityCommitment resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromLocationName(locationName) → {string}

Parse the project from Location resource.

Parameters:
Name Type Description
locationName string

A fully-qualified path representing Location resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromProjectName(projectName) → {string}

Parse the project from Project resource.

Parameters:
Name Type Description
projectName string

A fully-qualified path representing Project resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromReservationName(reservationName) → {string}

Parse the project from Reservation resource.

Parameters:
Name Type Description
reservationName string

A fully-qualified path representing Reservation resource.

Returns:
Type Description
string

A string representing the project.

matchReservationFromAssignmentName(assignmentName) → {string}

Parse the reservation from Assignment resource.

Parameters:
Name Type Description
assignmentName string

A fully-qualified path representing Assignment resource.

Returns:
Type Description
string

A string representing the reservation.

matchReservationFromReservationName(reservationName) → {string}

Parse the reservation from Reservation resource.

Parameters:
Name Type Description
reservationName string

A fully-qualified path representing Reservation resource.

Returns:
Type Description
string

A string representing the reservation.

projectPath(project) → {string}

Return a fully-qualified project resource name string.

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

Resource name string.

reservationPath(project, location, reservation) → {string}

Return a fully-qualified reservation resource name string.

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

Resource name string.

searchAllAssignmentsAsync(request, optionsopt) → {Object}

Equivalent to searchAllAssignments, 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. The resource name with location (project name could be the wildcard '-'), e.g.: projects/-/locations/US.

query string

Please specify resource name as assignee in the query.

Examples:

  • assignee=projects/myproject
  • assignee=folders/123
  • assignee=organizations/456
pageSize number

The maximum number of items to return per page.

pageToken string

The next_page_token value returned from a previous List request, if any.

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 Assignment. 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. The resource name with location (project name could be the
   *  wildcard '-'), e.g.:
   *    `projects/-/locations/US`.
   */
  // const parent = 'abc123'
  /**
   *  Please specify resource name as assignee in the query.
   *  Examples:
   *  * `assignee=projects/myproject`
   *  * `assignee=folders/123`
   *  * `assignee=organizations/456`
   */
  // const query = 'abc123'
  /**
   *  The maximum number of items to return per page.
   */
  // const pageSize = 1234
  /**
   *  The next_page_token value returned from a previous List request, if any.
   */
  // const pageToken = 'abc123'

  // Imports the Reservation library
  const {ReservationServiceClient} = require('@google-cloud/bigquery-reservation').v1;

  // Instantiates a client
  const reservationClient = new ReservationServiceClient();

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

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

  callSearchAllAssignments();

searchAllAssignmentsStream(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. The resource name with location (project name could be the wildcard '-'), e.g.: projects/-/locations/US.

query string

Please specify resource name as assignee in the query.

Examples:

  • assignee=projects/myproject
  • assignee=folders/123
  • assignee=organizations/456
pageSize number

The maximum number of items to return per page.

pageToken string

The next_page_token value returned from a previous List request, if any.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Assignment 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 searchAllAssignmentsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

searchAssignmentsAsync(request, optionsopt) → {Object}

Equivalent to searchAssignments, but returns an iterable object.

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

Deprecated: SearchAssignments is deprecated and may be removed in a future version.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The resource name of the admin project(containing project and location), e.g.: projects/myproject/locations/US.

query string

Please specify resource name as assignee in the query.

Examples:

  • assignee=projects/myproject
  • assignee=folders/123
  • assignee=organizations/456
pageSize number

The maximum number of items to return per page.

pageToken string

The next_page_token value returned from a previous List request, if any.

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 Assignment. 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. The resource name of the admin project(containing project and
   *  location), e.g.:
   *    `projects/myproject/locations/US`.
   */
  // const parent = 'abc123'
  /**
   *  Please specify resource name as assignee in the query.
   *  Examples:
   *  * `assignee=projects/myproject`
   *  * `assignee=folders/123`
   *  * `assignee=organizations/456`
   */
  // const query = 'abc123'
  /**
   *  The maximum number of items to return per page.
   */
  // const pageSize = 1234
  /**
   *  The next_page_token value returned from a previous List request, if any.
   */
  // const pageToken = 'abc123'

  // Imports the Reservation library
  const {ReservationServiceClient} = require('@google-cloud/bigquery-reservation').v1;

  // Instantiates a client
  const reservationClient = new ReservationServiceClient();

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

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

  callSearchAssignments();

searchAssignmentsStream(request, optionsopt) → {Stream}

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

Deprecated: SearchAssignments is deprecated and may be removed in a future version.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The resource name of the admin project(containing project and location), e.g.: projects/myproject/locations/US.

query string

Please specify resource name as assignee in the query.

Examples:

  • assignee=projects/myproject
  • assignee=folders/123
  • assignee=organizations/456
pageSize number

The maximum number of items to return per page.

pageToken string

The next_page_token value returned from a previous List request, if any.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Assignment 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 searchAssignmentsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.