Adds a web page criterion to target Dynamic Search Ads.

  Args:
    client: an AdWordsClient instance.
    ad_group_id: an integer ID of the ad group the criteria is being added to.
505988
def _AddWebPageCriteria(client, ad_group_id):
  
  ad_group_criterion_service = client.GetService('AdGroupCriterionService',
                                                 version='v201809')

  operations = [{
      'operator': 'ADD',
      # Create biddable ad group criterion.
      'operand': {
          'xsi_type': 'BiddableAdGroupCriterion',
          'adGroupId': ad_group_id,
          # Create a webpage criterion for special offers for children.
          'criterion': {
              'xsi_type': 'Webpage',
              'parameter': {
                  'criterionName': 'Special offers for children.',
                  'conditions': [
                      {
                          'operand': 'URL',
                          'argument': '/marscruise/children'
                      },
                      {
                          'operand': 'PAGE_TITLE',
                          'argument': 'Special Offer'
                      }
                  ]
              }
          },
          'userStatus': 'PAUSED',
          # Optional: set a custom bid.
          'biddingStrategyConfiguration': {
              'bids': [{
                  'xsi_type': 'CpcBid',
                  'bid': {
                      'microAmount': 10000000L
                  }
              }]
          }
      }
  }]

  criterion = ad_group_criterion_service.mutate(operations)['value'][0]

  print 'Webpage criterion with ID "%d" was added to ad group ID "%d".' % (
      criterion['criterion']['id'], criterion['adGroupId'])
422003
def CreateProductPartition(client, adgroup_id):
  
  ad_group_criterion_service = client.GetService('AdGroupCriterionService',
                                                 'v201809')
  helper = ProductPartitionHelper(adgroup_id)
  root = helper.CreateSubdivision()

  new_product_canonical_condition = {
      'xsi_type': 'ProductCanonicalCondition',
      'condition': 'NEW'
  }

  used_product_canonical_condition = {
      'xsi_type': 'ProductCanonicalCondition',
      'condition': 'USED'
  }

  other_product_canonical_condition = {
      'xsi_type': 'ProductCanonicalCondition',
  }

  helper.CreateUnit(root, new_product_canonical_condition)
  helper.CreateUnit(root, used_product_canonical_condition)
  helper.CreateUnit(root, other_product_canonical_condition)

  result = ad_group_criterion_service.mutate(helper.operations)
  return result['value']
912635
private static function restrictFeedItemToAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $feedId,
        $feedItemId,
        $adGroupId
    ) {
        $feedItemTargetService = $adWordsServices->get(
            $session,
            FeedItemTargetService::class
        );

        // Create a feed item ad group target.
        $feedItemAdGroupTarget = new FeedItemAdGroupTarget();
        $feedItemAdGroupTarget->setFeedId($feedId);
        $feedItemAdGroupTarget->setFeedItemId($feedItemId);
        $feedItemAdGroupTarget->setAdGroupId($adGroupId);

        // Create a feed item ad group target operation.
        $operation = new FeedItemTargetOperation();
        $operation->setOperand($feedItemAdGroupTarget);
        $operation->setOperator(Operator::ADD);

        // Create the feed item ad group target on the server and print out
        // some information.
        $result = $feedItemTargetService->mutate([$operation]);
        $feedItemAdGroupTarget = $result->getValue()[0];
        printf(
            'Feed item target for feed ID %d and feed item ID %d was '
            . 'created to restrict serving to ad group ID %d.%s',
            $feedItemAdGroupTarget->getFeedId(),
            $feedItemAdGroupTarget->getFeedItemId(),
            $feedItemAdGroupTarget->getAdGroupId(),
            PHP_EOL
        );
    }
1306575
def on_menu_criteria(self, event):
        

        dia = thellier_gui_dialogs.Criteria_Dialog(
            None, self.acceptance_criteria, self.preferences, title='Set Acceptance Criteria')
        dia.Center()
        result = self.show_dlg(dia)

        if result == wx.ID_OK:  # Until the user clicks OK, show the message
            self.On_close_criteria_box(dia)
