当前位置: 首页>>代码示例>>Python>>正文


Python AdWordsWebService.AdWordsWebService类代码示例

本文整理汇总了Python中adspygoogle.adwords.AdWordsWebService.AdWordsWebService的典型用法代码示例。如果您正苦于以下问题:Python AdWordsWebService类的具体用法?Python AdWordsWebService怎么用?Python AdWordsWebService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AdWordsWebService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BulkOpportunityService

class BulkOpportunityService(ApiService):

    """Wrapper for BulkOpportunityService.

  The BulkOpportunityService service lets you research opportunities for your
  AdWords account in bulk.
  """

    def __init__(self, headers, config, op_config, lock, logger):
        """Inits BulkOpportunityService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
        url = [op_config["server"], "api/adwords", op_config["version"], self.__class__.__name__]
        if AdWordsSanityCheck.IsJaxbApi(op_config["version"]):
            url.insert(2, "o")
        if config["access"]:
            url.insert(len(url) - 1, config["access"])
        self.__service = AdWordsWebService(headers, config, op_config, "/".join(url), lock, logger)
        self._wsdl_types_map = WSDL_MAP[op_config["version"]][self.__service._GetServiceName()]
        super(BulkOpportunityService, self).__init__(
            headers, config, op_config, url, "adspygoogle.adwords", lock, logger
        )

    def Get(self, selector):
        """Return a page of opportunities.

    Args:
      selector: dict Filter to run opportunities through.

    Returns:
      tuple List of user lists meeting all the criteria of the selector.
    """
        method_name = "getBulkOpportunity"
        SanityCheck.NewSanityCheck(self._wsdl_types_map, selector, "BulkOpportunitySelector")

        if self._config["soap_lib"] == SOAPPY:
            selector = self._message_handler.PackVarAsXml(
                selector, "selector", self._wsdl_types_map, False, "BulkOpportunitySelector"
            )
            return self.__service.CallMethod(
                method_name.split(self.__class__.__name__.split("Service")[0])[0], (selector)
            )
        elif self._config["soap_lib"] == ZSI:
            selector = self._transformation.MakeZsiCompatible(
                selector, "BulkOpportunitySelector", self._wsdl_types_map, self._web_services
            )
            request = eval("self._web_services.%sRequest()" % method_name)
            return self.__service.CallMethod(
                method_name, (({"selector": selector},)), "BulkOpportunity", self._loc, request
            )
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:58,代码来源:BulkOpportunityService.py

示例2: GeoLocationService

class GeoLocationService(ApiService):

  """Wrapper for GeoLocationService.

  The GeoLocationService service provides operations for accessing, modifying,
  and creating campaign ad extension.
  """

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits GeoLocationService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
    url = [op_config['server'], 'api/adwords', op_config['group'],
           op_config['version'], self.__class__.__name__]
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(GeoLocationService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)

  def Get(self, selector):
    """Return a list of geo locationss.

    Args:
      selector: dict Filter to run geo locations through.

    Returns:
      tuple List of geo locations meeting all the criteria of the selector.
    """
    method_name = 'getGeoLocation'
    SanityCheck.NewSanityCheck(
        self._wsdl_types_map, selector, 'GeoLocationSelector')

    if self._config['soap_lib'] == SOAPPY:
      selector = self._message_handler.PackVarAsXml(
          selector, 'selector', self._wsdl_types_map, False,
          'GeoLocationSelector')
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (selector))
    elif self._config['soap_lib'] == ZSI:
      selector = self._transformation.MakeZsiCompatible(
          selector, 'GeoLocationSelector', self._wsdl_types_map,
          self._web_services)
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name, (({'selector': selector},)),
                                       'GeoLocation', self._loc, request)
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:57,代码来源:GeoLocationService.py

示例3: __init__

    def __init__(self, headers, config, op_config, lock, logger):
        """Inits ServicedAccountService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
        url = [op_config["server"], "api/adwords", op_config["group"], op_config["version"], self.__class__.__name__]
        if config["access"]:
            url.insert(len(url) - 1, config["access"])
        self.__service = AdWordsWebService(headers, config, op_config, "/".join(url), lock, logger)
        self._wsdl_types_map = WSDL_MAP[op_config["version"]][self.__service._GetServiceName()]
        super(ServicedAccountService, self).__init__(
            headers, config, op_config, url, "adspygoogle.adwords", lock, logger
        )
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:20,代码来源:ServicedAccountService.py

