Creates a ProductPartition tree for the given AdGroup ID.

  Args:
    client: an AdWordsClient instance.
    adgroup_id: a str AdGroup ID.

  Returns:
    The ProductPartition tree as a sudsobject.
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']
2314
private static function createAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        Campaign $campaign
    ) {
        $adGroupService = $adWordsServices->get($session, AdGroupService::class);

        // Create ad group.
        $adGroup = new AdGroup();
        $adGroup->setCampaignId($campaign->getId());
        $adGroup->setName('Ad Group #' . uniqid());

        // Required: Set the ad group type to SHOPPING_SHOWCASE_ADS.
        $adGroup->setAdGroupType(AdGroupType::SHOPPING_SHOWCASE_ADS);

        // Required: Set the ad group's bidding strategy configuration.
        // Note: Showcase ads require that the campaign has a ManualCpc
        // BiddingStrategyConfiguration.
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();

        // Optional: Set the bids.
        $bidAmount = new Money();
        $bidAmount->setMicroAmount(100000);
        $cpcBid = new CpcBid();
        $cpcBid->setBid($bidAmount);
        $biddingStrategyConfiguration->setBids([$cpcBid]);

        $adGroup->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

        // Create operation.
        $adGroupOperation = new AdGroupOperation();
        $adGroupOperation->setOperand($adGroup);
        $adGroupOperation->setOperator(Operator::ADD);

        // Make the mutate request.
        $adGroupAddResult = $adGroupService->mutate([$adGroupOperation]);
        $adGroup = $adGroupAddResult->getValue()[0];

        return $adGroup;
    }
284084
def create(self, name, desc):
        
        body = {'security_group': {'name': name,
                                   'description': desc,
                                   'tenant_id': self.request.user.project_id}}
        secgroup = self.client.create_security_group(body)
        return SecurityGroup(secgroup.get('security_group'))
871591
def attach_securitygroup_components(self, group_id, component_ids):
        
        return self.security_group.attachNetworkComponents(component_ids,
                                                           id=group_id)
66192
public static void runExample(AdWordsServicesInterface adWordsServices,
      AdWordsSession session) throws RemoteException {
    // Get the AdGroupBidModifierService.
    AdGroupBidModifierServiceInterface adGroupBidModifierService =
        adWordsServices.get(session, AdGroupBidModifierServiceInterface.class);

    // Create selector.
    Selector selector = new SelectorBuilder()
        .fields(
            AdGroupBidModifierField.CampaignId,
            AdGroupBidModifierField.AdGroupId,
            AdGroupBidModifierField.BidModifier,
            AdGroupBidModifierField.Id)
        .offset(0)
        .limit(PAGE_SIZE)
        .build();

    AdGroupBidModifierPage page = adGroupBidModifierService.get(selector);
    if (page.getEntries() != null) {
      for (AdGroupBidModifier bidModifierResult : page.getEntries()) {
        String bidModifierValue =
            bidModifierResult.getBidModifier() != null
                ? bidModifierResult.getBidModifier().toString()
                : "unset";
        System.out.printf("Campaign ID %d, AdGroup ID %d, Criterion ID %d, "
            + "has ad group level modifier: %s%n",
            bidModifierResult.getCampaignId(),
            bidModifierResult.getAdGroupId(),
            bidModifierResult.getCriterion().getId(),
            bidModifierValue);
      }
    } else {
      System.out.println("No ad group level bid modifiers were found.");
    }
  }
539012
public String getServiceUrlGroup(String version, String service) {
    String[] groups = config.getStringArray("api.adwords.version." + version + ".groups");
    for (String group : groups) {
      String[] services =
          config.getStringArray("api.adwords.version." + version + "." + group + ".services");
      if (Lists.newArrayList(services).contains(service)) {
        return group;
      }
    }
    throw new NullPointerException("No group found for service: " + version + "." + service);
  }
