Creates a performance target for the campaign group.

  Args:
    client: an AdWordsClient instance.
    campaign_group_id: an integer ID for the campaign group.
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']))
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)
914607
def search_client_by_id(self, clientID) -> Client:
        
        for c in self.clients:
            if c.id == clientID:
                return c
        return None
960587
def client(self, *args, **kwargs):
        

        return self._makeApiCall(self.funcinfo["client"], *args, **kwargs)
183800
def get_campaign(self, campaign_id):
        
        api = self._get_api(update_service.DefaultApi)
        return Campaign(api.update_campaign_retrieve(campaign_id))
1370570
def group_is_client_group(self) -> bool:
        
        # TODO create test
        first_unit = self.get_unit_by_index(1)
        if first_unit:
            return first_unit.skill == 'Client'

        return False
1193962
private static function setCampaignTargetingCriteria(
        $campaignId,
        AdWordsServices $adWordsServices,
        AdWordsSession $session
    ) {
        $campaignCriterionService = $adWordsServices->get($session, CampaignCriterionService::class);

        $campaignCriteria = [];
        // Create locations. The IDs can be found in the documentation or retrieved
        // with the LocationCriterionService.
        $california = new Location();
        $california->setId(21137);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $california);

        $mexico = new Location();
        $mexico->setId(2484);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $mexico);

        // Create languages. The IDs can be found in the documentation or retrieved
        // with the ConstantDataService.
        $english = new Language();
        $english->setId(1000);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $english);

        $spanish = new Language();
        $spanish->setId(1003);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $spanish);

        // Create operations to add each of the criteria above.
        $operations = [];
        foreach ($campaignCriteria as $campaignCriterion) {
            $operation = new CampaignCriterionOperation();
            $operation->setOperand($campaignCriterion);
            $operation->setOperator(Operator::ADD);
            $operations[] = $operation;
        }

        // Set the campaign targets.
        $result = $campaignCriterionService->mutate($operations);

        // Display added campaign targets.
        foreach ($result->getValue() as $campaignCriterion) {
            printf(
                "Campaign criterion of type '%s' and ID %d was added.\n",
                $campaignCriterion->getCriterion()->getType(),
                $campaignCriterion->getCriterion()->getId()
            );
        }
    }
561022
def get_client(self, client_id):
        ''''''
        client_response = self.get_request('clients/%s' % client_id)
        return Client(self, client_response['client'])
1161142
def _CreateBudget(client):
  
  budget_service = client.GetService('BudgetService', version='v201809')

  # Create the campaign budget
  operation = {
      'operand': {
          'name': 'Interplanetary Cruise Budget #%d' % uuid.uuid4(),
          'deliveryMethod': 'STANDARD',
          'amount': {
              'microAmount': 500000
          }
      },
      'operator': 'ADD'
  }

  budget = budget_service.mutate([operation])['value'][0]

  print 'Budget with ID "%d" and name "%s" was created.' % (
      budget['budgetId'], budget['name'])

  return budget
316788
def _CreateExpandedDSA(client, ad_group_id):
  
  # Get the AdGroupAdService.
  ad_group_ad_service = client.GetService('AdGroupAdService')

  # Create the operation
  operations = [{
      'operator': 'ADD',
      'operand': {
          'xsi_type': 'AdGroupAd',
          'adGroupId': ad_group_id,
          # Create the expanded dynamic search ad. This ad will have its
          # headline and final URL auto-generated at serving time according to
          # domain name specific information provided by DynamicSearchAdsSetting
          # at the campaign level.
          'ad': {
              'xsi_type': 'ExpandedDynamicSearchAd',
              # Set the ad description.
              'description': 'Buy your tickets now!',
              'description2': 'Discount ends soon'
          },
          # Optional: Set the status.
          'status': 'PAUSED',
      }
  }]

  # Create the ad.
  ad = ad_group_ad_service.mutate(operations)['value'][0]['ad']

  # Display the results.
  print ('Expanded dynamic search ad with ID "%d", description "%s", and '
         'description 2 "%s" was added'
         % (ad['id'], ad['description'], ad['description2']))
1276566
private static Campaign createCampaign(
      AdWordsServicesInterface adWordsServices,
      AdWordsSession session,
      Long budgetId,
      Long merchantId)
      throws RemoteException {
    // Get the CampaignService
    CampaignServiceInterface campaignService =
        adWordsServices.get(session, CampaignServiceInterface.class);

    // Create campaign.
    Campaign campaign = new Campaign();
    campaign.setName("Shopping campaign #" + System.currentTimeMillis());
    // The advertisingChannelType is what makes this a Shopping campaign
    campaign.setAdvertisingChannelType(AdvertisingChannelType.SHOPPING);

    // Recommendation: Set the campaign to PAUSED when creating it to prevent
    // the ads from immediately serving. Set to ENABLED once you've added
    // targeting and the ads are ready to serve.
    campaign.setStatus(CampaignStatus.PAUSED);

    // Set shared budget (required).
    Budget budget = new Budget();
    budget.setBudgetId(budgetId);
    campaign.setBudget(budget);

    // Set bidding strategy (required).
    BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
    biddingStrategyConfiguration.setBiddingStrategyType(BiddingStrategyType.MANUAL_CPC);
    campaign.setBiddingStrategyConfiguration(biddingStrategyConfiguration);

    // All Shopping campaigns need a ShoppingSetting.
    ShoppingSetting shoppingSetting = new ShoppingSetting();
    shoppingSetting.setSalesCountry("US");
    shoppingSetting.setCampaignPriority(0);
    shoppingSetting.setMerchantId(merchantId);

    // Set to 'true' to enable Local Inventory Ads in your campaign.
    shoppingSetting.setEnableLocal(true);

    campaign.setSettings(new Setting[] {shoppingSetting});

    // Create operation.
    CampaignOperation campaignOperation = new CampaignOperation();
    campaignOperation.setOperand(campaign);
    campaignOperation.setOperator(Operator.ADD);

    // Make the mutate request.
    CampaignReturnValue campaignAddResult =
        campaignService.mutate(new CampaignOperation[] {campaignOperation});

    return campaignAddResult.getValue(0);
  }