示例4: __init__

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits GeoLocationService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
    url = [op_config['server'], 'api/adwords', op_config['group'],
           op_config['version'], self.__class__.__name__]
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(GeoLocationService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:21,代码来源:GeoLocationService.py

示例5: __init__

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits TrafficEstimatorService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock
      logger: Logger Instance of Logger
    """
    url = [op_config['server'], 'api/adwords', op_config['version'],
           self.__class__.__name__]
    if AdWordsSanityCheck.IsJaxbApi(op_config['version']): url.insert(2, 'o')
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__name_space = 'https://adwords.google.com/api/adwords'
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(TrafficEstimatorService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:23,代码来源:TrafficEstimatorService.py

示例6: __init__

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits BulkMutateJobService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
    # NOTE(api.sgrinberg): Custom handling for BulkMutateJobService, whose
    # group in URL is 'job/' which is different from its namespace 'cm/'.
    url = [op_config['server'], 'api/adwords', 'job',
           op_config['version'], self.__class__.__name__]
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(BulkMutateJobService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:23,代码来源:BulkMutateJobService.py

示例7: AdParamService

class AdParamService(ApiService):

  """Wrapper for AdParamService.

  The AdParamService service provides operations for accessing, creating,
  modifying, and removing ad parameters.
  """

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits AdParamService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
    url = [op_config['server'], 'api/adwords', op_config['group'],
           op_config['version'], self.__class__.__name__]
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(AdParamService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)

  def Get(self, selector):
    """Return a list of ad params.

    List of ad params specified by the selector from the customer's account.

    Args:
      selector: dict Filter to run ad params through.

    Returns:
      tuple List of ad params meeting all the criteria of the selector.
    """
    method_name = 'getAdParam'
    SanityCheck.NewSanityCheck(
        self._wsdl_types_map, selector, 'AdParamSelector')

    if self._config['soap_lib'] == SOAPPY:
      selector = self._message_handler.PackVarAsXml(
          selector, 'selector', self._wsdl_types_map, False, 'AdParamSelector')
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (selector))
    elif self._config['soap_lib'] == ZSI:
      selector = self._transformation.MakeZsiCompatible(
          selector, 'AdParamSelector', self._wsdl_types_map, self._web_services)
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name, (({'selector': selector},)),
                                       'AdParam', self._loc, request)

  def Mutate(self, ops):
    """Create, update, or remove ad params.

    Args:
      ops: list Unique operations.

    Returns:
      tuple Mutated ad params.
    """
    method_name = 'mutateAdParam'
    SanityCheck.ValidateTypes(((ops, list),))
    for op in ops:
      SanityCheck.NewSanityCheck(self._wsdl_types_map, op, 'AdParamOperation')

    if self._config['soap_lib'] == SOAPPY:
      new_ops = []
      for op in ops:
        new_ops.append(self._message_handler.PackVarAsXml(
            op, 'operations', self._wsdl_types_map, False, 'AdParamOperation'))
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (''.join(new_ops)))
    elif self._config['soap_lib'] == ZSI:
      new_ops = []
      for op in ops:
        new_ops.append(self._transformation.MakeZsiCompatible(
            op, 'AdParamOperation', self._wsdl_types_map,
            self._web_services))
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name,
                                       (({'operations': new_ops},)),
                                       'AdParam', self._loc, request)
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:90,代码来源:AdParamService.py

示例8: TrafficEstimatorService

class TrafficEstimatorService(ApiService):

  """Wrapper for TrafficEstimatorService.

  The TrafficEstimatorService service provides operations for estimating
  campaign, ad group, and keyword traffic.
  """

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits TrafficEstimatorService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock
      logger: Logger Instance of Logger
    """
    url = [op_config['server'], 'api/adwords', op_config['version'],
           self.__class__.__name__]
    if AdWordsSanityCheck.IsJaxbApi(op_config['version']): url.insert(2, 'o')
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__name_space = 'https://adwords.google.com/api/adwords'
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(TrafficEstimatorService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)

  def CheckKeywordTraffic(self, requests):
    """Check a batch of keywords to see whether they will get any traffic.

    Args:
      requests: list Requests for keyword traffic checks.

    Returns:
      tuple Response from the API method.
    """
    SanityCheck.ValidateTypes(((requests, list),))
    for item in requests:
      self._sanity_check.ValidateKeywordTrafficRequestV13(item)

    method_name = 'checkKeywordTraffic'
    if self._config['soap_lib'] == SOAPPY:
      return self.__service.CallMethod(method_name, (requests))
    elif self._config['soap_lib'] == ZSI:
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name, (({'requests': requests},)),
                                       'TrafficEstimator', self._loc, request)

  def EstimateAdGroupList(self, requests):
    """Return traffic estimates for the requested set.

    Set is of new or existing ad groups.

    Args:
      requests: list Set of ad groups to estimate.

    Returns:
      tuple Response from the API method.
    """
    SanityCheck.ValidateTypes(((requests, list),))

    method_name = 'estimateAdGroupList'
    if self._config['soap_lib'] == SOAPPY:
      from adspygoogle.common.soappy import SanityCheck as SoappySanityCheck
      items = []
      for item in requests:
        items.append(self._sanity_check.ValidateAdGroupRequestV13(item))
      requests = SoappySanityCheck.UnType(''.join(items))
      name_space = '/'.join([self.__name_space, self._op_config['version'],
                             self._config['access']]).strip('/')
      requests._setAttr('xmlns:impl', name_space)
      requests._setAttr('xsi3:type', 'AdGroupRequests')
      return self.__service.CallMethod(method_name, (requests))
    elif self._config['soap_lib'] == ZSI:
      for item in requests:
        self._sanity_check.ValidateAdGroupRequestV13(item)
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name,
                                       (({'adGroupRequests': requests},)),
                                       'TrafficEstimator', self._loc, request)

  def EstimateCampaignList(self, requests):
    """Return traffic estimates for the requested set of campaigns.

    Args:
      requests: list Set of campaigns to estimate.

    Returns:
      tuple Response from the API method.
    """
    SanityCheck.ValidateTypes(((requests, list),))

    method_name = 'estimateCampaignList'
    if self._config['soap_lib'] == SOAPPY:
      from adspygoogle.common.soappy import SanityCheck as SoappySanityCheck