936541
def main(client, adgroup_id):
  """"""
  adgroup_criterion_service = client.GetService(
      'AdGroupCriterionService', version='v201809')

  helper = ProductPartitionHelper(adgroup_id)

  # The most trivial partition tree has only a unit node as the root, e.g.:
  # helper.CreateUnit(bid_amount=100000)

  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, 200000)
  helper.CreateUnit(root, used_product_canonical_condition, 100000)
  other_condition = helper.CreateSubdivision(
      root, other_product_canonical_condition)

  cool_product_brand = {
      'xsi_type': 'ProductBrand',
      'value': 'CoolBrand'
  }

  cheap_product_brand = {
      'xsi_type': 'ProductBrand',
      'value': 'CheapBrand'
  }

  other_product_brand = {
      'xsi_type': 'ProductBrand',
  }

  helper.CreateUnit(other_condition, cool_product_brand, 900000)
  helper.CreateUnit(other_condition, cheap_product_brand, 10000)
  other_brand = helper.CreateSubdivision(other_condition, other_product_brand)

  # The value for the bidding category is a fixed ID for the 'Luggage & Bags'
  # category. You can retrieve IDs for categories from the ConstantDataService.
  # See the 'GetProductTaxonomy' example for more details.
  luggage_category = {
      'xsi_type': 'ProductBiddingCategory',
      'type': 'BIDDING_CATEGORY_L1',
      'value': '-5914235892932915235'
  }

  generic_category = {
      'xsi_type': 'ProductBiddingCategory',
      'type': 'BIDDING_CATEGORY_L1',
  }

  helper.CreateUnit(other_brand, luggage_category, 750000)
  helper.CreateUnit(other_brand, generic_category, 110000)

  # Make the mutate request
  result = adgroup_criterion_service.mutate(helper.GetOperations())

  children = {}

  root_node = None

  # For each criterion, make an array containing each of its children.
  # We always create the parent before the child, so we can rely on that here.
  for adgroup_criterion in result['value']:
    children[adgroup_criterion['criterion']['id']] = []

    if 'parentCriterionId' in adgroup_criterion['criterion']:
      children[adgroup_criterion['criterion']['parentCriterionId']].append(
          adgroup_criterion['criterion'])
    else:
      root_node = adgroup_criterion['criterion']

  # Show the tree
  DisplayTree(root_node, children)
1090572
static AdGroupCriterion createCriterionForRemove(ProductPartitionNode node,
      long adGroupId) {
    Preconditions.checkNotNull(node, "Null node");

    AdGroupCriterion adGroupCriterion = new AdGroupCriterion();
    adGroupCriterion.setAdGroupId(adGroupId);
    adGroupCriterion.setCriterion(new ProductPartition());
    adGroupCriterion.getCriterion().setId(node.getProductPartitionId());

    return adGroupCriterion;
  }
717837
def group(self, groupId):
        
        url = "%s/%s" % (self.root, groupId)
        return Group(url=url,
                     securityHandler=self._securityHandler,
                     proxy_url=self._proxy_url,
                     proxy_port=self._proxy_port,
                     initalize=False)
1078398
def _CreateCampaignGroup(client):
  
  # Get the CampaignGroupService.
  campaign_group_service = client.GetService('CampaignGroupService',
                                             version='v201809')

  # Create the operation.
  operations = [{
      'operator': 'ADD',
      # Create the campaign group.
      'operand': {
          'name': 'Mars campaign group #%d' % uuid.uuid4()
      }
  }]

  campaign_group = campaign_group_service.mutate(operations)['value'][0]
  campaign_group_id = campaign_group['id']

  # Display the results.
  print 'Campaign group with ID "%d" and name "%s" was created.' % (
      campaign_group_id, campaign_group['name'])

  return campaign_group_id
882817
def _CreateAdGroup(client, campaign_id):
  
  ad_group_service = client.GetService('AdGroupService')

  operations = [{
      'operator': 'ADD',
      'operand': {
          'campaignId': campaign_id,
          'adGroupType': 'SEARCH_DYNAMIC_ADS',
          'name': 'Earth to Mars Cruises #%d' % uuid.uuid4(),
          'status': 'PAUSED',
          'biddingStrategyConfiguration': {
              'bids': [{
                  'xsi_type': 'CpcBid',
                  'bid': {
                      'microAmount': '3000000'
                  },
              }]
          }
      }
  }]

  ad_group = ad_group_service.mutate(operations)['value'][0]
  ad_group_id = ad_group['id']

  print 'Ad group with ID "%d" and name "%s" was created.' % (
      ad_group_id, ad_group['name'])

  return ad_group_id
1062996
def create_ad_product_set(name:, filter:)
      query = { name: name, filter: filter.to_json }
      result = AdProductSet.post("/#{id}/product_sets", query: query)
      AdProductSet.find(result['id'])
    end