438697
def client_id(self, client):
        

        params = {
            "name": client
        }

        response = self._get(url.clients, params=params)
        self._check_response(response, 200)
        return self._create_response(response).get("client_id")
948533
def add_group(id, description=None):
    

    if not description:
        description = id
    data = {
        'description': description
    }
    acl_url = urljoin(_acl_url(), 'groups/{}'.format(id))
    try:
        r = http.put(acl_url, json=data)
        assert r.status_code == 201
    except DCOSHTTPException as e:
        if e.response.status_code != 409:
            raise
576639
private static BiddingStrategyConfiguration getAdGroupBiddingStrategyConfiguration(
      AdWordsServicesInterface services, AdWordsSession session, Long adGroupId)
      throws ApiException, RemoteException {
    AdGroupServiceInterface adGroupService = services.get(session, AdGroupServiceInterface.class);

    Selector selector = new SelectorBuilder()
        .fields(
            AdGroupField.Id,
            AdGroupField.BiddingStrategyType,
            AdGroupField.BiddingStrategyId,
            AdGroupField.BiddingStrategyName)
        .equalsId(adGroupId).build();

    AdGroupPage adGroupPage = adGroupService.get(selector);

    if (adGroupPage.getEntries() == null || adGroupPage.getEntries().length == 0) {
      throw new IllegalArgumentException("No ad group found with ID " + adGroupId);
    }

    AdGroup adGroup = adGroupPage.getEntries(0);

    Preconditions.checkState(adGroup.getBiddingStrategyConfiguration() != null,
        "Unexpected state - ad group ID %s has a null BiddingStrategyConfiguration", adGroupId);
    return adGroup.getBiddingStrategyConfiguration();
  }
1364484
private static void restrictFeedItemToAdGroup(
      AdWordsServicesInterface adWordsServices,
      AdWordsSession session,
      SiteLinksDataHolder siteLinksData,
      Long adGroupId)
      throws RemoteException {
    FeedItemTargetServiceInterface feedItemTargetService =
        adWordsServices.get(session, FeedItemTargetServiceInterface.class);
    FeedItemAdGroupTarget feedItemAdGroupTarget = new FeedItemAdGroupTarget();
    feedItemAdGroupTarget.setAdGroupId(adGroupId);
    feedItemAdGroupTarget.setFeedId(siteLinksData.siteLinksFeedId);
    feedItemAdGroupTarget.setFeedItemId(siteLinksData.siteLinkFeedItemIds.get(0));

    FeedItemTargetOperation operation = new FeedItemTargetOperation();
    operation.setOperand(feedItemAdGroupTarget);
    operation.setOperator(Operator.ADD);

    feedItemAdGroupTarget =
        (FeedItemAdGroupTarget)
            feedItemTargetService.mutate(new FeedItemTargetOperation[] {operation}).getValue(0);
    System.out.printf(
        "Feed item target for feed ID %d and feed item ID %d was created to restrict serving to "
            + "ad group ID %d'.%n",
        feedItemAdGroupTarget.getFeedId(),
        feedItemAdGroupTarget.getFeedItemId(),
        feedItemAdGroupTarget.getAdGroupId());
  }