#.........这里部分代码省略.........
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:101,代码来源:TrafficEstimatorService.py

示例9: ReportService

class ReportService(ApiService):

  """Wrapper for ReportService.

  The Report Service allows you to request a report about the performance of
  your AdWords campaigns.
  """

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits ReportService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
    url = [op_config['server'], 'api/adwords', op_config['version'],
           self.__class__.__name__]
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__name_space = 'https://adwords.google.com/api/adwords'
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(ReportService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)

  def DeleteReport(self, report_job_id):
    """Delete a report job along with the report it produced, if any.

    Args:
      report_job_id: str ID of the report job.
    """
    SanityCheck.ValidateTypes(((report_job_id, (str, unicode)),))

    method_name = 'deleteReport'
    if self._config['soap_lib'] == SOAPPY:
      from adspygoogle.common.soappy import SanityCheck as SoappySanityCheck
      report_job_id = SoappySanityCheck.UnType(report_job_id)
      self.__service.CallMethod(method_name, (report_job_id))
    elif self._config['soap_lib'] == ZSI:
      request = eval('self._web_services.%sRequest()' % method_name)
      self.__service.CallMethod(method_name,
                                (({'reportJobId': report_job_id},)),
                                'Report', self._loc, request)

  def GetAllJobs(self):
    """Return an array consisting of all jobs the user has scheduled.

    Returns:
      tuple Response from the API method.
    """
    method_name = 'getAllJobs'
    if self._config['soap_lib'] == SOAPPY:
      return self.__service.CallMethod(method_name, ())
    elif self._config['soap_lib'] == ZSI:
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name, (), 'Report', self._loc,
                                       request)

  def GetGzipReportDownloadUrl(self, report_job_id):
    """Return a URL for a compressed report.

    URL from which a compressed report with the given job ID can be downloaded
    (in Gzip format).

    Args:
      report_job_id: str ID of the report job.

    Returns:
      tuple Response from the API method.
    """
    SanityCheck.ValidateTypes(((report_job_id, (str, unicode)),))

    method_name = 'getGzipReportDownloadUrl'
    if self._config['soap_lib'] == SOAPPY:
      from adspygoogle.common.soappy import SanityCheck as SoappySanityCheck
      report_job_id = SoappySanityCheck.UnType(report_job_id)
      return self.__service.CallMethod(method_name, (report_job_id))
    elif self._config['soap_lib'] == ZSI:
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name,
                                       (({'reportJobId': report_job_id},)),
                                       'Report', self._loc, request)

  def GetReportDownloadUrl(self, report_job_id):
    """Return a URL for a report.

    URL from which the report with the given job ID can be downloaded.

    Args:
      report_job_id: str ID of the report job.

    Returns:
      tuple Response from the API method.
    """
