UNPKG

google-ads-node

Version:
744 lines 268 kB
"use strict"; // Copyright 2021 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. ** Object.defineProperty(exports, "__esModule", { value: true }); exports.CampaignDraftServiceClient = void 0; /* global window */ const gax = require("google-gax"); const jsonProtos = require("../../protos/protos.json"); /** * Client JSON configuration object, loaded from * `src/v8/campaign_draft_service_client_config.json`. * This file defines retry strategy and timeouts for all API methods in this library. */ const gapicConfig = require("./campaign_draft_service_client_config.json"); const google_gax_1 = require("google-gax"); const version = require('../../../package.json').version; /** * Service to manage campaign drafts. * @class * @memberof v8 */ class CampaignDraftServiceClient { /** * Construct an instance of CampaignDraftServiceClient. * * @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/master/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} [options.fallback] - Use HTTP fallback mode. * In fallback mode, a special browser-compatible transport implementation is used * instead of gRPC transport. In browser context (if the `window` object is defined) * the fallback mode is enabled automatically; set `options.fallback` to `false` * if you need to override this behavior. */ constructor(opts) { var _a, _b; this._terminated = false; this.descriptors = { page: {}, stream: {}, longrunning: {}, batching: {}, }; // Ensure that options include all the required fields. const staticMembers = this.constructor; const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || staticMembers.servicePath; this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint)); const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port; const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {}; const fallback = (_b = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _b !== void 0 ? _b : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function'); opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } // Choose either gRPC or proto-over-HTTP implementation of google-gax. this._gaxModule = opts.fallback ? gax.fallback : gax; // 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 = staticMembers.servicePath; // Set the default scopes in auth client if needed. if (servicePath === staticMembers.servicePath) { this.auth.defaultScopes = staticMembers.scopes; } // Determine the client header string. const clientHeader = [ `gax/${this._gaxModule.version}`, `gapic/${version}`, ]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { clientHeader.push(`gl-web/${this._gaxModule.version}`); } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); } else if (opts.fallback === 'rest') { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } // 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 = { accessibleBiddingStrategyPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/accessibleBiddingStrategies/{bidding_strategy_id}'), accountBudgetPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/accountBudgets/{account_budget_id}'), accountBudgetProposalPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/accountBudgetProposals/{account_budget_proposal_id}'), accountLinkPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/accountLinks/{account_link_id}'), adPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/ads/{ad_id}'), adGroupPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroups/{ad_group_id}'), adGroupAdPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupAds/{ad_group_id}~{ad_id}'), adGroupAdAssetViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupAdAssetViews/{ad_group_id}~{ad_id}~{asset_id}~{field_type}'), adGroupAdLabelPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupAdLabels/{ad_group_id}~{ad_id}~{label_id}'), adGroupAssetPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupAssets/{ad_group_id}~{asset_id}~{field_type}'), adGroupAudienceViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupAudienceViews/{ad_group_id}~{criterion_id}'), adGroupBidModifierPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupBidModifiers/{ad_group_id}~{criterion_id}'), adGroupCriterionPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupCriteria/{ad_group_id}~{criterion_id}'), adGroupCriterionLabelPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupCriterionLabels/{ad_group_id}~{criterion_id}~{label_id}'), adGroupCriterionSimulationPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupCriterionSimulations/{ad_group_id}~{criterion_id}~{type}~{modification_method}~{start_date}~{end_date}'), adGroupExtensionSettingPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupExtensionSettings/{ad_group_id}~{extension_type}'), adGroupFeedPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupFeeds/{ad_group_id}~{feed_id}'), adGroupLabelPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupLabels/{ad_group_id}~{label_id}'), adGroupSimulationPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adGroupSimulations/{ad_group_id}~{type}~{modification_method}~{start_date}~{end_date}'), adParameterPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adParameters/{ad_group_id}~{criterion_id}~{parameter_index}'), adScheduleViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/adScheduleViews/{campaign_id}~{criterion_id}'), ageRangeViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/ageRangeViews/{ad_group_id}~{criterion_id}'), assetPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/assets/{asset_id}'), assetFieldTypeViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/assetFieldTypeViews/{field_type}'), batchJobPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/batchJobs/{batch_job_id}'), biddingDataExclusionPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/biddingDataExclusions/{seasonality_event_id}'), biddingSeasonalityAdjustmentPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/biddingSeasonalityAdjustments/{seasonality_event_id}'), biddingStrategyPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/biddingStrategies/{bidding_strategy_id}'), biddingStrategySimulationPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/biddingStrategySimulations/{bidding_strategy_id}~{type}~{modification_method}~{start_date}~{end_date}'), billingSetupPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/billingSetups/{billing_setup_id}'), callViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/callViews/{call_detail_id}'), campaignPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaigns/{campaign_id}'), campaignAssetPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignAssets/{campaign_id}~{asset_id}~{field_type}'), campaignAudienceViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignAudienceViews/{campaign_id}~{criterion_id}'), campaignBidModifierPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignBidModifiers/{campaign_id}~{criterion_id}'), campaignBudgetPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignBudgets/{campaign_budget_id}'), campaignCriterionPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignCriteria/{campaign_id}~{criterion_id}'), campaignCriterionSimulationPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignCriterionSimulations/{campaign_id}~{criterion_id}~{type}~{modification_method}~{start_date}~{end_date}'), campaignDraftPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignDrafts/{base_campaign_id}~{draft_id}'), campaignExperimentPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignExperiments/{campaign_experiment_id}'), campaignExtensionSettingPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignExtensionSettings/{campaign_id}~{extension_type}'), campaignFeedPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignFeeds/{campaign_id}~{feed_id}'), campaignLabelPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignLabels/{campaign_id}~{label_id}'), campaignSharedSetPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignSharedSets/{campaign_id}~{shared_set_id}'), campaignSimulationPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/campaignSimulations/{campaign_id}~{type}~{modification_method}~{start_date}~{end_date}'), carrierConstantPathTemplate: new this._gaxModule.PathTemplate('carrierConstants/{criterion_id}'), changeEventPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/changeEvents/{timestamp_micros}~{command_index}~{mutate_index}'), changeStatusPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/changeStatus/{change_status_id}'), clickViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/clickViews/{date}~{gclid}'), combinedAudiencePathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/combinedAudiences/{combined_audience_id}'), conversionActionPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/conversionActions/{conversion_action_id}'), conversionCustomVariablePathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/conversionCustomVariables/{conversion_custom_variable_id}'), conversionValueRulePathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/conversionValueRules/{conversion_value_rule_id}'), conversionValueRuleSetPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/conversionValueRuleSets/{conversion_value_rule_set_id}'), currencyConstantPathTemplate: new this._gaxModule.PathTemplate('currencyConstants/{code}'), customAudiencePathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customAudiences/{custom_audience_id}'), customInterestPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customInterests/{custom_interest_id}'), customerPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}'), customerAssetPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customerAssets/{asset_id}~{field_type}'), customerClientPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customerClients/{client_customer_id}'), customerClientLinkPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customerClientLinks/{client_customer_id}~{manager_link_id}'), customerExtensionSettingPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customerExtensionSettings/{extension_type}'), customerFeedPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customerFeeds/{feed_id}'), customerLabelPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customerLabels/{label_id}'), customerManagerLinkPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customerManagerLinks/{manager_customer_id}~{manager_link_id}'), customerNegativeCriterionPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customerNegativeCriteria/{criterion_id}'), customerUserAccessPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customerUserAccesses/{user_id}'), customerUserAccessInvitationPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/customerUserAccessInvitations/{invitation_id}'), detailPlacementViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/detailPlacementViews/{ad_group_id}~{base64_placement}'), detailedDemographicPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/detailedDemographics/{detailed_demographic_id}'), displayKeywordViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/displayKeywordViews/{ad_group_id}~{criterion_id}'), distanceViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/distanceViews/{placeholder_chain_id}~{distance_bucket}'), domainCategoryPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/domainCategories/{campaign_id}~{base64_category}~{language_code}'), dynamicSearchAdsSearchTermViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/dynamicSearchAdsSearchTermViews/{ad_group_id}~{search_term_fingerprint}~{headline_fingerprint}~{landing_page_fingerprint}~{page_url_fingerprint}'), expandedLandingPageViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/expandedLandingPageViews/{expanded_final_url_fingerprint}'), extensionFeedItemPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/extensionFeedItems/{feed_item_id}'), feedPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/feeds/{feed_id}'), feedItemPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/feedItems/{feed_id}~{feed_item_id}'), feedItemSetPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/feedItemSets/{feed_id}~{feed_item_set_id}'), feedItemSetLinkPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/feedItemSetLinks/{feed_id}~{feed_item_set_id}~{feed_item_id}'), feedItemTargetPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/feedItemTargets/{feed_id}~{feed_item_id}~{feed_item_target_type}~{feed_item_target_id}'), feedMappingPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/feedMappings/{feed_id}~{feed_mapping_id}'), feedPlaceholderViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/feedPlaceholderViews/{placeholder_type}'), genderViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/genderViews/{ad_group_id}~{criterion_id}'), geoTargetConstantPathTemplate: new this._gaxModule.PathTemplate('geoTargetConstants/{criterion_id}'), geographicViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/geographicViews/{country_criterion_id}~{location_type}'), googleAdsFieldPathTemplate: new this._gaxModule.PathTemplate('googleAdsFields/{google_ads_field}'), groupPlacementViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/groupPlacementViews/{ad_group_id}~{base64_placement}'), hotelGroupViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/hotelGroupViews/{ad_group_id}~{criterion_id}'), hotelPerformanceViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/hotelPerformanceView'), incomeRangeViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/incomeRangeViews/{ad_group_id}~{criterion_id}'), invoicePathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/invoices/{invoice_id}'), keywordPlanPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/keywordPlans/{keyword_plan_id}'), keywordPlanAdGroupPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/keywordPlanAdGroups/{keyword_plan_ad_group_id}'), keywordPlanAdGroupKeywordPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/keywordPlanAdGroupKeywords/{keyword_plan_ad_group_keyword_id}'), keywordPlanCampaignPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/keywordPlanCampaigns/{keyword_plan_campaign_id}'), keywordPlanCampaignKeywordPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/keywordPlanCampaignKeywords/{keyword_plan_campaign_keyword_id}'), keywordThemeConstantPathTemplate: new this._gaxModule.PathTemplate('keywordThemeConstants/{express_category_id}~{express_sub_category_id}'), keywordViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/keywordViews/{ad_group_id}~{criterion_id}'), labelPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/labels/{label_id}'), landingPageViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/landingPageViews/{unexpanded_final_url_fingerprint}'), languageConstantPathTemplate: new this._gaxModule.PathTemplate('languageConstants/{criterion_id}'), lifeEventPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/lifeEvents/{life_event_id}'), locationViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/locationViews/{campaign_id}~{criterion_id}'), managedPlacementViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/managedPlacementViews/{ad_group_id}~{criterion_id}'), mediaFilePathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/mediaFiles/{media_file_id}'), merchantCenterLinkPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/merchantCenterLinks/{merchant_center_id}'), mobileAppCategoryConstantPathTemplate: new this._gaxModule.PathTemplate('mobileAppCategoryConstants/{mobile_app_category_id}'), mobileDeviceConstantPathTemplate: new this._gaxModule.PathTemplate('mobileDeviceConstants/{criterion_id}'), offlineUserDataJobPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/offlineUserDataJobs/{offline_user_data_update_id}'), operatingSystemVersionConstantPathTemplate: new this._gaxModule.PathTemplate('operatingSystemVersionConstants/{criterion_id}'), paidOrganicSearchTermViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/paidOrganicSearchTermViews/{campaign_id}~{ad_group_id}~{base64_search_term}'), parentalStatusViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/parentalStatusViews/{ad_group_id}~{criterion_id}'), paymentsAccountPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/paymentsAccounts/{payments_account_id}'), productBiddingCategoryConstantPathTemplate: new this._gaxModule.PathTemplate('productBiddingCategoryConstants/{country_code}~{level}~{id}'), productGroupViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/productGroupViews/{adgroup_id}~{criterion_id}'), recommendationPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/recommendations/{recommendation_id}'), remarketingActionPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/remarketingActions/{remarketing_action_id}'), searchTermViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/searchTermViews/{campaign_id}~{ad_group_id}~{query}'), sharedCriterionPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/sharedCriteria/{shared_set_id}~{criterion_id}'), sharedSetPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/sharedSets/{shared_set_id}'), shoppingPerformanceViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/shoppingPerformanceView'), smartCampaignSearchTermViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/smartCampaignSearchTermViews/{campaign_id}~{query}'), smartCampaignSettingPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/smartCampaignSettings/{campaign_id}'), thirdPartyAppAnalyticsLinkPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/thirdPartyAppAnalyticsLinks/{customer_link_id}'), topicConstantPathTemplate: new this._gaxModule.PathTemplate('topicConstants/{topic_id}'), topicViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/topicViews/{ad_group_id}~{criterion_id}'), userInterestPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/userInterests/{user_interest_id}'), userListPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/userLists/{user_list_id}'), userLocationViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/userLocationViews/{country_criterion_id}~{is_targeting_location}'), videoPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/videos/{video_id}'), webpageViewPathTemplate: new this._gaxModule.PathTemplate('customers/{customer_id}/webpageViews/{ad_group_id}~{criterion_id}'), }; // 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 = { listCampaignDraftAsyncErrors: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'errors') }; const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, // rather than holding a request open. this.operationsClient = this._gaxModule.lro({ auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined }).operationsClient(opts); const promoteCampaignDraftResponse = protoFilesRoot.lookup('.google.protobuf.Empty'); const promoteCampaignDraftMetadata = protoFilesRoot.lookup('.google.protobuf.Empty'); this.descriptors.longrunning = { promoteCampaignDraft: new this._gaxModule.LongrunningDescriptor(this.operationsClient, promoteCampaignDraftResponse.decode.bind(promoteCampaignDraftResponse), promoteCampaignDraftMetadata.decode.bind(promoteCampaignDraftMetadata)) }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings('google.ads.googleads.v8.services.CampaignDraftService', 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 = gax.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. */ initialize() { // If the client stub promise is already initialized, return immediately. if (this.campaignDraftServiceStub) { return this.campaignDraftServiceStub; } // Put together the "service stub" for // google.ads.googleads.v8.services.CampaignDraftService. this.campaignDraftServiceStub = this._gaxGrpc.createStub(this._opts.fallback ? this._protos.lookupService('google.ads.googleads.v8.services.CampaignDraftService') : // eslint-disable-next-line @typescript-eslint/no-explicit-any this._protos.google.ads.googleads.v8.services.CampaignDraftService, this._opts, this._providedCustomServicePath); // Iterate over each of the methods that the service provides // and create an API call method for each. const campaignDraftServiceStubMethods = ['getCampaignDraft', 'mutateCampaignDrafts', 'promoteCampaignDraft', 'listCampaignDraftAsyncErrors']; for (const methodName of campaignDraftServiceStubMethods) { const callPromise = this.campaignDraftServiceStub.then(stub => (...args) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); } const func = stub[methodName]; return func.apply(stub, args); }, (err) => () => { throw err; }); const descriptor = this.descriptors.page[methodName] || this.descriptors.longrunning[methodName] || undefined; const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor); this.innerApiCalls[methodName] = apiCall; } return this.campaignDraftServiceStub; } /** * The DNS address for this API service. * @returns {string} The DNS address for this service. */ static get servicePath() { return 'googleads.googleapis.com'; } /** * The DNS address for this API service - same as servicePath(), * exists for compatibility reasons. * @returns {string} The DNS address for this service. */ static get apiEndpoint() { return 'googleads.googleapis.com'; } /** * The port for this API service. * @returns {number} The default port for this service. */ static get port() { return 443; } /** * The scopes needed to make gRPC calls for every method defined * in this service. * @returns {string[]} List of default scopes. */ static get scopes() { return [ 'https://www.googleapis.com/auth/adwords' ]; } /** * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ getProjectId(callback) { if (callback) { this.auth.getProjectId(callback); return; } return this.auth.getProjectId(); } /** * Returns the requested campaign draft in full detail. * * List of thrown errors: * [AuthenticationError]() * [AuthorizationError]() * [HeaderError]() * [InternalError]() * [QuotaError]() * [RequestError]() * * @param {Object} request * The request object that will be sent. * @param {string} request.resource_name * Required. The resource name of the campaign draft to fetch. * @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 [CampaignDraft]{@link google.ads.googleads.v8.resources.CampaignDraft}. * Please see the * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) * for more details and examples. * @example * const [response] = await client.getCampaignDraft(request); */ getCampaignDraft(request, optionsOrCallback, callback) { request = request || {}; let 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'] = gax.routingHeader.fromParams({ 'resource_name': request.resource_name || '', }); this.initialize(); return this.innerApiCalls.getCampaignDraft(request, options, callback); } /** * Creates, updates, or removes campaign drafts. Operation statuses are * returned. * * List of thrown errors: * [AuthenticationError]() * [AuthorizationError]() * [CampaignDraftError]() * [DatabaseError]() * [FieldError]() * [HeaderError]() * [InternalError]() * [MutateError]() * [QuotaError]() * [RequestError]() * * @param {Object} request * The request object that will be sent. * @param {string} request.customer_id * Required. The ID of the customer whose campaign drafts are being modified. * @param {number[]} request.operations * Required. The list of operations to perform on individual campaign drafts. * @param {boolean} request.partialFailure * If true, successful operations will be carried out and invalid * operations will return errors. If false, all operations will be carried * out in one transaction if and only if they are all valid. * Default is false. * @param {boolean} request.validateOnly * If true, the request is validated but not executed. Only errors are * returned, not results. * @param {google.ads.googleads.v8.enums.ResponseContentTypeEnum.ResponseContentType} request.responseContentType * The response content type setting. Determines whether the mutable resource * or just the resource name should be returned post mutation. * @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 [MutateCampaignDraftsResponse]{@link google.ads.googleads.v8.services.MutateCampaignDraftsResponse}. * Please see the * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) * for more details and examples. * @example * const [response] = await client.mutateCampaignDrafts(request); */ mutateCampaignDrafts(request, optionsOrCallback, callback) { request = request || {}; let 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'] = gax.routingHeader.fromParams({ 'customer_id': request.customer_id || '', }); this.initialize(); return this.innerApiCalls.mutateCampaignDrafts(request, options, callback); } /** * Promotes the changes in a draft back to the base campaign. * * This method returns a Long Running Operation (LRO) indicating if the * Promote is done. Use [Operations.GetOperation] to poll the LRO until it * is done. Only a done status is returned in the response. See the status * in the Campaign Draft resource to determine if the promotion was * successful. If the LRO failed, use * {@link google.ads.googleads.v8.services.CampaignDraftService.ListCampaignDraftAsyncErrors|CampaignDraftService.ListCampaignDraftAsyncErrors} to view the list of * error reasons. * * List of thrown errors: * [AuthenticationError]() * [AuthorizationError]() * [CampaignDraftError]() * [HeaderError]() * [InternalError]() * [QuotaError]() * [RequestError]() * * @param {Object} request * The request object that will be sent. * @param {string} request.campaign_draft * Required. The resource name of the campaign draft to promote. * @param {boolean} request.validateOnly * If true, the request is validated but no Long Running Operation is created. * Only errors are returned. * @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 * a long running operation. Its `promise()` method returns a promise * you can `await` for. * Please see the * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) * for more details and examples. * @example * const [operation] = await client.promoteCampaignDraft(request); * const [response] = await operation.promise(); */ promoteCampaignDraft(request, optionsOrCallback, callback) { request = request || {}; let 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'] = gax.routingHeader.fromParams({ 'campaign_draft': request.campaign_draft || '', }); this.initialize(); return this.innerApiCalls.promoteCampaignDraft(request, options, callback); } /** * Check the status of the long running operation returned by `promoteCampaignDraft()`. * @param {String} name * The operation name that will be passed. * @returns {Promise} - The promise which resolves to an object. * The decoded operation object has result and metadata field to get information from. * Please see the * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) * for more details and examples. * @example * const decodedOperation = await checkPromoteCampaignDraftProgress(name); * console.log(decodedOperation.result); * console.log(decodedOperation.done); * console.log(decodedOperation.metadata); */ async checkPromoteCampaignDraftProgress(name) { const request = new google_gax_1.operationsProtos.google.longrunning.GetOperationRequest({ name }); const [operation] = await this.operationsClient.getOperation(request); const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.promoteCampaignDraft, gax.createDefaultBackoffSettings()); return decodeOperation; } /** * Returns all errors that occurred during CampaignDraft promote. Throws an * error if called before campaign draft is promoted. * Supports standard list paging. * * List of thrown errors: * [AuthenticationError]() * [AuthorizationError]() * [HeaderError]() * [InternalError]() * [QuotaError]() * [RequestError]() * * @param {Object} request * The request object that will be sent. * @param {string} request.resource_name * Required. The name of the campaign draft from which to retrieve the async errors. * @param {string} request.pageToken * Token of the page to retrieve. If not specified, the first * page of results will be returned. Use the value obtained from * `next_page_token` in the previous response in order to request * the next page of results. * @param {number} request.pageSize * Number of elements to retrieve in a single page. * When a page request is too large, the server may decide to * further limit the number of returned resources. * @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 [Status]{@link google.rpc.Status}. * 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 `listCampaignDraftAsyncErrorsAsync()` * method described below for async iteration which you can stop as needed. * Please see the * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) * for more details and examples. */ listCampaignDraftAsyncErrors(request, optionsOrCallback, callback) { request = request || {}; let 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'] = gax.routingHeader.fromParams({ 'resource_name': request.resource_name || '', }); this.initialize(); return this.innerApiCalls.listCampaignDraftAsyncErrors(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.resource_name * Required. The name of the campaign draft from which to retrieve the async errors. * @param {string} request.pageToken * Token of the page to retrieve. If not specified, the first * page of results will be returned. Use the value obtained from * `next_page_token` in the previous response in order to request * the next page of results. * @param {number} request.pageSize * Number of elements to retrieve in a single page. * When a page request is too large, the server may decide to * further limit the number of returned resources. * @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 [Status]{@link google.rpc.Status} 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 `listCampaignDraftAsyncErrorsAsync()` * method described below for async iteration which you can stop as needed. * Please see the * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) * for more details and examples. */ listCampaignDraftAsyncErrorsStream(request, options) { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({ 'resource_name': request.resource_name || '', }); const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listCampaignDraftAsyncErrors.createStream(this.innerApiCalls.listCampaignDraftAsyncErrors, request, callSettings); } /** * Equivalent to `listCampaignDraftAsyncErrors`, 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.resource_name * Required. The name of the campaign draft from which to retrieve the async errors. * @param {string} request.pageToken * Token of the page to retrieve. If not specified, the first * page of results will be returned. Use the value obtained from * `next_page_token` in the previous response in order to request * the next page of results. * @param {number} request.pageSize * Number of elements to retrieve in a single page. * When a page request is too large, the server may decide to * further limit the number of returned resources. * @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 [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). * When you iterate the returned iterable, each element will be an object representing * [Status]{@link google.rpc.Status}. The API will be called under the hood as needed, once per the page, * so you can stop the iteration when you don't need more results. * Please see the * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) * for more details and examples. * @example * const iterable = client.listCampaignDraftAsyncErrorsAsync(request); * for await (const response of iterable) { * // process response * } */ listCampaignDraftAsyncErrorsAsync(request, options) { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({ 'resource_name': request.resource_name || '', }); options = options || {}; const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listCampaignDraftAsyncErrors.asyncIterate(this.innerApiCalls['listCampaignDraftAsyncErrors'], request, callSettings); } // -------------------- // -- Path templates -- // -------------------- /** * Return a fully-qualified accessibleBiddingStrategy resource name string. * * @param {string} customer_id * @param {string} bidding_strategy_id * @returns {string} Resource name string. */ accessibleBiddingStrategyPath(customerId, biddingStrategyId) { return this.pathTemplates.accessibleBiddingStrategyPathTemplate.render({ customer_id: customerId, bidding_strategy_id: biddingStrategyId, }); } /** * Parse the customer_id from AccessibleBiddingStrategy resource. * * @param {string} accessibleBiddingStrategyName * A fully-qualified path representing AccessibleBiddingStrategy resource. * @returns {string} A string representing the customer_id. */ matchCustomerIdFromAccessibleBiddingStrategyName(accessibleBiddingStrategyName) { return this.pathTemplates.accessibleBiddingStrategyPathTemplate.match(accessibleBiddingStrategyName).customer_id; } /** * Parse the bidding_strategy_id from AccessibleBiddingStrategy resource. * * @param {string} accessibleBiddingStrategyName * A fully-qualified path representing AccessibleBiddingStrategy resource. * @returns {string} A string representing the bidding_strategy_id. */ matchBiddingStrategyIdFromAccessibleBiddin