Class v2alpha.ServingConfigServiceClient (3.1.0)

Service for modifying ServingConfig. v2alpha

Package

@google-cloud/retail

Constructors

(constructor)(opts, gaxInstance)

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

Construct an instance of ServingConfigServiceClient.

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

Properties

apiEndpoint

static get apiEndpoint(): string;

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

auth

auth: gax.GoogleAuth;

descriptors

descriptors: Descriptors;

innerApiCalls

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

locationsClient

locationsClient: LocationsClient;

operationsClient

operationsClient: gax.OperationsClient;

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.

servingConfigServiceStub

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

warn

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

Methods

addControl(request, options)

addControl(request?: protos.google.cloud.retail.v2alpha.IAddControlRequest, options?: CallOptions): Promise<[
        protos.google.cloud.retail.v2alpha.IServingConfig,
        protos.google.cloud.retail.v2alpha.IAddControlRequest | undefined,
        {} | undefined
    ]>;

Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.

Parameters
NameDescription
request IAddControlRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.retail.v2alpha.IServingConfig, protos.google.cloud.retail.v2alpha.IAddControlRequest | 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 source ServingConfig resource name . Format:
   *  `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}`
   */
  // const servingConfig = 'abc123'
  /**
   *  Required. The id of the control to apply. Assumed to be in the same catalog
   *  as the serving config - if id is not found a NOT_FOUND error is returned.
   */
  // const controlId = 'abc123'

  // Imports the Retail library
  const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha;

  // Instantiates a client
  const retailClient = new ServingConfigServiceClient();

  async function callAddControl() {
    // Construct request
    const request = {
      servingConfig,
      controlId,
    };

    // Run request
    const response = await retailClient.addControl(request);
    console.log(response);
  }

  callAddControl();

addControl(request, options, callback)

addControl(request: protos.google.cloud.retail.v2alpha.IAddControlRequest, options: CallOptions, callback: Callback<protos.google.cloud.retail.v2alpha.IServingConfig, protos.google.cloud.retail.v2alpha.IAddControlRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IAddControlRequest
options CallOptions
callback Callback<protos.google.cloud.retail.v2alpha.IServingConfig, protos.google.cloud.retail.v2alpha.IAddControlRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

addControl(request, callback)

addControl(request: protos.google.cloud.retail.v2alpha.IAddControlRequest, callback: Callback<protos.google.cloud.retail.v2alpha.IServingConfig, protos.google.cloud.retail.v2alpha.IAddControlRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IAddControlRequest
callback Callback<protos.google.cloud.retail.v2alpha.IServingConfig, protos.google.cloud.retail.v2alpha.IAddControlRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

attributesConfigPath(project, location, catalog)

attributesConfigPath(project: string, location: string, catalog: string): string;

Return a fully-qualified attributesConfig resource name string.

Parameters
NameDescription
project string
location string
catalog string
Returns
TypeDescription
string

{string} Resource name string.

cancelOperation(request, options, callback)

cancelOperation(request: protos.google.longrunning.CancelOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>, callback?: Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>): Promise<protos.google.protobuf.Empty>;

Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an value with a of 1, corresponding to Code.CANCELLED.

Parameters
NameDescription
request CancelOperationRequest

The request object that will be sent.

options CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>

The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Returns
TypeDescription
Promise<protos.google.protobuf.Empty>
Example

const client = longrunning.operationsClient();
await client.cancelOperation({name: ''});

catalogPath(project, location, catalog)

catalogPath(project: string, location: string, catalog: string): string;

Return a fully-qualified catalog resource name string.

Parameters
NameDescription
project string
location string
catalog string
Returns
TypeDescription
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
TypeDescription
Promise<void>

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

completionConfigPath(project, location, catalog)

completionConfigPath(project: string, location: string, catalog: string): string;

Return a fully-qualified completionConfig resource name string.

Parameters
NameDescription
project string
location string
catalog string
Returns
TypeDescription
string

{string} Resource name string.

controlPath(project, location, catalog, control)

controlPath(project: string, location: string, catalog: string, control: string): string;

Return a fully-qualified control resource name string.

Parameters
NameDescription
project string
location string
catalog string
control string
Returns
TypeDescription
string

{string} Resource name string.

createServingConfig(request, options)

createServingConfig(request?: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, options?: CallOptions): Promise<[
        protos.google.cloud.retail.v2alpha.IServingConfig,
        (protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest | undefined),
        {} | undefined
    ]>;

Creates a ServingConfig.

A maximum of 100 s are allowed in a Catalog, otherwise a FAILED_PRECONDITION error is returned.

Parameters
NameDescription
request ICreateServingConfigRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.retail.v2alpha.IServingConfig, (protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest | 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. Full resource name of parent. Format:
   *  `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
   */
  // const parent = 'abc123'
  /**
   *  Required. The ServingConfig to create.
   */
  // const servingConfig = {}
  /**
   *  Required. The ID to use for the ServingConfig, which will become the final
   *  component of the ServingConfig's resource name.
   *  This value should be 4-63 characters, and valid characters
   *  are /[a-z][0-9]-_/.
   */
  // const servingConfigId = 'abc123'

  // Imports the Retail library
  const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha;

  // Instantiates a client
  const retailClient = new ServingConfigServiceClient();

  async function callCreateServingConfig() {
    // Construct request
    const request = {
      parent,
      servingConfig,
      servingConfigId,
    };

    // Run request
    const response = await retailClient.createServingConfig(request);
    console.log(response);
  }

  callCreateServingConfig();

createServingConfig(request, options, callback)

createServingConfig(request: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, options: CallOptions, callback: Callback<protos.google.cloud.retail.v2alpha.IServingConfig, protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateServingConfigRequest
options CallOptions
callback Callback<protos.google.cloud.retail.v2alpha.IServingConfig, protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void