#.........这里部分代码省略.........
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:101,代码来源:ReportService.py

示例10: ConversionTrackerService

class ConversionTrackerService(ApiService):

  """Wrapper for ConversionTrackerService.

  The ConversionTrackerService service lets you manage conversion trackers.
  """

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits ConversionTrackerService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
    url = [op_config['server'], 'api/adwords', op_config['version'],
           self.__class__.__name__]
    if AdWordsSanityCheck.IsJaxbApi(op_config['version']): url.insert(2, 'cm')
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(ConversionTrackerService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)

  def Get(self, selector):
    """Return a list of conversion trackers.

    Args:
      selector: dict Filter to run user lists through.

    Returns:
      tuple List of user lists meeting all the criteria of the selector.
    """
    method_name = 'getConversionTracker'
    selector_tag = AdWordsUtils.GetSelectorTag(self._op_config['version'])
    selector_type = AdWordsUtils.GetSelectorType('ConversionTrackerSelector',
                                                 self._op_config['version'])
    SanityCheck.NewSanityCheck(self._wsdl_types_map, selector, selector_type)

    if self._config['soap_lib'] == SOAPPY:
      selector = self._message_handler.PackVarAsXml(
          selector, selector_tag, self._wsdl_types_map, False, selector_type)
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (selector))
    elif self._config['soap_lib'] == ZSI:
      selector = self._transformation.MakeZsiCompatible(
          selector, selector_type, self._wsdl_types_map, self._web_services)
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name,
                                       (({selector_tag: selector},)),
                                       'ConversionTracker', self._loc, request)

  def Mutate(self, ops):
    """Add, update, or remove conversion trackers.

    Args:
      ops: list Unique operations.

    Returns:
      tuple Mutated user lists.
    """
    method_name = 'mutateConversionTracker'
    SanityCheck.ValidateTypes(((ops, list),))
    for op in ops:
      SanityCheck.NewSanityCheck(
          self._wsdl_types_map, op, 'ConversionTrackerOperation')

    if self._config['soap_lib'] == SOAPPY:
      SanityCheck.ValidateTypes(((ops, list),))
      new_ops = []
      for op in ops:
        new_ops.append(self._message_handler.PackVarAsXml(
            op, 'operations', self._wsdl_types_map, False,
            'ConversionTrackerOperation'))
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (''.join(new_ops)))
    elif self._config['soap_lib'] == ZSI:
      new_ops = []
      for op in ops:
        new_ops.append(self._transformation.MakeZsiCompatible(
            op, 'ConversionTrackerOperation', self._wsdl_types_map,
            self._web_services))
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name,
                                       (({'operations': new_ops},)),
                                       'ConversionTracker', self._loc, request)
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:94,代码来源:ConversionTrackerService.py

示例11: MediaService

