"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.CloudTasksClient = void 0;
var gax = _interopRequireWildcard(require("google-gax"));
var _path = _interopRequireDefault(require("path"));
var _url = require("url");
var _jsonHelper = require("../json-helper.cjs");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
/* global window */ // @ts-ignore
// @ts-ignore
var dirname = __dirname;

/**
 * Client JSON configuration object, loaded from
 * `src/v2/cloud_tasks_client_config.json`.
 * This file defines retry strategy and timeouts for all API methods in this library.
 */
var gapicConfig = (0, _jsonHelper.getJSON)(_path["default"].join(dirname, 'cloud_tasks_client_config.json'));
var jsonProtos = (0, _jsonHelper.getJSON)(_path["default"].join(dirname, '..', '..', '..', 'protos/protos.json'));
var version = (0, _jsonHelper.getJSON)(_path["default"].join(dirname, '..', '..', '..', '..', 'package.json')).version;

/**
 *  Cloud Tasks allows developers to manage the execution of background
 *  work in their applications.
 * @class
 * @memberof v2
 */
var CloudTasksClient = exports.CloudTasksClient = /*#__PURE__*/function () {
  /**
   * Construct an instance of CloudTasksClient.
   *
   * @param {object} [options] - The configuration object.
   * The options accepted by the constructor are described in detail
   * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
   * The common options are:
   * @param {object} [options.credentials] - Credentials object.
   * @param {string} [options.credentials.client_email]
   * @param {string} [options.credentials.private_key]
   * @param {string} [options.email] - Account email address. Required when
   *     using a .pem or .p12 keyFilename.
   * @param {string} [options.keyFilename] - 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.
   * @param {number} [options.port] - The port on which to connect to
   *     the remote host.
   * @param {string} [options.projectId] - 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
   *     {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
   *     your project ID will be detected automatically.
   * @param {string} [options.apiEndpoint] - The domain name of the
   *     API remote host.
   * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
   *     Follows the structure of {@link gapicConfig}.
   * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
   *     Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
   *     For more information, please check the
   *     {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
   * @param {gax} [gaxInstance]: 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 CloudTasksClient({fallback: 'rest'}, gax);
   *     ```
   */
  function CloudTasksClient(opts, gaxInstance) {
    var _opts, _opts2, _opts3, _opts4, _ref, _opts$universeDomain, _opts5, _opts6, _opts7, _opts8, _opts9, _opts10, _opts11, _opts$clientConfig, _opts12, _opts$fallback, _opts13, _window;
    _classCallCheck(this, CloudTasksClient);
    _defineProperty(this, "_terminated", false);
    _defineProperty(this, "_opts", void 0);
    _defineProperty(this, "_providedCustomServicePath", void 0);
    _defineProperty(this, "_gaxModule", void 0);
    _defineProperty(this, "_gaxGrpc", void 0);
    _defineProperty(this, "_protos", void 0);
    _defineProperty(this, "_defaults", void 0);
    _defineProperty(this, "_universeDomain", void 0);
    _defineProperty(this, "_servicePath", void 0);
    _defineProperty(this, "auth", void 0);
    _defineProperty(this, "descriptors", {
      page: {},
      stream: {},
      longrunning: {},
      batching: {}
    });
    _defineProperty(this, "warn", void 0);
    _defineProperty(this, "innerApiCalls", void 0);
    _defineProperty(this, "locationsClient", void 0);
    _defineProperty(this, "pathTemplates", void 0);
    _defineProperty(this, "cloudTasksStub", void 0);
    // Ensure that options include all the required fields.
    var staticMembers = this.constructor;
    if ((_opts = opts) !== null && _opts !== void 0 && _opts.universe_domain && (_opts2 = opts) !== null && _opts2 !== void 0 && _opts2.universeDomain && ((_opts3 = opts) === null || _opts3 === void 0 ? void 0 : _opts3.universe_domain) !== ((_opts4 = opts) === null || _opts4 === void 0 ? void 0 : _opts4.universeDomain)) {
      throw new Error('Please set either universe_domain or universeDomain, but not both.');
    }
    this._universeDomain = (_ref = (_opts$universeDomain = (_opts5 = opts) === null || _opts5 === void 0 ? void 0 : _opts5.universeDomain) !== null && _opts$universeDomain !== void 0 ? _opts$universeDomain : (_opts6 = opts) === null || _opts6 === void 0 ? void 0 : _opts6.universe_domain) !== null && _ref !== void 0 ? _ref : 'googleapis.com';
    this._servicePath = 'cloudtasks.' + this._universeDomain;
    var servicePath = ((_opts7 = opts) === null || _opts7 === void 0 ? void 0 : _opts7.servicePath) || ((_opts8 = opts) === null || _opts8 === void 0 ? void 0 : _opts8.apiEndpoint) || this._servicePath;
    this._providedCustomServicePath = !!((_opts9 = opts) !== null && _opts9 !== void 0 && _opts9.servicePath || (_opts10 = opts) !== null && _opts10 !== void 0 && _opts10.apiEndpoint);
    var port = ((_opts11 = opts) === null || _opts11 === void 0 ? void 0 : _opts11.port) || staticMembers.port;
    var clientConfig = (_opts$clientConfig = (_opts12 = opts) === null || _opts12 === void 0 ? void 0 : _opts12.clientConfig) !== null && _opts$clientConfig !== void 0 ? _opts$clientConfig : {};
    var fallback = (_opts$fallback = (_opts13 = opts) === null || _opts13 === void 0 ? void 0 : _opts13.fallback) !== null && _opts$fallback !== void 0 ? _opts$fallback : typeof window !== 'undefined' && typeof ((_window = window) === null || _window === void 0 ? void 0 : _window.fetch) === 'function';
    opts = Object.assign({
      servicePath: servicePath,
      port: port,
      clientConfig: clientConfig,
      fallback: fallback
    }, opts);

    // Request numeric enum values if REST transport is used.
    opts.numericEnums = true;

    // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
    if (servicePath !== this._servicePath && !('scopes' in opts)) {
      opts['scopes'] = staticMembers.scopes;
    }

    // Load google-gax module synchronously if needed
    if (!gaxInstance) {
      gaxInstance = gax;
    }

    // Choose either gRPC or proto-over-HTTP implementation of google-gax.
    this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;

    // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
    this._gaxGrpc = new this._gaxModule.GrpcClient(opts);

    // Save options to use in initialize() method.
    this._opts = opts;

    // Save the auth object to the client, for use by other methods.
    this.auth = this._gaxGrpc.auth;

    // Set useJWTAccessWithScope on the auth object.
    this.auth.useJWTAccessWithScope = true;

    // Set defaultServicePath on the auth object.
    this.auth.defaultServicePath = this._servicePath;

    // Set the default scopes in auth client if needed.
    if (servicePath === this._servicePath) {
      this.auth.defaultScopes = staticMembers.scopes;
    }
    this.locationsClient = new this._gaxModule.LocationsClient(this._gaxGrpc, opts);

    // Determine the client header string.
    var clientHeader = ["gax/".concat(this._gaxModule.version), "gapic/".concat(version)];
    if (typeof process !== 'undefined' && 'versions' in process) {
      clientHeader.push("gl-node/".concat(process.versions.node));
    } else {
      clientHeader.push("gl-web/".concat(this._gaxModule.version));
    }
    if (!opts.fallback) {
      clientHeader.push("grpc/".concat(this._gaxGrpc.grpcVersion));
    } else if (opts.fallback === 'rest') {
      clientHeader.push("rest/".concat(this._gaxGrpc.grpcVersion));
    }
    if (opts.libName && opts.libVersion) {
      clientHeader.push("".concat(opts.libName, "/").concat(opts.libVersion));
    }
    // Add ESM headers
    var isEsm = false;
    if ((opts.libVersion || version) && isEsm) {
      var _opts$libVersion;
      clientHeader.push("".concat((_opts$libVersion = opts.libVersion) !== null && _opts$libVersion !== void 0 ? _opts$libVersion : version, "-esm"));
    }

    // Load the applicable protos.
    this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);

    // This API contains "path templates"; forward-slash-separated
    // identifiers to uniquely identify resources within the API.
    // Create useful helper objects for these.
    this.pathTemplates = {
      locationPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}'),
      projectPathTemplate: new this._gaxModule.PathTemplate('projects/{project}'),
      queuePathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/queues/{queue}'),
      taskPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/queues/{queue}/tasks/{task}')
    };

    // Some of the methods on this service return "paged" results,
    // (e.g. 50 results at a time, with tokens to get subsequent
    // pages). Denote the keys used for pagination and results.
    this.descriptors.page = {
      listQueues: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'queues'),
      listTasks: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks')
    };

    // Put together the default options sent with requests.
    this._defaults = this._gaxGrpc.constructSettings('google.cloud.tasks.v2.CloudTasks', gapicConfig, opts.clientConfig || {}, {
      'x-goog-api-client': clientHeader.join(' ')
    });

    // Set up a dictionary of "inner API calls"; the core implementation
    // of calling the API is handled in `google-gax`, with this code
    // merely providing the destination and request information.
    this.innerApiCalls = {};

    // Add a warn function to the client constructor so it can be easily tested.
    this.warn = this._gaxModule.warn;
  }

  /**
   * 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 {Promise} A promise that resolves to an authenticated service stub.
   */
  _createClass(CloudTasksClient, [{
    key: "initialize",
    value: function initialize() {
      var _this = this;
      // If the client stub promise is already initialized, return immediately.
      if (this.cloudTasksStub) {
        return this.cloudTasksStub;
      }

      // Put together the "service stub" for
      // google.cloud.tasks.v2.CloudTasks.
      this.cloudTasksStub = this._gaxGrpc.createStub(this._opts.fallback ? this._protos.lookupService('google.cloud.tasks.v2.CloudTasks') :
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      this._protos.google.cloud.tasks.v2.CloudTasks, this._opts, this._providedCustomServicePath);

      // Iterate over each of the methods that the service provides
      // and create an API call method for each.
      var cloudTasksStubMethods = ['listQueues', 'getQueue', 'createQueue', 'updateQueue', 'deleteQueue', 'purgeQueue', 'pauseQueue', 'resumeQueue', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions', 'listTasks', 'getTask', 'createTask', 'deleteTask', 'runTask'];
      var _loop = function _loop() {
        var methodName = _cloudTasksStubMethod[_i];
        var callPromise = _this.cloudTasksStub.then(function (stub) {
          return function () {
            if (_this._terminated) {
              return Promise.reject('The client has already been closed.');
            }
            var func = stub[methodName];
            for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
              args[_key] = arguments[_key];
            }
            return func.apply(stub, args);
          };
        }, function (err) {
          return function () {
            throw err;
          };
        });
        var descriptor = _this.descriptors.page[methodName] || undefined;
        var apiCall = _this._gaxModule.createApiCall(callPromise, _this._defaults[methodName], descriptor, _this._opts.fallback);
        _this.innerApiCalls[methodName] = apiCall;
      };
      for (var _i = 0, _cloudTasksStubMethod = cloudTasksStubMethods; _i < _cloudTasksStubMethod.length; _i++) {
        _loop();
      }
      return this.cloudTasksStub;
    }

    /**
     * The DNS address for this API service.
     * @deprecated Use the apiEndpoint method of the client instance.
     * @returns {string} The DNS address for this service.
     */
  }, {
    key: "apiEndpoint",
    get:
    /**
     * The DNS address for this API service.
     * @returns {string} The DNS address for this service.
     */
    function get() {
      return this._servicePath;
    }
  }, {
    key: "universeDomain",
    get: function get() {
      return this._universeDomain;
    }

    /**
     * The port for this API service.
     * @returns {number} The default port for this service.
     */
  }, {
    key: "getProjectId",
    value:
    /**
     * Return the project ID used by this class.
     * @returns {Promise} A promise that resolves to string containing the project ID.
     */
    function getProjectId(callback) {
      if (callback) {
        this.auth.getProjectId(callback);
        return;
      }
      return this.auth.getProjectId();
    }

    // -------------------
    // -- Service calls --
    // -------------------
    /**
     * Gets a queue.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.name
     *   Required. The resource name of the queue. For example:
     *   `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.cloud.tasks.v2.Queue|Queue}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.get_queue.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_GetQueue_async
     */
  }, {
    key: "getQueue",
    value: function getQueue(request, optionsOrCallback, callback) {
      var _request$name;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        name: (_request$name = request.name) !== null && _request$name !== void 0 ? _request$name : ''
      });
      this.initialize();
      return this.innerApiCalls.getQueue(request, options, callback);
    }
    /**
     * Creates a queue.
     *
     * Queues created with this method allow tasks to live for a maximum of 31
     * days. After a task is 31 days old, the task will be deleted regardless of
     * whether it was dispatched or not.
     *
     * WARNING: Using this method may have unintended side effects if you are
     * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
     * Read
     * [Overview of Queue Management and
     * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
     * this method.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.parent
     *   Required. The location name in which the queue will be created.
     *   For example: `projects/PROJECT_ID/locations/LOCATION_ID`
     *
     *   The list of allowed locations can be obtained by calling Cloud
     *   Tasks' implementation of
     *   {@link protos.google.cloud.location.Locations.ListLocations|ListLocations}.
     * @param {google.cloud.tasks.v2.Queue} request.queue
     *   Required. The queue to create.
     *
     *   {@link protos.google.cloud.tasks.v2.Queue.name|Queue's name} cannot be the same as an
     *   existing queue.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.cloud.tasks.v2.Queue|Queue}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.create_queue.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_CreateQueue_async
     */
  }, {
    key: "createQueue",
    value: function createQueue(request, optionsOrCallback, callback) {
      var _request$parent;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        parent: (_request$parent = request.parent) !== null && _request$parent !== void 0 ? _request$parent : ''
      });
      this.initialize();
      return this.innerApiCalls.createQueue(request, options, callback);
    }
    /**
     * Updates a queue.
     *
     * This method creates the queue if it does not exist and updates
     * the queue if it does exist.
     *
     * Queues created with this method allow tasks to live for a maximum of 31
     * days. After a task is 31 days old, the task will be deleted regardless of
     * whether it was dispatched or not.
     *
     * WARNING: Using this method may have unintended side effects if you are
     * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
     * Read
     * [Overview of Queue Management and
     * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
     * this method.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {google.cloud.tasks.v2.Queue} request.queue
     *   Required. The queue to create or update.
     *
     *   The queue's {@link protos.google.cloud.tasks.v2.Queue.name|name} must be specified.
     *
     *   Output only fields cannot be modified using UpdateQueue.
     *   Any value specified for an output only field will be ignored.
     *   The queue's {@link protos.google.cloud.tasks.v2.Queue.name|name} cannot be changed.
     * @param {google.protobuf.FieldMask} request.updateMask
     *   A mask used to specify which fields of the queue are being updated.
     *
     *   If empty, then all fields will be updated.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.cloud.tasks.v2.Queue|Queue}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.update_queue.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_UpdateQueue_async
     */
  }, {
    key: "updateQueue",
    value: function updateQueue(request, optionsOrCallback, callback) {
      var _name;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        'queue.name': (_name = request.queue.name) !== null && _name !== void 0 ? _name : ''
      });
      this.initialize();
      return this.innerApiCalls.updateQueue(request, options, callback);
    }
    /**
     * Deletes a queue.
     *
     * This command will delete the queue even if it has tasks in it.
     *
     * Note: If you delete a queue, a queue with the same name can't be created
     * for 7 days.
     *
     * WARNING: Using this method may have unintended side effects if you are
     * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
     * Read
     * [Overview of Queue Management and
     * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
     * this method.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.name
     *   Required. The queue name. For example:
     *   `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.delete_queue.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_DeleteQueue_async
     */
  }, {
    key: "deleteQueue",
    value: function deleteQueue(request, optionsOrCallback, callback) {
      var _request$name2;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        name: (_request$name2 = request.name) !== null && _request$name2 !== void 0 ? _request$name2 : ''
      });
      this.initialize();
      return this.innerApiCalls.deleteQueue(request, options, callback);
    }
    /**
     * Purges a queue by deleting all of its tasks.
     *
     * All tasks created before this method is called are permanently deleted.
     *
     * Purge operations can take up to one minute to take effect. Tasks
     * might be dispatched before the purge takes effect. A purge is irreversible.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.name
     *   Required. The queue name. For example:
     *   `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.cloud.tasks.v2.Queue|Queue}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.purge_queue.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_PurgeQueue_async
     */
  }, {
    key: "purgeQueue",
    value: function purgeQueue(request, optionsOrCallback, callback) {
      var _request$name3;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        name: (_request$name3 = request.name) !== null && _request$name3 !== void 0 ? _request$name3 : ''
      });
      this.initialize();
      return this.innerApiCalls.purgeQueue(request, options, callback);
    }
    /**
     * Pauses the queue.
     *
     * If a queue is paused then the system will stop dispatching tasks
     * until the queue is resumed via
     * {@link protos.google.cloud.tasks.v2.CloudTasks.ResumeQueue|ResumeQueue}. Tasks can
     * still be added when the queue is paused. A queue is paused if its
     * {@link protos.google.cloud.tasks.v2.Queue.state|state} is
     * {@link protos.google.cloud.tasks.v2.Queue.State.PAUSED|PAUSED}.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.name
     *   Required. The queue name. For example:
     *   `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.cloud.tasks.v2.Queue|Queue}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.pause_queue.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_PauseQueue_async
     */
  }, {
    key: "pauseQueue",
    value: function pauseQueue(request, optionsOrCallback, callback) {
      var _request$name4;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        name: (_request$name4 = request.name) !== null && _request$name4 !== void 0 ? _request$name4 : ''
      });
      this.initialize();
      return this.innerApiCalls.pauseQueue(request, options, callback);
    }
    /**
     * Resume a queue.
     *
     * This method resumes a queue after it has been
     * {@link protos.google.cloud.tasks.v2.Queue.State.PAUSED|PAUSED} or
     * {@link protos.google.cloud.tasks.v2.Queue.State.DISABLED|DISABLED}. The state of a
     * queue is stored in the queue's {@link protos.google.cloud.tasks.v2.Queue.state|state};
     * after calling this method it will be set to
     * {@link protos.google.cloud.tasks.v2.Queue.State.RUNNING|RUNNING}.
     *
     * WARNING: Resuming many high-QPS queues at the same time can
     * lead to target overloading. If you are resuming high-QPS
     * queues, follow the 500/50/5 pattern described in
     * [Managing Cloud Tasks Scaling
     * Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.name
     *   Required. The queue name. For example:
     *   `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.cloud.tasks.v2.Queue|Queue}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.resume_queue.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_ResumeQueue_async
     */
  }, {
    key: "resumeQueue",
    value: function resumeQueue(request, optionsOrCallback, callback) {
      var _request$name5;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        name: (_request$name5 = request.name) !== null && _request$name5 !== void 0 ? _request$name5 : ''
      });
      this.initialize();
      return this.innerApiCalls.resumeQueue(request, options, callback);
    }
    /**
     * Gets the access control policy for a {@link protos.google.cloud.tasks.v2.Queue|Queue}.
     * Returns an empty policy if the resource exists and does not have a policy
     * set.
     *
     * Authorization requires the following
     * [Google IAM](https://cloud.google.com/iam) permission on the specified
     * resource parent:
     *
     * * `cloudtasks.queues.getIamPolicy`
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.resource
     *   REQUIRED: The resource for which the policy is being requested.
     *   See the operation documentation for the appropriate value for this field.
     * @param {google.iam.v1.GetPolicyOptions} request.options
     *   OPTIONAL: A `GetPolicyOptions` object for specifying options to
     *   `GetIamPolicy`.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.get_iam_policy.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_GetIamPolicy_async
     */
  }, {
    key: "getIamPolicy",
    value: function getIamPolicy(request, optionsOrCallback, callback) {
      var _request$resource;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        resource: (_request$resource = request.resource) !== null && _request$resource !== void 0 ? _request$resource : ''
      });
      this.initialize();
      return this.innerApiCalls.getIamPolicy(request, options, callback);
    }
    /**
     * Sets the access control policy for a {@link protos.google.cloud.tasks.v2.Queue|Queue}.
     * Replaces any existing policy.
     *
     * Note: The Cloud Console does not check queue-level IAM permissions yet.
     * Project-level permissions are required to use the Cloud Console.
     *
     * Authorization requires the following
     * [Google IAM](https://cloud.google.com/iam) permission on the specified
     * resource parent:
     *
     * * `cloudtasks.queues.setIamPolicy`
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.resource
     *   REQUIRED: The resource for which the policy is being specified.
     *   See the operation documentation for the appropriate value for this field.
     * @param {google.iam.v1.Policy} request.policy
     *   REQUIRED: The complete policy to be applied to the `resource`. The size of
     *   the policy is limited to a few 10s of KB. An empty policy is a
     *   valid policy but certain Cloud Platform services (such as Projects)
     *   might reject them.
     * @param {google.protobuf.FieldMask} request.updateMask
     *   OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
     *   the fields in the mask will be modified. If no mask is provided, the
     *   following default mask is used:
     *
     *   `paths: "bindings, etag"`
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.set_iam_policy.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_SetIamPolicy_async
     */
  }, {
    key: "setIamPolicy",
    value: function setIamPolicy(request, optionsOrCallback, callback) {
      var _request$resource2;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        resource: (_request$resource2 = request.resource) !== null && _request$resource2 !== void 0 ? _request$resource2 : ''
      });
      this.initialize();
      return this.innerApiCalls.setIamPolicy(request, options, callback);
    }
    /**
     * Returns permissions that a caller has on a
     * {@link protos.google.cloud.tasks.v2.Queue|Queue}. If the resource does not exist, this
     * will return an empty set of permissions, not a
     * {@link protos.google.rpc.Code.NOT_FOUND|NOT_FOUND} error.
     *
     * Note: This operation is designed to be used for building permission-aware
     * UIs and command-line tools, not for authorization checking. This operation
     * may "fail open" without warning.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.resource
     *   REQUIRED: The resource for which the policy detail is being requested.
     *   See the operation documentation for the appropriate value for this field.
     * @param {string[]} request.permissions
     *   The set of permissions to check for the `resource`. Permissions with
     *   wildcards (such as '*' or 'storage.*') are not allowed. For more
     *   information see
     *   [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.test_iam_permissions.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_TestIamPermissions_async
     */
  }, {
    key: "testIamPermissions",
    value: function testIamPermissions(request, optionsOrCallback, callback) {
      var _request$resource3;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        resource: (_request$resource3 = request.resource) !== null && _request$resource3 !== void 0 ? _request$resource3 : ''
      });
      this.initialize();
      return this.innerApiCalls.testIamPermissions(request, options, callback);
    }
    /**
     * Gets a task.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.name
     *   Required. The task name. For example:
     *   `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
     * @param {google.cloud.tasks.v2.Task.View} request.responseView
     *   The response_view specifies which subset of the
     *   {@link protos.google.cloud.tasks.v2.Task|Task} will be returned.
     *
     *   By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC};
     *   not all information is retrieved by default because some data, such as
     *   payloads, might be desirable to return only when needed because
     *   of its large size or because of the sensitivity of data that it
     *   contains.
     *
     *   Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires
     *   `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
     *   permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.cloud.tasks.v2.Task|Task}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.get_task.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_GetTask_async
     */
  }, {
    key: "getTask",
    value: function getTask(request, optionsOrCallback, callback) {
      var _request$name6;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        name: (_request$name6 = request.name) !== null && _request$name6 !== void 0 ? _request$name6 : ''
      });
      this.initialize();
      return this.innerApiCalls.getTask(request, options, callback);
    }
    /**
     * Creates a task and adds it to a queue.
     *
     * Tasks cannot be updated after creation; there is no UpdateTask command.
     *
     * * The maximum task size is 100KB.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.parent
     *   Required. The queue name. For example:
     *   `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
     *
     *   The queue must already exist.
     * @param {google.cloud.tasks.v2.Task} request.task
     *   Required. The task to add.
     *
     *   Task names have the following format:
     *   `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`.
     *   The user can optionally specify a task
     *   {@link protos.google.cloud.tasks.v2.Task.name|name}. If a name is not specified then
     *   the system will generate a random unique task id, which will be set in the
     *   task returned in the {@link protos.google.cloud.tasks.v2.Task.name|response}.
     *
     *   If {@link protos.google.cloud.tasks.v2.Task.schedule_time|schedule_time} is not set or
     *   is in the past then Cloud Tasks will set it to the current time.
     *
     *   Task De-duplication:
     *
     *   Explicitly specifying a task ID enables task de-duplication.  If
     *   a task's ID is identical to that of an existing task or a task
     *   that was deleted or executed recently then the call will fail
     *   with {@link protos.google.rpc.Code.ALREADY_EXISTS|ALREADY_EXISTS}.
     *   If the task's queue was created using Cloud Tasks, then another task with
     *   the same name can't be created for ~1hour after the original task was
     *   deleted or executed. If the task's queue was created using queue.yaml or
     *   queue.xml, then another task with the same name can't be created
     *   for ~9days after the original task was deleted or executed.
     *
     *   Because there is an extra lookup cost to identify duplicate task
     *   names, these {@link protos.google.cloud.tasks.v2.CloudTasks.CreateTask|CreateTask}
     *   calls have significantly increased latency. Using hashed strings for the
     *   task id or for the prefix of the task id is recommended. Choosing task ids
     *   that are sequential or have sequential prefixes, for example using a
     *   timestamp, causes an increase in latency and error rates in all
     *   task commands. The infrastructure relies on an approximately
     *   uniform distribution of task ids to store and serve tasks
     *   efficiently.
     * @param {google.cloud.tasks.v2.Task.View} request.responseView
     *   The response_view specifies which subset of the
     *   {@link protos.google.cloud.tasks.v2.Task|Task} will be returned.
     *
     *   By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC};
     *   not all information is retrieved by default because some data, such as
     *   payloads, might be desirable to return only when needed because
     *   of its large size or because of the sensitivity of data that it
     *   contains.
     *
     *   Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires
     *   `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
     *   permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.cloud.tasks.v2.Task|Task}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.create_task.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_CreateTask_async
     */
  }, {
    key: "createTask",
    value: function createTask(request, optionsOrCallback, callback) {
      var _request$parent2;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        parent: (_request$parent2 = request.parent) !== null && _request$parent2 !== void 0 ? _request$parent2 : ''
      });
      this.initialize();
      return this.innerApiCalls.createTask(request, options, callback);
    }
    /**
     * Deletes a task.
     *
     * A task can be deleted if it is scheduled or dispatched. A task
     * cannot be deleted if it has executed successfully or permanently
     * failed.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.name
     *   Required. The task name. For example:
     *   `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.protobuf.Empty|Empty}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.delete_task.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_DeleteTask_async
     */
  }, {
    key: "deleteTask",
    value: function deleteTask(request, optionsOrCallback, callback) {
      var _request$name7;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        name: (_request$name7 = request.name) !== null && _request$name7 !== void 0 ? _request$name7 : ''
      });
      this.initialize();
      return this.innerApiCalls.deleteTask(request, options, callback);
    }
    /**
     * Forces a task to run now.
     *
     * When this method is called, Cloud Tasks will dispatch the task, even if
     * the task is already running, the queue has reached its
     * {@link protos.google.cloud.tasks.v2.RateLimits|RateLimits} or is
     * {@link protos.google.cloud.tasks.v2.Queue.State.PAUSED|PAUSED}.
     *
     * This command is meant to be used for manual debugging. For
     * example, {@link protos.google.cloud.tasks.v2.CloudTasks.RunTask|RunTask} can be used to
     * retry a failed task after a fix has been made or to manually force a task
     * to be dispatched now.
     *
     * The dispatched task is returned. That is, the task that is returned
     * contains the {@link protos.Task.status|status} after the task is dispatched but
     * before the task is received by its target.
     *
     * If Cloud Tasks receives a successful response from the task's
     * target, then the task will be deleted; otherwise the task's
     * {@link protos.google.cloud.tasks.v2.Task.schedule_time|schedule_time} will be reset to
     * the time that {@link protos.google.cloud.tasks.v2.CloudTasks.RunTask|RunTask} was
     * called plus the retry delay specified in the queue's
     * {@link protos.google.cloud.tasks.v2.RetryConfig|RetryConfig}.
     *
     * {@link protos.google.cloud.tasks.v2.CloudTasks.RunTask|RunTask} returns
     * {@link protos.google.rpc.Code.NOT_FOUND|NOT_FOUND} when it is called on a
     * task that has already succeeded or permanently failed.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.name
     *   Required. The task name. For example:
     *   `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
     * @param {google.cloud.tasks.v2.Task.View} request.responseView
     *   The response_view specifies which subset of the
     *   {@link protos.google.cloud.tasks.v2.Task|Task} will be returned.
     *
     *   By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC};
     *   not all information is retrieved by default because some data, such as
     *   payloads, might be desirable to return only when needed because
     *   of its large size or because of the sensitivity of data that it
     *   contains.
     *
     *   Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires
     *   `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
     *   permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link protos.google.cloud.tasks.v2.Task|Task}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.run_task.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_RunTask_async
     */
  }, {
    key: "runTask",
    value: function runTask(request, optionsOrCallback, callback) {
      var _request$name8;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        name: (_request$name8 = request.name) !== null && _request$name8 !== void 0 ? _request$name8 : ''
      });
      this.initialize();
      return this.innerApiCalls.runTask(request, options, callback);
    }

    /**
     * Lists queues.
     *
     * Queues are returned in lexicographical order.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.parent
     *   Required. The location name.
     *   For example: `projects/PROJECT_ID/locations/LOCATION_ID`
     * @param {string} request.filter
     *   `filter` can be used to specify a subset of queues. Any
     *   {@link protos.google.cloud.tasks.v2.Queue|Queue} field can be used as a filter and
     *   several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The
     *   filter syntax is the same as described in [Stackdriver's Advanced Logs
     *   Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
     *
     *   Sample filter "state: PAUSED".
     *
     *   Note that using filters might cause fewer queues than the
     *   requested page_size to be returned.
     * @param {number} request.pageSize
     *   Requested page size.
     *
     *   The maximum page size is 9800. If unspecified, the page size will
     *   be the maximum. Fewer queues than requested might be returned,
     *   even if more queues exist; use the
     *   {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token}
     *   in the response to determine if more queues exist.
     * @param {string} request.pageToken
     *   A token identifying the page of results to return.
     *
     *   To request the first page results, page_token must be empty. To
     *   request the next page of results, page_token must be the value of
     *   {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token}
     *   returned from the previous call to
     *   {@link protos.google.cloud.tasks.v2.CloudTasks.ListQueues|ListQueues} method. It is an
     *   error to switch the value of the
     *   {@link protos.google.cloud.tasks.v2.ListQueuesRequest.filter|filter} while iterating
     *   through pages.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is Array of {@link protos.google.cloud.tasks.v2.Queue|Queue}.
     *   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 `listQueuesAsync()`
     *   method described below for async iteration which you can stop as needed.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
     *   for more details and examples.
     */
  }, {
    key: "listQueues",
    value: function listQueues(request, optionsOrCallback, callback) {
      var _request$parent3;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        parent: (_request$parent3 = request.parent) !== null && _request$parent3 !== void 0 ? _request$parent3 : ''
      });
      this.initialize();
      return this.innerApiCalls.listQueues(request, options, callback);
    }

    /**
     * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.parent
     *   Required. The location name.
     *   For example: `projects/PROJECT_ID/locations/LOCATION_ID`
     * @param {string} request.filter
     *   `filter` can be used to specify a subset of queues. Any
     *   {@link protos.google.cloud.tasks.v2.Queue|Queue} field can be used as a filter and
     *   several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The
     *   filter syntax is the same as described in [Stackdriver's Advanced Logs
     *   Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
     *
     *   Sample filter "state: PAUSED".
     *
     *   Note that using filters might cause fewer queues than the
     *   requested page_size to be returned.
     * @param {number} request.pageSize
     *   Requested page size.
     *
     *   The maximum page size is 9800. If unspecified, the page size will
     *   be the maximum. Fewer queues than requested might be returned,
     *   even if more queues exist; use the
     *   {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token}
     *   in the response to determine if more queues exist.
     * @param {string} request.pageToken
     *   A token identifying the page of results to return.
     *
     *   To request the first page results, page_token must be empty. To
     *   request the next page of results, page_token must be the value of
     *   {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token}
     *   returned from the previous call to
     *   {@link protos.google.cloud.tasks.v2.CloudTasks.ListQueues|ListQueues} method. It is an
     *   error to switch the value of the
     *   {@link protos.google.cloud.tasks.v2.ListQueuesRequest.filter|filter} while iterating
     *   through pages.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Stream}
     *   An object stream which emits an object representing {@link protos.google.cloud.tasks.v2.Queue|Queue} 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 `listQueuesAsync()`
     *   method described below for async iteration which you can stop as needed.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
     *   for more details and examples.
     */
  }, {
    key: "listQueuesStream",
    value: function listQueuesStream(request, options) {
      var _request$parent4;
      request = request || {};
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        parent: (_request$parent4 = request.parent) !== null && _request$parent4 !== void 0 ? _request$parent4 : ''
      });
      var defaultCallSettings = this._defaults['listQueues'];
      var callSettings = defaultCallSettings.merge(options);
      this.initialize();
      return this.descriptors.page.listQueues.createStream(this.innerApiCalls.listQueues, request, callSettings);
    }

    /**
     * Equivalent to `listQueues`, but returns an iterable object.
     *
     * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.parent
     *   Required. The location name.
     *   For example: `projects/PROJECT_ID/locations/LOCATION_ID`
     * @param {string} request.filter
     *   `filter` can be used to specify a subset of queues. Any
     *   {@link protos.google.cloud.tasks.v2.Queue|Queue} field can be used as a filter and
     *   several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The
     *   filter syntax is the same as described in [Stackdriver's Advanced Logs
     *   Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
     *
     *   Sample filter "state: PAUSED".
     *
     *   Note that using filters might cause fewer queues than the
     *   requested page_size to be returned.
     * @param {number} request.pageSize
     *   Requested page size.
     *
     *   The maximum page size is 9800. If unspecified, the page size will
     *   be the maximum. Fewer queues than requested might be returned,
     *   even if more queues exist; use the
     *   {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token}
     *   in the response to determine if more queues exist.
     * @param {string} request.pageToken
     *   A token identifying the page of results to return.
     *
     *   To request the first page results, page_token must be empty. To
     *   request the next page of results, page_token must be the value of
     *   {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token}
     *   returned from the previous call to
     *   {@link protos.google.cloud.tasks.v2.CloudTasks.ListQueues|ListQueues} method. It is an
     *   error to switch the value of the
     *   {@link protos.google.cloud.tasks.v2.ListQueuesRequest.filter|filter} while iterating
     *   through pages.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Object}
     *   An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
     *   When you iterate the returned iterable, each element will be an object representing
     *   {@link protos.google.cloud.tasks.v2.Queue|Queue}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.list_queues.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_ListQueues_async
     */
  }, {
    key: "listQueuesAsync",
    value: function listQueuesAsync(request, options) {
      var _request$parent5;
      request = request || {};
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        parent: (_request$parent5 = request.parent) !== null && _request$parent5 !== void 0 ? _request$parent5 : ''
      });
      var defaultCallSettings = this._defaults['listQueues'];
      var callSettings = defaultCallSettings.merge(options);
      this.initialize();
      return this.descriptors.page.listQueues.asyncIterate(this.innerApiCalls['listQueues'], request, callSettings);
    }
    /**
     * Lists the tasks in a queue.
     *
     * By default, only the {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC} view is
     * retrieved due to performance considerations;
     * {@link protos.google.cloud.tasks.v2.ListTasksRequest.response_view|response_view}
     * controls the subset of information which is returned.
     *
     * The tasks may be returned in any order. The ordering may change at any
     * time.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.parent
     *   Required. The queue name. For example:
     *   `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
     * @param {google.cloud.tasks.v2.Task.View} request.responseView
     *   The response_view specifies which subset of the
     *   {@link protos.google.cloud.tasks.v2.Task|Task} will be returned.
     *
     *   By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC};
     *   not all information is retrieved by default because some data, such as
     *   payloads, might be desirable to return only when needed because
     *   of its large size or because of the sensitivity of data that it
     *   contains.
     *
     *   Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires
     *   `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
     *   permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource.
     * @param {number} request.pageSize
     *   Maximum page size.
     *
     *   Fewer tasks than requested might be returned, even if more tasks exist; use
     *   {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token}
     *   in the response to determine if more tasks exist.
     *
     *   The maximum page size is 1000. If unspecified, the page size will be the
     *   maximum.
     * @param {string} request.pageToken
     *   A token identifying the page of results to return.
     *
     *   To request the first page results, page_token must be empty. To
     *   request the next page of results, page_token must be the value of
     *   {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token}
     *   returned from the previous call to
     *   {@link protos.google.cloud.tasks.v2.CloudTasks.ListTasks|ListTasks} method.
     *
     *   The page token is valid for only 2 hours.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is Array of {@link protos.google.cloud.tasks.v2.Task|Task}.
     *   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 `listTasksAsync()`
     *   method described below for async iteration which you can stop as needed.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
     *   for more details and examples.
     */
  }, {
    key: "listTasks",
    value: function listTasks(request, optionsOrCallback, callback) {
      var _request$parent6;
      request = request || {};
      var options;
      if (typeof optionsOrCallback === 'function' && callback === undefined) {
        callback = optionsOrCallback;
        options = {};
      } else {
        options = optionsOrCallback;
      }
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        parent: (_request$parent6 = request.parent) !== null && _request$parent6 !== void 0 ? _request$parent6 : ''
      });
      this.initialize();
      return this.innerApiCalls.listTasks(request, options, callback);
    }

    /**
     * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.parent
     *   Required. The queue name. For example:
     *   `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
     * @param {google.cloud.tasks.v2.Task.View} request.responseView
     *   The response_view specifies which subset of the
     *   {@link protos.google.cloud.tasks.v2.Task|Task} will be returned.
     *
     *   By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC};
     *   not all information is retrieved by default because some data, such as
     *   payloads, might be desirable to return only when needed because
     *   of its large size or because of the sensitivity of data that it
     *   contains.
     *
     *   Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires
     *   `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
     *   permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource.
     * @param {number} request.pageSize
     *   Maximum page size.
     *
     *   Fewer tasks than requested might be returned, even if more tasks exist; use
     *   {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token}
     *   in the response to determine if more tasks exist.
     *
     *   The maximum page size is 1000. If unspecified, the page size will be the
     *   maximum.
     * @param {string} request.pageToken
     *   A token identifying the page of results to return.
     *
     *   To request the first page results, page_token must be empty. To
     *   request the next page of results, page_token must be the value of
     *   {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token}
     *   returned from the previous call to
     *   {@link protos.google.cloud.tasks.v2.CloudTasks.ListTasks|ListTasks} method.
     *
     *   The page token is valid for only 2 hours.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Stream}
     *   An object stream which emits an object representing {@link protos.google.cloud.tasks.v2.Task|Task} 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 `listTasksAsync()`
     *   method described below for async iteration which you can stop as needed.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
     *   for more details and examples.
     */
  }, {
    key: "listTasksStream",
    value: function listTasksStream(request, options) {
      var _request$parent7;
      request = request || {};
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        parent: (_request$parent7 = request.parent) !== null && _request$parent7 !== void 0 ? _request$parent7 : ''
      });
      var defaultCallSettings = this._defaults['listTasks'];
      var callSettings = defaultCallSettings.merge(options);
      this.initialize();
      return this.descriptors.page.listTasks.createStream(this.innerApiCalls.listTasks, request, callSettings);
    }

    /**
     * Equivalent to `listTasks`, but returns an iterable object.
     *
     * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.parent
     *   Required. The queue name. For example:
     *   `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
     * @param {google.cloud.tasks.v2.Task.View} request.responseView
     *   The response_view specifies which subset of the
     *   {@link protos.google.cloud.tasks.v2.Task|Task} will be returned.
     *
     *   By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC};
     *   not all information is retrieved by default because some data, such as
     *   payloads, might be desirable to return only when needed because
     *   of its large size or because of the sensitivity of data that it
     *   contains.
     *
     *   Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires
     *   `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
     *   permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource.
     * @param {number} request.pageSize
     *   Maximum page size.
     *
     *   Fewer tasks than requested might be returned, even if more tasks exist; use
     *   {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token}
     *   in the response to determine if more tasks exist.
     *
     *   The maximum page size is 1000. If unspecified, the page size will be the
     *   maximum.
     * @param {string} request.pageToken
     *   A token identifying the page of results to return.
     *
     *   To request the first page results, page_token must be empty. To
     *   request the next page of results, page_token must be the value of
     *   {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token}
     *   returned from the previous call to
     *   {@link protos.google.cloud.tasks.v2.CloudTasks.ListTasks|ListTasks} method.
     *
     *   The page token is valid for only 2 hours.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Object}
     *   An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
     *   When you iterate the returned iterable, each element will be an object representing
     *   {@link protos.google.cloud.tasks.v2.Task|Task}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
     *   for more details and examples.
     * @example <caption>include:samples/generated/v2/cloud_tasks.list_tasks.js</caption>
     * region_tag:cloudtasks_v2_generated_CloudTasks_ListTasks_async
     */
  }, {
    key: "listTasksAsync",
    value: function listTasksAsync(request, options) {
      var _request$parent8;
      request = request || {};
      options = options || {};
      options.otherArgs = options.otherArgs || {};
      options.otherArgs.headers = options.otherArgs.headers || {};
      options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
        parent: (_request$parent8 = request.parent) !== null && _request$parent8 !== void 0 ? _request$parent8 : ''
      });
      var defaultCallSettings = this._defaults['listTasks'];
      var callSettings = defaultCallSettings.merge(options);
      this.initialize();
      return this.descriptors.page.listTasks.asyncIterate(this.innerApiCalls['listTasks'], request, callSettings);
    }
    /**
     * Gets information about a location.
     *
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.name
     *   Resource name for the location.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details.
     * @returns {Promise} - The promise which resolves to an array.
     *   The first element of the array is an object representing {@link google.cloud.location.Location | Location}.
     *   Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
     *   for more details and examples.
     * @example
     * ```
     * const [response] = await client.getLocation(request);
     * ```
     */
  }, {
    key: "getLocation",
    value: function getLocation(request, options, callback) {
      return this.locationsClient.getLocation(request, options, callback);
    }

    /**
     * Lists information about the supported locations for this service. Returns an iterable object.
     *
     * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
     * @param {Object} request
     *   The request object that will be sent.
     * @param {string} request.name
     *   The resource that owns the locations collection, if applicable.
     * @param {string} request.filter
     *   The standard list filter.
     * @param {number} request.pageSize
     *   The standard list page size.
     * @param {string} request.pageToken
     *   The standard list page token.
     * @param {object} [options]
     *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
     * @returns {Object}
     *   An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
     *   When you iterate the returned iterable, each element will be an object representing
     *   {@link google.cloud.location.Location | Location}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
     *   for more details and examples.
     * @example
     * ```
     * const iterable = client.listLocationsAsync(request);
     * for await (const response of iterable) {
     *   // process response
     * }
     * ```
     */
  }, {
    key: "listLocationsAsync",
    value: function listLocationsAsync(request, options) {
      return this.locationsClient.listLocationsAsync(request, options);
    }

    // --------------------
    // -- Path templates --
    // --------------------

    /**
     * Return a fully-qualified location resource name string.
     *
     * @param {string} project
     * @param {string} location
     * @returns {string} Resource name string.
     */
  }, {
    key: "locationPath",
    value: function locationPath(project, location) {
      return this.pathTemplates.locationPathTemplate.render({
        project: project,
        location: location
      });
    }

    /**
     * Parse the project from Location resource.
     *
     * @param {string} locationName
     *   A fully-qualified path representing Location resource.
     * @returns {string} A string representing the project.
     */
  }, {
    key: "matchProjectFromLocationName",
    value: function matchProjectFromLocationName(locationName) {
      return this.pathTemplates.locationPathTemplate.match(locationName).project;
    }

    /**
     * Parse the location from Location resource.
     *
     * @param {string} locationName
     *   A fully-qualified path representing Location resource.
     * @returns {string} A string representing the location.
     */
  }, {
    key: "matchLocationFromLocationName",
    value: function matchLocationFromLocationName(locationName) {
      return this.pathTemplates.locationPathTemplate.match(locationName).location;
    }

    /**
     * Return a fully-qualified project resource name string.
     *
     * @param {string} project
     * @returns {string} Resource name string.
     */
  }, {
    key: "projectPath",
    value: function projectPath(project) {
      return this.pathTemplates.projectPathTemplate.render({
        project: project
      });
    }

    /**
     * Parse the project from Project resource.
     *
     * @param {string} projectName
     *   A fully-qualified path representing Project resource.
     * @returns {string} A string representing the project.
     */
  }, {
    key: "matchProjectFromProjectName",
    value: function matchProjectFromProjectName(projectName) {
      return this.pathTemplates.projectPathTemplate.match(projectName).project;
    }

    /**
     * Return a fully-qualified queue resource name string.
     *
     * @param {string} project
     * @param {string} location
     * @param {string} queue
     * @returns {string} Resource name string.
     */
  }, {
    key: "queuePath",
    value: function queuePath(project, location, queue) {
      return this.pathTemplates.queuePathTemplate.render({
        project: project,
        location: location,
        queue: queue
      });
    }

    /**
     * Parse the project from Queue resource.
     *
     * @param {string} queueName
     *   A fully-qualified path representing Queue resource.
     * @returns {string} A string representing the project.
     */
  }, {
    key: "matchProjectFromQueueName",
    value: function matchProjectFromQueueName(queueName) {
      return this.pathTemplates.queuePathTemplate.match(queueName).project;
    }

    /**
     * Parse the location from Queue resource.
     *
     * @param {string} queueName
     *   A fully-qualified path representing Queue resource.
     * @returns {string} A string representing the location.
     */
  }, {
    key: "matchLocationFromQueueName",
    value: function matchLocationFromQueueName(queueName) {
      return this.pathTemplates.queuePathTemplate.match(queueName).location;
    }

    /**
     * Parse the queue from Queue resource.
     *
     * @param {string} queueName
     *   A fully-qualified path representing Queue resource.
     * @returns {string} A string representing the queue.
     */
  }, {
    key: "matchQueueFromQueueName",
    value: function matchQueueFromQueueName(queueName) {
      return this.pathTemplates.queuePathTemplate.match(queueName).queue;
    }

    /**
     * Return a fully-qualified task resource name string.
     *
     * @param {string} project
     * @param {string} location
     * @param {string} queue
     * @param {string} task
     * @returns {string} Resource name string.
     */
  }, {
    key: "taskPath",
    value: function taskPath(project, location, queue, task) {
      return this.pathTemplates.taskPathTemplate.render({
        project: project,
        location: location,
        queue: queue,
        task: task
      });
    }

    /**
     * Parse the project from Task resource.
     *
     * @param {string} taskName
     *   A fully-qualified path representing Task resource.
     * @returns {string} A string representing the project.
     */
  }, {
    key: "matchProjectFromTaskName",
    value: function matchProjectFromTaskName(taskName) {
      return this.pathTemplates.taskPathTemplate.match(taskName).project;
    }

    /**
     * Parse the location from Task resource.
     *
     * @param {string} taskName
     *   A fully-qualified path representing Task resource.
     * @returns {string} A string representing the location.
     */
  }, {
    key: "matchLocationFromTaskName",
    value: function matchLocationFromTaskName(taskName) {
      return this.pathTemplates.taskPathTemplate.match(taskName).location;
    }

    /**
     * Parse the queue from Task resource.
     *
     * @param {string} taskName
     *   A fully-qualified path representing Task resource.
     * @returns {string} A string representing the queue.
     */
  }, {
    key: "matchQueueFromTaskName",
    value: function matchQueueFromTaskName(taskName) {
      return this.pathTemplates.taskPathTemplate.match(taskName).queue;
    }

    /**
     * Parse the task from Task resource.
     *
     * @param {string} taskName
     *   A fully-qualified path representing Task resource.
     * @returns {string} A string representing the task.
     */
  }, {
    key: "matchTaskFromTaskName",
    value: function matchTaskFromTaskName(taskName) {
      return this.pathTemplates.taskPathTemplate.match(taskName).task;
    }

    /**
     * Terminate the gRPC channel and close the client.
     *
     * The client will no longer be usable and all future behavior is undefined.
     * @returns {Promise} A promise that resolves when the client is closed.
     */
  }, {
    key: "close",
    value: function close() {
      var _this2 = this;
      if (this.cloudTasksStub && !this._terminated) {
        return this.cloudTasksStub.then(function (stub) {
          _this2._terminated = true;
          stub.close();
          _this2.locationsClient.close();
        });
      }
      return Promise.resolve();
    }
  }], [{
    key: "servicePath",
    get: function get() {
      if ((typeof process === "undefined" ? "undefined" : _typeof(process)) !== undefined && typeof process.emitWarning === 'function') {
        process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
      }
      return 'cloudtasks.googleapis.com';
    }

    /**
     * The DNS address for this API service - same as servicePath,
     * exists for compatibility reasons.
     * @deprecated Use the apiEndpoint method of the client instance.
     * @returns {string} The DNS address for this service.
     */
  }, {
    key: "apiEndpoint",
    get: function get() {
      if ((typeof process === "undefined" ? "undefined" : _typeof(process)) !== undefined && typeof process.emitWarning === 'function') {
        process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
      }
      return 'cloudtasks.googleapis.com';
    }
  }, {
    key: "port",
    get: function get() {
      return 443;
    }

    /**
     * The scopes needed to make gRPC calls for every method defined
     * in this service.
     * @returns {string[]} List of default scopes.
     */
  }, {
    key: "scopes",
    get: function get() {
      return ['https://www.googleapis.com/auth/cloud-platform'];
    }
  }]);
  return CloudTasksClient;
}();