913508
public void setClient(AerospikeClient client) {
		this.client = client;
		this.updatePolicy = new WritePolicy(this.client.writePolicyDefault);
		this.updatePolicy.recordExistsAction = RecordExistsAction.UPDATE_ONLY;
		this.insertPolicy = new WritePolicy(this.client.writePolicyDefault);
		this.insertPolicy.recordExistsAction = RecordExistsAction.CREATE_ONLY;
		this.queryPolicy = client.queryPolicyDefault;
		refreshCluster();
		registerUDF();
	}
421187
def GetCampaigns(self, client_customer_id):
    
    self.client.SetClientCustomerId(client_customer_id)
    # A somewhat hackish workaround for "The read operation timed out" error,
    # which could be triggered on AppEngine's end if the request is too large
    # and is taking too long.
    max_tries = 3
    today = time.strftime('%Y%m%d', time.localtime())
    for i in xrange(1, max_tries + 1):
      try:
        selector = {
            'fields': ['Id', 'Name', 'Status', 'BudgetId', 'Amount'],
            'predicates': [
                {
                    'field': 'Status',
                    'operator': 'NOT_EQUALS',
                    'values': ['REMOVED']
                }
            ],
            'dateRange': {
                'min': today,
                'max': today
            }
        }
        campaigns = self.client.GetService('CampaignService').get(selector)
        if int(campaigns['totalNumEntries']) > 0:
          return campaigns['entries']
        else:
          return None
      except Exception, e:
        if i == max_tries:
          raise GoogleAdsError(e)
        continue
1372377
def _AddCampaignsToGroup(client, campaign_group_id, campaign_ids):
  
  # Get the CampaignService.
  campaign_service = client.GetService('CampaignService', version='v201809')

  # Create the operations.
  operations = [{
      'operator': 'SET',
      'operand': {
          'id': campaign_id,
          'campaignGroupId': campaign_group_id
      }
  } for campaign_id in campaign_ids]

  campaign_service.mutate(operations)

  # Display the results.
  print ('The following campaign IDs were added to the campaign group with ID '
         '"%d":\n\t%s' % (campaign_group_id, campaign_ids))
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()
809084
def _CreateCampaign(client, budget):
  
  campaign_service = client.GetService('CampaignService')

  operations = [{
      'operator': 'ADD',
      'operand': {
          'name': 'Interplanetary Cruise #%d' % uuid.uuid4(),
          # Recommendation: Set the campaign to PAUSED when creating it to
          # prevent the ads from immediately serving. Set to ENABLED once you've
          # added targeting and the ads are ready to serve.
          'status': 'PAUSED',
          'advertisingChannelType': 'SEARCH',
          'biddingStrategyConfiguration': {
              'biddingStrategyType': 'MANUAL_CPC',
          },
          'budget': budget,
          # Required: Set the campaign's Dynamic Search Ad settings.
          'settings': [{
              'xsi_type': 'DynamicSearchAdsSetting',
              # Required: Set the domain name and language.
              'domainName': 'example.com',
              'languageCode': 'en'
          }],
          # Optional: Set the start date.
          'startDate': (datetime.datetime.now() +
                        datetime.timedelta(1)).strftime('%Y%m%d'),
          # Optional: Set the end date.
          'endDate': (datetime.datetime.now() +
                      datetime.timedelta(365)).strftime('%Y%m%d'),
      }
  }]

  campaign = campaign_service.mutate(operations)['value'][0]
  campaign_id = campaign['id']

  print 'Campaign with ID "%d" and name "%s" was added.' % (
      campaign_id, campaign['name'])

  return campaign_id
562021
def SetCampaignTargetingCriteria(client, campaign):
  
  campaign_criterion_service = client.GetService('CampaignCriterionService')

  # Create locations. The IDs can be found in the documentation or retrieved
  # with the LocationCriterionService.
  criteria = [
      {
          'xsi_type': 'Location',
          'id': 21137  # California
      },
      {
          'xsi_type': 'Location',
          'id': 2484  # Mexico
      },
      {
          'xsi_type': 'Language',
          'id': 1000  # English
      },
      {
          'xsi_type': 'Language',
          'id': 1003  # Spanish
      }
  ]

  operations = [{
      'operator': 'ADD',
      'operand': {
          'campaignId': campaign['id'],
          'criterion': criterion
      }
  } for criterion in criteria]

  response = campaign_criterion_service.mutate(operations)

  if response and 'value' in response:
    # Display the added campaign targets.
    for criterion in response['value']:
      print ('Campaign criteria of type "%s" and id "%s" was added.'
             % (criterion['criterion']['type'],
                criterion['criterion']['id']))