class MediaService(ApiService):

  """Wrapper for MediaService.

  The MediaService service provides operations for managing media entities.
  """

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits MediaService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
    url = [op_config['server'], 'api/adwords', op_config['group'],
           op_config['version'], self.__class__.__name__]
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(MediaService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)

  def Get(self, selector):
    """Return a list of media objects.

    Args:
      selector: dict Filter to run media objects through.

    Returns:
      tuple List of media objects meeting all the criteria of the selector.
    """
    method_name = 'getMedia'
    selector_tag = AdWordsUtils.GetSelectorTag(self._op_config['version'])
    selector_type = AdWordsUtils.GetSelectorType('MediaSelector',
                                                 self._op_config['version'])
    SanityCheck.NewSanityCheck(self._wsdl_types_map, selector, selector_type)

    if self._config['soap_lib'] == SOAPPY:
      selector = self._message_handler.PackVarAsXml(
          selector, selector_tag, self._wsdl_types_map, False, selector_type)
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (selector))
    elif self._config['soap_lib'] == ZSI:
      selector = self._transformation.MakeZsiCompatible(
          selector, selector_type, self._wsdl_types_map, self._web_services)
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name,
                                       (({selector_tag: selector},)),
                                       'Media', self._loc, request)

  def Upload(self, media):
    """Upload a list of media.

    Args:
      media: list Media objects whose byte data should be uploaded.

    Returns:
      tuple Uploaded media objects.
    """
    method_name = 'upload'
    SanityCheck.ValidateTypes(((media, list),))
    for item in media:
      SanityCheck.NewSanityCheck(self._wsdl_types_map, item, 'Media')

    if self._config['soap_lib'] == SOAPPY:
      new_media = []
      for item in media:
        new_media.append(self._message_handler.PackVarAsXml(
            item, 'media', self._wsdl_types_map, False, 'Media'))
      media = ''.join(new_media)
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (media))
    elif self._config['soap_lib'] == ZSI:
      new_media = []
      for item in media:
        new_media.append(self._transformation.MakeZsiCompatible(
            item, 'Media', self._wsdl_types_map, self._web_services))
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name, (({'media': new_media},)),
                                       'Media', self._loc, request)
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:89,代码来源:MediaService.py

示例12: DataService

class DataService(ApiService):

  """Wrapper for DataService.

  The DataService service lets you retrieve Ads Campaign Management data
  matching a selector.
  """

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits DataService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
    url = [op_config['server'], 'api/adwords', op_config['version'],
           self.__class__.__name__]
    if AdWordsSanityCheck.IsJaxbApi(op_config['version']): url.insert(2, 'cm')
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(DataService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)

  def GetAdGroupBidLandscape(self, selector):
    """Return a list of bid landscapes for the ad groups in the selector.

    Args:
      selector: dict Filter to run bid landscapes through.

    Returns:
      tuple List of bid landscapes meeting all the criteria of the selector.
    """
    method_name = 'getAdGroupBidLandscape'
    SanityCheck.NewSanityCheck(self._wsdl_types_map, selector, 'Selector')

    if self._config['soap_lib'] == SOAPPY:
      selector = self._message_handler.PackVarAsXml(
          selector, 'serviceSelector', self._wsdl_types_map, False, 'Selector')
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (selector))
    elif self._config['soap_lib'] == ZSI:
      selector = self._transformation.MakeZsiCompatible(
          selector, 'Selector', self._wsdl_types_map, self._web_services)
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name,
                                       (({'serviceSelector': selector},)),
                                       'Data', self._loc, request)

  def GetCriterionBidLandscape(self, selector):
    """Return a list of bid landscapes for the criteria in the selector.

    Args:
      selector: dict Filter to run bid landscapes through.

    Returns:
      tuple List of bid landscapes meeting all the criteria of the selector.
    """
    method_name = 'getCriterionBidLandscape'
    SanityCheck.NewSanityCheck(self._wsdl_types_map, selector, 'Selector')

    if self._config['soap_lib'] == SOAPPY:
      selector = self._message_handler.PackVarAsXml(
          selector, 'serviceSelector', self._wsdl_types_map, False, 'Selector')
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (selector))
    elif self._config['soap_lib'] == ZSI:
      selector = self._transformation.MakeZsiCompatible(
          selector, 'Selector', self._wsdl_types_map, self._web_services)
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name,
                                       (({'serviceSelector': selector},)),
                                       'Data', self._loc, request)
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:82,代码来源:DataService.py

示例13: ReportDefinitionService

