Class v1beta1.RecaptchaEnterpriseServiceV1Beta1Client (5.2.0)

Service to determine the likelihood an event is legitimate. v1beta1

Package

@google-cloud/recaptcha-enterprise

Constructors

(constructor)(opts, gaxInstance)

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

Construct an instance of RecaptchaEnterpriseServiceV1Beta1Client.

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 RecaptchaEnterpriseServiceV1Beta1Client({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;
    };

pathTemplates

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

port

static get port(): number;

The port for this API service.

recaptchaEnterpriseServiceV1Beta1Stub

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

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.

warn

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

Methods

annotateAssessment(request, options)

annotateAssessment(request?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, options?: CallOptions): Promise<[
        protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse,
        (protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest | undefined),
        {} | undefined
    ]>;

Annotates a previously created Assessment to provide additional information on whether the event turned out to be authentic or fradulent.

Parameters
NameDescription
request IAnnotateAssessmentRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, (protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing AnnotateAssessmentResponse. 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 Assessment, in the format
   *  `projects/{project_number}/assessments/{assessment_id}`.
   */
  // const name = 'abc123'
  /**
   *  Optional. The annotation that will be assigned to the Event. This field can
   *  be left empty to provide reasons that apply to an event without concluding
   *  whether the event is legitimate or fraudulent.
   */
  // const annotation = {}
  /**
   *  Optional. Reasons for the annotation that are assigned to the event.
   */
  // const reasons = [1,2,3,4]
  /**
   *  Optional. Unique stable hashed user identifier to apply to the assessment.
   *  This is an alternative to setting the `hashed_account_id` in
   *  `CreateAssessment`, for example, when the account identifier is not yet
   *  known in the initial request. It is recommended that the identifier is
   *  hashed using hmac-sha256 with stable secret.
   */
  // const hashedAccountId = Buffer.from('string')
  /**
   *  Optional. If the assessment is part of a payment transaction, provide
   *  details on payment lifecycle events that occur in the transaction.
   */
  // const transactionEvent = {}

  // Imports the Recaptchaenterprise library
  const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1;

  // Instantiates a client
  const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client();

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

    // Run request
    const response = await recaptchaenterpriseClient.annotateAssessment(request);
    console.log(response);
  }

  callAnnotateAssessment();

annotateAssessment(request, options, callback)

annotateAssessment(request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, options: CallOptions, callback: Callback<protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IAnnotateAssessmentRequest
options CallOptions
callback Callback<protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

annotateAssessment(request, callback)

annotateAssessment(request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, callback: Callback<protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IAnnotateAssessmentRequest
callback Callback<protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

assessmentPath(project, assessment)

assessmentPath(project: string, assessment: string): string;

Return a fully-qualified assessment resource name string.

Parameters
NameDescription
project string
assessment 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.

createAssessment(request, options)

createAssessment(request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, options?: CallOptions): Promise<[
        protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment,
        (protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest | undefined),
        {} | undefined
    ]>;

Creates an Assessment of the likelihood an event is legitimate.

Parameters
NameDescription
request ICreateAssessmentRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, (protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest | 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 project in which the assessment will be created,
   *  in the format `projects/{project_number}`.
   */
  // const parent = 'abc123'
  /**
   *  Required. The assessment details.
   */
  // const assessment = {}

  // Imports the Recaptchaenterprise library
  const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1;

  // Instantiates a client
  const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client();

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

    // Run request
    const response = await recaptchaenterpriseClient.createAssessment(request);
    console.log(response);
  }

  callCreateAssessment();

createAssessment(request, options, callback)

createAssessment(request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, options: CallOptions, callback: Callback<protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateAssessmentRequest
options CallOptions
callback Callback<protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createAssessment(request, callback)

createAssessment(request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, callback: Callback<protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateAssessmentRequest
callback Callback<protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getProjectId()

getProjectId(): Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
NameDescription
callback Callback<string, undefined, undefined>
Returns
TypeDescription
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
TypeDescription
Promise<{ [name: string]: Function; }>

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

matchAssessmentFromAssessmentName(assessmentName)

matchAssessmentFromAssessmentName(assessmentName: string): string | number;

Parse the assessment from Assessment resource.

Parameter
NameDescription
assessmentName string

A fully-qualified path representing Assessment resource.

Returns
TypeDescription
string | number

{string} A string representing the assessment.

matchProjectFromAssessmentName(assessmentName)

matchProjectFromAssessmentName(assessmentName: string): string | number;

Parse the project from Assessment resource.

Parameter
NameDescription
assessmentName string

A fully-qualified path representing Assessment resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromProjectName(projectName)

matchProjectFromProjectName(projectName: string): string | number;

Parse the project from Project resource.

Parameter
NameDescription
projectName string

A fully-qualified path representing Project resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

projectPath(project)

projectPath(project: string): string;

Return a fully-qualified project resource name string.

Parameter
NameDescription
project string
Returns
TypeDescription
string

{string} Resource name string.