Class v1beta.DataSourcesServiceClient (0.1.0)

Service to manage primary, supplemental, inventory and other data sources. See more in the [Merchant Center](https://support.google.com/merchants/answer/7439058) help article. v1beta

Package

@google-shopping/datasources

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of DataSourcesServiceClient.

Parameters
Name Description
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: 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 DataSourcesServiceClient({fallback: true}, gax); ```

Properties

apiEndpoint

get apiEndpoint(): string;

The DNS address for this API service.

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath.

auth

auth: gax.GoogleAuth;

dataSourcesServiceStub

dataSourcesServiceStub?: Promise<{
        [name: string]: Function;
    }>;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

pathTemplates

pathTemplates: {
        [name: string]: gax.PathTemplate;
    };

port

static get port(): number;

The port for this API service.

scopes

static get scopes(): string[];

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

servicePath

static get servicePath(): string;

The DNS address for this API service.

universeDomain

get universeDomain(): string;

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

accountPath(account)

accountPath(account: string): string;

Return a fully-qualified account resource name string.

Parameter
Name Description
account string
Returns
Type Description
string

{string} Resource name string.

close()

close(): Promise<void>;

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<void>

{Promise} A promise that resolves when the client is closed.

createDataSource(request, options)

createDataSource(request?: protos.google.shopping.merchant.datasources.v1beta.ICreateDataSourceRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.datasources.v1beta.IDataSource,
        (protos.google.shopping.merchant.datasources.v1beta.ICreateDataSourceRequest | undefined),
        {} | undefined
    ]>;

Creates the new data source configuration for the given account.

Parameters
Name Description
request ICreateDataSourceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.datasources.v1beta.IDataSource, (protos.google.shopping.merchant.datasources.v1beta.ICreateDataSourceRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . 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 account where this data source will be created.
   *  Format: `accounts/{account}`
   */
  // const parent = 'abc123'
  /**
   *  Required. The data source to create.
   */
  // const dataSource = {}

  // Imports the Datasources library
  const {DataSourcesServiceClient} = require('@google-shopping/datasources').v1beta;

  // Instantiates a client
  const datasourcesClient = new DataSourcesServiceClient();

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

    // Run request
    const response = await datasourcesClient.createDataSource(request);
    console.log(response);
  }

  callCreateDataSource();

createDataSource(request, options, callback)

createDataSource(request: protos.google.shopping.merchant.datasources.v1beta.ICreateDataSourceRequest, options: CallOptions, callback: Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.ICreateDataSourceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateDataSourceRequest
options CallOptions
callback Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.ICreateDataSourceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

createDataSource(request, callback)

createDataSource(request: protos.google.shopping.merchant.datasources.v1beta.ICreateDataSourceRequest, callback: Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.ICreateDataSourceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateDataSourceRequest
callback Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.ICreateDataSourceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

dataSourcePath(account, datasource)

dataSourcePath(account: string, datasource: string): string;

Return a fully-qualified dataSource resource name string.

Parameters
Name Description
account string
datasource string
Returns
Type Description
string

{string} Resource name string.

deleteDataSource(request, options)

deleteDataSource(request?: protos.google.shopping.merchant.datasources.v1beta.IDeleteDataSourceRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        (protos.google.shopping.merchant.datasources.v1beta.IDeleteDataSourceRequest | undefined),
        {} | undefined
    ]>;

Deletes a data source from your Merchant Center account.

Parameters
Name Description
request IDeleteDataSourceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.protobuf.IEmpty, (protos.google.shopping.merchant.datasources.v1beta.IDeleteDataSourceRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Empty. 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 name of the data source to delete.
   *  Format: `accounts/{account}/dataSources/{datasource}`
   */
  // const name = 'abc123'

  // Imports the Datasources library
  const {DataSourcesServiceClient} = require('@google-shopping/datasources').v1beta;

  // Instantiates a client
  const datasourcesClient = new DataSourcesServiceClient();

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

    // Run request
    const response = await datasourcesClient.deleteDataSource(request);
    console.log(response);
  }

  callDeleteDataSource();

deleteDataSource(request, options, callback)

deleteDataSource(request: protos.google.shopping.merchant.datasources.v1beta.IDeleteDataSourceRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.datasources.v1beta.IDeleteDataSourceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteDataSourceRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.datasources.v1beta.IDeleteDataSourceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteDataSource(request, callback)

deleteDataSource(request: protos.google.shopping.merchant.datasources.v1beta.IDeleteDataSourceRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.datasources.v1beta.IDeleteDataSourceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteDataSourceRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.datasources.v1beta.IDeleteDataSourceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

fetchDataSource(request, options)

fetchDataSource(request?: protos.google.shopping.merchant.datasources.v1beta.IFetchDataSourceRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        (protos.google.shopping.merchant.datasources.v1beta.IFetchDataSourceRequest | undefined),
        {} | undefined
    ]>;

Performs the data fetch immediately (even outside fetch schedule) on a data source from your Merchant Center Account. If you need to call this method more than once per day, you should use the Products service to update your product data instead. This method only works on data sources with a file input set.

Parameters
Name Description
request IFetchDataSourceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.protobuf.IEmpty, (protos.google.shopping.merchant.datasources.v1beta.IFetchDataSourceRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Empty. 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 name of the data source resource to fetch.
   *  Format: `accounts/{account}/dataSources/{datasource}`
   */
  // const name = 'abc123'

  // Imports the Datasources library
  const {DataSourcesServiceClient} = require('@google-shopping/datasources').v1beta;

  // Instantiates a client
  const datasourcesClient = new DataSourcesServiceClient();

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

    // Run request
    const response = await datasourcesClient.fetchDataSource(request);
    console.log(response);
  }

  callFetchDataSource();

fetchDataSource(request, options, callback)

fetchDataSource(request: protos.google.shopping.merchant.datasources.v1beta.IFetchDataSourceRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.datasources.v1beta.IFetchDataSourceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IFetchDataSourceRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.datasources.v1beta.IFetchDataSourceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

fetchDataSource(request, callback)

fetchDataSource(request: protos.google.shopping.merchant.datasources.v1beta.IFetchDataSourceRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.datasources.v1beta.IFetchDataSourceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IFetchDataSourceRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.datasources.v1beta.IFetchDataSourceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getDataSource(request, options)

getDataSource(request?: protos.google.shopping.merchant.datasources.v1beta.IGetDataSourceRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.datasources.v1beta.IDataSource,
        (protos.google.shopping.merchant.datasources.v1beta.IGetDataSourceRequest | undefined),
        {} | undefined
    ]>;

Retrieves the data source configuration for the given account.

Parameters
Name Description
request IGetDataSourceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.datasources.v1beta.IDataSource, (protos.google.shopping.merchant.datasources.v1beta.IGetDataSourceRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . 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 name of the data source to retrieve.
   *  Format: `accounts/{account}/dataSources/{datasource}`
   */
  // const name = 'abc123'

  // Imports the Datasources library
  const {DataSourcesServiceClient} = require('@google-shopping/datasources').v1beta;

  // Instantiates a client
  const datasourcesClient = new DataSourcesServiceClient();

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

    // Run request
    const response = await datasourcesClient.getDataSource(request);
    console.log(response);
  }

  callGetDataSource();

getDataSource(request, options, callback)

getDataSource(request: protos.google.shopping.merchant.datasources.v1beta.IGetDataSourceRequest, options: CallOptions, callback: Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.IGetDataSourceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetDataSourceRequest
options CallOptions
callback Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.IGetDataSourceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getDataSource(request, callback)

getDataSource(request: protos.google.shopping.merchant.datasources.v1beta.IGetDataSourceRequest, callback: Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.IGetDataSourceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetDataSourceRequest
callback Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.IGetDataSourceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getProjectId()

getProjectId(): Promise<string>;
Returns
Type Description
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
Name Description
callback Callback<string, undefined, undefined>
Returns
Type Description
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

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<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

listDataSources(request, options)

listDataSources(request?: protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.datasources.v1beta.IDataSource[],
        protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesRequest | null,
        protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesResponse
    ]>;

Lists the configurations for data sources for the given account.

Parameters
Name Description
request IListDataSourcesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.datasources.v1beta.IDataSource[], protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesRequest | null, protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listDataSourcesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listDataSources(request, options, callback)

listDataSources(request: protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesRequest, options: CallOptions, callback: PaginationCallback<protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesRequest, protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesResponse | null | undefined, protos.google.shopping.merchant.datasources.v1beta.IDataSource>): void;
Parameters
Name Description
request IListDataSourcesRequest
options CallOptions
callback PaginationCallback<protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesRequest, protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesResponse | null | undefined, protos.google.shopping.merchant.datasources.v1beta.IDataSource>
Returns
Type Description
void

listDataSources(request, callback)

listDataSources(request: protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesRequest, callback: PaginationCallback<protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesRequest, protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesResponse | null | undefined, protos.google.shopping.merchant.datasources.v1beta.IDataSource>): void;
Parameters
Name Description
request IListDataSourcesRequest
callback PaginationCallback<protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesRequest, protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesResponse | null | undefined, protos.google.shopping.merchant.datasources.v1beta.IDataSource>
Returns
Type Description
void

listDataSourcesAsync(request, options)

listDataSourcesAsync(request?: protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesRequest, options?: CallOptions): AsyncIterable<protos.google.shopping.merchant.datasources.v1beta.IDataSource>;

Equivalent to listDataSources, but returns an iterable object.

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

Parameters
Name Description
request IListDataSourcesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.shopping.merchant.datasources.v1beta.IDataSource>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . 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 account to list data sources for.
   *  Format: `accounts/{account}`
   */
  // const parent = 'abc123'
  /**
   *  Optional. The maximum number of data sources to return. The service may
   *  return fewer than this value. The maximum value is 1000; values above 1000
   *  will be coerced to 1000. If unspecified, the maximum number of data sources
   *  will be returned.
   */
  // const pageSize = 1234
  /**
   *  Optional. A page token, received from a previous `ListDataSources` call.
   *  Provide this to retrieve the subsequent page.
   *  When paginating, all other parameters provided to `ListDataSources`
   *  must match the call that provided the page token.
   */
  // const pageToken = 'abc123'

  // Imports the Datasources library
  const {DataSourcesServiceClient} = require('@google-shopping/datasources').v1beta;

  // Instantiates a client
  const datasourcesClient = new DataSourcesServiceClient();

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

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

  callListDataSources();

listDataSourcesStream(request, options)

listDataSourcesStream(request?: protos.google.shopping.merchant.datasources.v1beta.IListDataSourcesRequest, options?: CallOptions): Transform;

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

Parameters
Name Description
request IListDataSourcesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Transform

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

matchAccountFromAccountName(accountName)

matchAccountFromAccountName(accountName: string): string | number;

Parse the account from Account resource.

Parameter
Name Description
accountName string

A fully-qualified path representing Account resource.

Returns
Type Description
string | number

{string} A string representing the account.

matchAccountFromDataSourceName(dataSourceName)

matchAccountFromDataSourceName(dataSourceName: string): string | number;

Parse the account from DataSource resource.

Parameter
Name Description
dataSourceName string

A fully-qualified path representing DataSource resource.

Returns
Type Description
string | number

{string} A string representing the account.

matchDatasourceFromDataSourceName(dataSourceName)

matchDatasourceFromDataSourceName(dataSourceName: string): string | number;

Parse the datasource from DataSource resource.

Parameter
Name Description
dataSourceName string

A fully-qualified path representing DataSource resource.

Returns
Type Description
string | number

{string} A string representing the datasource.

updateDataSource(request, options)

updateDataSource(request?: protos.google.shopping.merchant.datasources.v1beta.IUpdateDataSourceRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.datasources.v1beta.IDataSource,
        (protos.google.shopping.merchant.datasources.v1beta.IUpdateDataSourceRequest | undefined),
        {} | undefined
    ]>;

Updates the existing data source configuration. The fields that are set in the update mask but not provided in the resource will be deleted.

Parameters
Name Description
request IUpdateDataSourceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.datasources.v1beta.IDataSource, (protos.google.shopping.merchant.datasources.v1beta.IUpdateDataSourceRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . 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 data source resource to update.
   */
  // const dataSource = {}
  /**
   *  Required. The list of data source fields to be updated.
   *  Fields specified in the update mask without a value specified in the
   *  body will be deleted from the data source.
   *  Providing special "*" value for full data source replacement is not
   *  supported.
   */
  // const updateMask = {}

  // Imports the Datasources library
  const {DataSourcesServiceClient} = require('@google-shopping/datasources').v1beta;

  // Instantiates a client
  const datasourcesClient = new DataSourcesServiceClient();

  async function callUpdateDataSource() {
    // Construct request
    const request = {
      dataSource,
      updateMask,
    };

    // Run request
    const response = await datasourcesClient.updateDataSource(request);
    console.log(response);
  }

  callUpdateDataSource();

updateDataSource(request, options, callback)

updateDataSource(request: protos.google.shopping.merchant.datasources.v1beta.IUpdateDataSourceRequest, options: CallOptions, callback: Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.IUpdateDataSourceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateDataSourceRequest
options CallOptions
callback Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.IUpdateDataSourceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

updateDataSource(request, callback)

updateDataSource(request: protos.google.shopping.merchant.datasources.v1beta.IUpdateDataSourceRequest, callback: Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.IUpdateDataSourceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateDataSourceRequest
callback Callback<protos.google.shopping.merchant.datasources.v1beta.IDataSource, protos.google.shopping.merchant.datasources.v1beta.IUpdateDataSourceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void