class ReportDefinitionService(ApiService):

  """Wrapper for ReportDefinitionService.

  The ReportDefinitionService service provides operations for accessing,
  modifying, and creating report definitions.
  """

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits ReportDefinitionService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
    url = [op_config['server'], 'api/adwords', op_config['group'],
           op_config['version'], self.__class__.__name__]
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(ReportDefinitionService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)

  def Get(self, selector):
    """Return a list of report definitions.

    Args:
      selector: dict Filter to run report definitions through.

    Returns:
      tuple List of report definitions meeting all the criteria of the selector.
    """
    method_name = 'getReportDefinition'
    SanityCheck.NewSanityCheck(
        self._wsdl_types_map, selector, 'ReportDefinitionSelector')

    if self._config['soap_lib'] == SOAPPY:
      selector = self._message_handler.PackVarAsXml(
          selector, 'selector', self._wsdl_types_map, False,
          'ReportDefinitionSelector')
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (selector))
    elif self._config['soap_lib'] == ZSI:
      selector = self._transformation.MakeZsiCompatible(
          selector, 'ReportDefinitionSelector', self._wsdl_types_map,
          self._web_services)
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name, (({'selector': selector},)),
                                       'ReportDefinition', self._loc, request)

  def GetReportFields(self, report_type):
    """Return a list of supported report fields.

    Args:
      report_type: str Type of the report.

    Returns:
      tuple List of report fields.
    """
    SanityCheck.ValidateTypes(((report_type, str),))

    method_name = 'getReportFields'
    if self._config['soap_lib'] == SOAPPY:
      report_type = self._message_handler.PackVarAsXml(report_type,
                                                       'reportType')
      return self.__service.CallMethod(
          method_name.split(self.__class__.__name__.split('Service')[0])[0],
          (report_type))
    elif self._config['soap_lib'] == ZSI:
      request = eval('self._web_services.%sRequest()' % method_name)
      return self.__service.CallMethod(method_name,
                                       (({'reportType': report_type},)),
                                       'ReportDefinition', self._loc, request)

  def Mutate(self, ops):
    """Create, update, or remove a report.

    Args:
      ops: list Unique operations.

    Returns:
      tuple Mutated reports.
    """
    method_name = 'mutateReportDefinition'
    SanityCheck.ValidateTypes(((ops, list),))
    for op in ops:
      SanityCheck.NewSanityCheck(
          self._wsdl_types_map, op, 'ReportDefinitionOperation')

    if self._config['soap_lib'] == SOAPPY:
      new_ops = []
      for op in ops:
#.........这里部分代码省略.........
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:101,代码来源:ReportDefinitionService.py

示例14: BulkMutateJobService