826885
private static function updateCampaignDsaSetting(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $campaignId,
        DSAFeedDetails $feedDetails
    ) {
        $campaignService = $adWordsServices->get($session, CampaignService::class);

        // Create selector.
        $selector = new Selector();
        $selector->setFields(['Id', 'Settings']);
        $selector->setPredicates(
            [new Predicate('CampaignId', PredicateOperator::IN, [$campaignId])]
        );

        $result = $campaignService->get($selector);
        if (empty($result->getEntries()) || $result->getTotalNumEntries() === 0) {
            throw new InvalidArgumentException(
                'No campaign found with ID: ' . $campaignId
            );
        }
        $campaign = $result->getEntries()[0];

        if ($campaign->getSettings() === null) {
            throw new InvalidArgumentException(
                'Campaign with ID ' . $campaignId . ' is not a DSA campaign.'
            );
        }

        $dsaSetting = null;
        foreach ($campaign->getSettings() as $setting) {
            if ($setting instanceof DynamicSearchAdsSetting) {
                $dsaSetting = $setting;
                break;
            }
        }

        if ($dsaSetting === null) {
            throw new InvalidArgumentException(
                'Campaign with ID ' . $campaignId . ' is not a DSA campaign.'
            );
        }

        // Use a page feed to specify precisely which URLs to use with your
        // Dynamic Search Ads.
        $pageFeed = new PageFeed();
        $pageFeed->setFeedIds([$feedDetails->feedId]);
        $dsaSetting->setPageFeed($pageFeed);

        // Optional: Specify whether only the supplied URLs should be used with your
        // Dynamic Search Ads.
        $dsaSetting->setUseSuppliedUrlsOnly(true);

        $updatedCampaign = new Campaign();
        $updatedCampaign->setId($campaignId);
        $updatedCampaign->setSettings($campaign->getSettings());

        $operation = new CampaignOperation();
        $operation->setOperand($updatedCampaign);
        $operation->setOperator(Operator::SET);

        // Update the campaign on the server and print out some information.
        $result = $campaignService->mutate([$operation]);
        $updatedCampaign = $result->getValue()[0];
        printf(
            "DSA page feed for campaign ID %d was updated with feed ID %d.\n",
            $updatedCampaign->getId(),
            $feedDetails->feedId
        );
    }
616453
def _get_client_by_id(self, client_id):
    
    client = self.grr_api.Client(client_id)
    print('Checking for client approval')
    self._check_approval_wrapper(client, client.ListFlows)
    print('{0:s}: Client approval is valid'.format(client_id))
    return client.Get()
169786
public function setCriteriaDisplayGroup($query_name, $criteria_display_group)
    {
        if (($cl = ReporticoUtility::getQueryColumn($query_name, $this->lookup_queries))) {
            $cl->setCriteriaDisplayGroup($criteria_display_group);
        }
    }
625406
def _set_client_id(self, client_id):
        
        with self.lock:
            if self.client_id is None:
                self.client_id = client_id
863484
private static function addDsaTargeting(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $adGroupId,
        $dsaPageUrlLabel
    ) {
        $adGroupCriterionService = $adWordsServices->get($session, AdGroupCriterionService::class);

        // Create a webpage criterion.
        $webpage = new Webpage();

        $parameter = new WebpageParameter();
        $parameter->setCriterionName('Test criterion');
        $webpage->setParameter($parameter);

        // Add a condition for label=specified_label_name.
        $condition = new WebpageCondition();
        $condition->setOperand(WebpageConditionOperand::CUSTOM_LABEL);
        $condition->setArgument($dsaPageUrlLabel);
        $parameter->setConditions([$condition]);

        $criterion = new BiddableAdGroupCriterion();
        $criterion->setAdGroupId($adGroupId);
        $criterion->setCriterion($webpage);

        // Set a custom bid for this criterion.
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();

        $cpcBid = new CpcBid();
        $money = new Money();
        $money->setMicroAmount(1500000);
        $cpcBid->setBid($money);
        $biddingStrategyConfiguration->setBids([$cpcBid]);

        $criterion->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

        $operation = new AdGroupCriterionOperation();
        $operation->setOperand($criterion);
        $operation->setOperator(Operator::ADD);

        // Create ad group criterion on the server and print out some information.
        $result = $adGroupCriterionService->mutate([$operation]);
        $criterion = $result->getValue()[0];
        printf(
            "Web page criterion with ID %d and status '%s' was created.\n",
            $criterion->getCriterion()->getId(),
            $criterion->getUserStatus()
        );
    }