837448
def AttachUserList(client, ad_group_id, user_list_id):
  
  ad_group_criterion_service = client.GetService(
      'AdGroupCriterionService', 'v201809')

  user_list = {
      'xsi_type': 'CriterionUserList',
      'userListId': user_list_id
  }

  ad_group_criterion = {
      'xsi_type': 'BiddableAdGroupCriterion',
      'criterion': user_list,
      'adGroupId': ad_group_id
  }

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

  return ad_group_criterion_service.mutate(operations)['value'][0]
678294
private static ProductPartitionTree createProductPartitions(
      AdWordsServicesInterface adWordsServices, AdWordsSession session, Long adGroupId)
      throws RemoteException {
    AdGroupCriterionServiceInterface adGroupCriterionService =
        adWordsServices.get(session, AdGroupCriterionServiceInterface.class);

    ProductPartitionTree partitionTree =
        ProductPartitionTree.createAdGroupTree(adWordsServices, session, adGroupId);
    System.out.printf("Original tree: %s%n", partitionTree);

    // Clear out any existing criteria.
    ProductPartitionNode rootNode = partitionTree.getRoot().removeAllChildren();

    // Make the root node a subdivision.
    rootNode = rootNode.asSubdivision();

    // Add a unit node for condition = NEW to include it.
    rootNode
        .addChild(
            ProductDimensions.createCanonicalCondition(ProductCanonicalConditionCondition.NEW))
        .asBiddableUnit();

    // Add a unit node for condition = USED to include it.
    rootNode
        .addChild(
            ProductDimensions.createCanonicalCondition(ProductCanonicalConditionCondition.USED))
        .asBiddableUnit();

    // Exclude everything else.
    rootNode.addChild(ProductDimensions.createCanonicalCondition(null)).asExcludedUnit();

    // Make the mutate request, using the operations returned by the ProductPartitionTree.
    List<AdGroupCriterionOperation> mutateOperations = partitionTree.getMutateOperations();
    if (mutateOperations.isEmpty()) {
      System.out.println(
          "Skipping the mutate call because the original tree and the current "
              + "tree are logically identical.");
    } else {
      adGroupCriterionService.mutate(
          mutateOperations.toArray(new AdGroupCriterionOperation[mutateOperations.size()]));
    }

    // The request was successful, so create a new ProductPartitionTree based on the updated
    // state of the ad group.
    return ProductPartitionTree.createAdGroupTree(adWordsServices, session, adGroupId);
  }
898099
def CreateDefaultPartition(client, ad_group_id):
  
  ad_group_criterion_service = client.GetService('AdGroupCriterionService',
                                                 version='v201809')

  operations = [{
      'operator': 'ADD',
      'operand': {
          'xsi_type': 'BiddableAdGroupCriterion',
          'adGroupId': ad_group_id,
          # Make sure that caseValue and parentCriterionId are left unspecified.
          # This makes this partition as generic as possible to use as a
          # fallback when others don't match.
          'criterion': {
              'xsi_type': 'ProductPartition',
              'partitionType': 'UNIT'
          },
          'biddingStrategyConfiguration': {
              'bids': [{
                  'xsi_type': 'CpcBid',
                  'bid': {
                      'microAmount': 500000
                  }
              }]
          }
      }
  }]

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

  print ('Ad group criterion with ID "%d" in ad group with ID "%d" was added.'
         % (ad_group_criterion['criterion']['id'],
            ad_group_criterion['adGroupId']))
327183
def RootGroup(self):
		

		return(clc.v2.Group(id=self.root_group_id,alias=self.alias,session=self.session))
1162090
def _create_subscription_definition(gg_client, group_type, config):
        
        logging.info('[begin] Configuring routing subscriptions')
        sub_info = gg_client.create_subscription_definition(
            Name="{0}_routing".format(group_type.type_name)
        )
        logging.info('Created subscription definition: {0}'.format(sub_info))

        subs = group_type.get_subscription_definition(config=config)
        if subs is None:
            logging.warning(
                "[end] No SubscriptionDefinition exists in GroupType:{0}".format(
                    group_type.type_name)
            )
            return

        subv = gg_client.create_subscription_definition_version(
            SubscriptionDefinitionId=sub_info['Id'],
            Subscriptions=subs
        )
        sub_arn = subv['Arn']
        config['subscription_def'] = {
            "id": sub_info['Id'],
            "version_arn": sub_arn
        }
        logging.info('[end] Configured routing subscriptions')
        return sub_arn