class BulkMutateJobService(ApiService):

  """Wrapper for BulkMutateJobService.

  The BulkMutateJobService service provides operations for submitting jobs to be
  executed asynchronously and get information about submitted jobs and their
  parts.
  """

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits BulkMutateJobService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
    # NOTE(api.sgrinberg): Custom handling for BulkMutateJobService, whose
    # group in URL is 'job/' which is different from its namespace 'cm/'.
    url = [op_config['server'], 'api/adwords', 'job',
           op_config['version'], self.__class__.__name__]
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(BulkMutateJobService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)

  def DownloadBulkJob(self, job_id, wait_secs=30, max_polls=60):
    """Return results of the bulk mutate job or None if there was a failure.

    Args:
      job_id: str Bulk mutate job id.
      wait_secs: int Time in seconds to wait between each poll.
      max_polls: int Maximum number of polls to perform.

    Returns:
      list Results of the bulk mutate job or None if there was a failure.
    """
    SanityCheck.ValidateTypes(((job_id, (str, unicode)), (wait_secs, int),
                               (max_polls, int)))

    # Wait for bulk muate job to complete.
    selector = {
        'jobIds': [job_id]
    }
    job = self.Get(selector)[0]
    status = job['status']
    num_parts = job['numRequestParts']
    num_parts_recieved = job['numRequestPartsReceived']

    # Were all parts of the job uploaded?
    if num_parts != num_parts_recieved:
      return None

    num_polls = 1
    while (status != 'COMPLETED' and status != 'FAILED' and
           num_polls < max_polls):
      if Utils.BoolTypeConvert(self._config['debug']):
        print 'Bulk mutate job status: %s' % status
      time.sleep(wait_secs)
      status = self.Get(selector)[0]['status']
      num_polls += 1

    if status != 'COMPLETED' and status != 'FAILED' and num_polls >= max_polls:
      msg = ('The job with id \'%s\' has exceeded max_polls of \'%s\'.'
             % (job_id, max_polls))
      raise AdWordsError(msg)

    if status == 'FAILED':
      if Utils.BoolTypeConvert(self._config['debug']):
        print 'Bulk mutate job failed'
        return None

    if Utils.BoolTypeConvert(self._config['debug']):
      print 'Bulk mutate job completed successfully'

    # Get results for each part of the job.
    res = []
    for part in xrange(int(num_parts)):
      selector = {
          'jobIds': [job_id],
          'resultPartIndex': str(part)
      }
      res.append(self.Get(selector)[0])
    return res

  def Get(self, selector):
    """Return a list of bulk mutate jobs.

    List of bulk mutate jobs specified by a job selector.

    Args:
      selector: dict Filter to run campaign criteria through.

#.........这里部分代码省略.........
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:101,代码来源:BulkMutateJobService.py

示例15: InfoService

class InfoService(ApiService):

  """Wrapper for InfoService.

  The InfoService service allows you to obtain some basic information about your
  API usage.
  """

  def __init__(self, headers, config, op_config, lock, logger):
    """Inits InfoService.

    Args:
      headers: dict Dictionary object with populated authentication
               credentials.
      config: dict Dictionary object with populated configuration values.
      op_config: dict Dictionary object with additional configuration values for
                 this operation.
      lock: thread.lock Thread lock.
      logger: Logger Instance of Logger
    """
    url = [op_config['server'], 'api/adwords', op_config['version'],
           self.__class__.__name__]
    if AdWordsSanityCheck.IsJaxbApi(op_config['version']): url.insert(2, 'info')
    if config['access']: url.insert(len(url) - 1, config['access'])
    self.__service = AdWordsWebService(headers, config, op_config,
                                       '/'.join(url), lock, logger)
    self._wsdl_types_map = WSDL_MAP[op_config['version']][
        self.__service._GetServiceName()]
    super(InfoService, self).__init__(
        headers, config, op_config, url, 'adspygoogle.adwords', lock, logger)

  def GetUnitSummary(self):
    """Retrieve the current status of API units.

    The results are similar to the numbers shown in API Center.

    Returns:
      tuple Collection of API units stats.
    """
    selector = {
        'apiUsageType': 'TOTAL_USAGE_API_UNITS_PER_MONTH'
    }
    total_units = self.Get(selector)[0]['cost']

    selector = {
        'apiUsageType': 'FREE_USAGE_API_UNITS_PER_MONTH'
    }
    free_units_limit = self.Get(selector)[0]['cost']

    selector = {
        'dateRange': {
            'min': datetime.datetime.now().strftime('%Y%m01'),
            'max': datetime.datetime.now().strftime('%Y%m%d')
        },
        'apiUsageType': 'UNIT_COUNT'
    }
    units_count = self.Get(selector)[0]['cost']

    if long(units_count) > long(free_units_limit):
      free_units_used = free_units_limit
    else:
      free_units_used = units_count

    stats = {
        'free_units_used': free_units_used,
        'total_units_used': units_count,
        'free_units_remaining': long(free_units_limit) - long(free_units_used),
        'total_units': total_units
    }
    return (stats,)

  def GetTotalUnitUsed(self):
    """Retrieve the total number of API units used.

    Units used from beggining of time to now.

    Returns:
      tuple Total number of API units used.
    """
    start_date = '20040101'
    end_date = datetime.datetime.now().strftime('%Y%m%d')
    selector = {
        'dateRange': {
            'min': start_date,
            'max': end_date
        },
        'apiUsageType': 'UNIT_COUNT'
    }
    return (self.Get(selector)[0]['cost'],)

  def Get(self, selector):
    """Return the API usage information.

    Usage information is based on the selection criteria of the selector.

    Args:
      selector: dict Filter to run API usage through.

    Returns:
      tuple API usage information.
#.........这里部分代码省略.........
开发者ID:mrcrabby,项目名称:aranciulla,代码行数:101,代码来源:InfoService.py


注:本文中的adspygoogle.adwords.AdWordsWebService.AdWordsWebService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。