175773
def CreateCampaign(client, merchant_id, budget_id):
  
  campaign_service = client.GetService('CampaignService', 'v201809')

  campaign = {
      'name': 'Shopping campaign #%d' % uuid.uuid4(),
      # Dynamic remarketing campaigns are only available on the Google Display
      # Network.
      'advertisingChannelType': 'DISPLAY',
      'status': 'PAUSED',
      'budget': {
          'budgetId': budget_id
      },
      # This example uses a Manual CPC bidding strategy, but you should select
      # the strategy that best aligns with your sales goals. More details here:
      # https://support.google.com/adwords/answer/2472725
      'biddingStrategyConfiguration': {
          'biddingStrategyType': 'MANUAL_CPC'
      },
      'settings': [{
          'xsi_type': 'ShoppingSetting',
          # Campaigns with numerically higher priorities take precedence over
          # those with lower priorities.
          'campaignPriority': 0,
          'merchantId': merchant_id,
          # Display network campaigns do not support partition by country. The
          # only supported value is "ZZ". This signals that products from all
          # countries are available in this campaign. The actual products which
          # serve are based on the products tagged in the user list entry.
          'salesCountry': 'ZZ',
          # Optional: Enable local inventory ads (items for sale in physical
          # stores.)
          'enableLocal': True,
      }]
  }

  operations = [{
      'operator': 'ADD',
      'operand': campaign
  }]

  return campaign_service.mutate(operations)['value'][0]
133911
def AddClient(self, client):
    
    keywords = self.AnalyzeClient(client)
    keywords.add(self._NormalizeKeyword(client.client_id))

    data_store.REL_DB.AddClientKeywords(client.client_id, keywords)
179422
def _CreatePerformanceTarget(client, campaign_group_id):
  
  # Get the CampaignGroupPerformanceTargetService.
  cgpt_service = client.GetService('CampaignGroupPerformanceTargetService',
                                   version='v201809')

  # Create the operation.
  operations = [{
      'operator': 'ADD',
      # Create the performance target.
      'operand': {
          'campaignGroupId': campaign_group_id,
          'performanceTarget': {
              # Keep the CPC for the campaigns < $3.
              'efficiencyTargetType': 'CPC_LESS_THAN_OR_EQUAL_TO',
              'efficiencyTargetValue': 3000000,
              # Keep the maximum spend under $50.
              'spendTargetType': 'MAXIMUM',
              'spendTarget': {
                  'microAmount': 500000000
              },
              # Aim for at least 3000 clicks.
              'volumeGoalType': 'MAXIMIZE_CLICKS',
              'volumeTargetValue': 3000,
              # Start the performance target today, and run it for the next 90
              # days.
              'startDate': datetime.datetime.now().strftime('%Y%m%d'),
              'endDate': (datetime.datetime.now() +
                          datetime.timedelta(90)).strftime('%Y%m%d')
          }
      }
  }]

  cgpt = cgpt_service.mutate(operations)['value'][0]

  # Display the results.
  print ('Campaign performance target with ID "%d" was added for campaign '
         'group ID "%d".' % (cgpt['id'], cgpt['campaignGroupId']))
717561
def CreateBiddingStrategy(client):
  
  # Initialize appropriate service.
  bidding_strategy_service = client.GetService(
      'BiddingStrategyService', version='v201809')

  # Create a shared bidding strategy.
  shared_bidding_strategy = {
      'name': 'Maximize Clicks %s' % uuid.uuid4(),
      'biddingScheme': {
          'xsi_type': 'TargetSpendBiddingScheme',
          # Optionally set additional bidding scheme parameters.
          'bidCeiling': {
              'microAmount': '2000000'
          }
      }
  }

  # Create operation.
  operation = {
      'operator': 'ADD',
      'operand': shared_bidding_strategy
  }

  response = bidding_strategy_service.mutate([operation])
  new_bidding_strategy = response['value'][0]

  print ('Shared bidding strategy with name "%s" and ID "%s" of type "%s"'
         'was created.' %
         (new_bidding_strategy['name'], new_bidding_strategy['id'],
          new_bidding_strategy['biddingScheme']['BiddingScheme.Type']))

  return new_bidding_strategy