Example #1
0
  def Mutate(self, op):
    """Add or update bulk mutate job.

    Args:
      op: dict Operation.

    Returns:
      tuple Mutated bulk mutate job.
    """
    method_name = 'mutateBulkMutateJob'
    AdWordsUtils.TransformJobOperationXsi(op)
    SanityCheck.NewSanityCheck(self._wsdl_types_map, op, 'JobOperation')

    if self._config['soap_lib'] == SOAPPY:
      op = self._message_handler.PackVarAsXml(
          op, 'operation', self._wsdl_types_map, False, 'JobOperation')
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (op))
    elif self._config['soap_lib'] == ZSI:
      op = self._transformation.MakeZsiCompatible(
          op, 'JobOperation', self._wsdl_types_map, self._web_services)
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name, (({'operation': op},)),
                                       'BulkMutateJob', self._loc, request)
  def _TakeActionOnSoapCall(self, method_name, args):
    """Gives the service a chance to take product-specific action on raw inputs.

    AdWords will support legacy xsi_typing for the BulkMutateJobService.

    Args:
      method_name: string The name of the SOAP operation being called.
      args: tuple The arguments passed into the SOAP operation.

    Returns:
      tuple The method arguments, possibly modified.
    """
    if (self._service_name == 'BulkMutateJobService' and
        method_name.lower() == 'mutate'):
      AdWordsUtils.TransformJobOperationXsi(args[0])
    elif (self._service_name == 'UserListService' and
          method_name.lower() == 'mutate'):
      if isinstance(args[0], (list, tuple)):
        for operation in args[0]:
          if isinstance(operation, dict) and 'operand' in operation:
            AdWordsUtils.TransformUserListRuleOperands(operation['operand'])
    return args