Example #1
0
# the following two lines are not needed.
from datetime import date
import os
import sys

sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))
client.strict = False

# Initialize appropriate service.
forecast_service = client.GetService('ForecastService', version='v201211')

# Set the placement that the prospective line item will target.
target_placement_ids = ['INSERT_PLACEMENT_ID_HERE']

# Create prospective line item.
line_item = {
    'targeting': {
        'inventoryTargeting': {
            'targetedPlacementIds': target_placement_ids
        }
    },
    'creativePlaceholders': [{
        'size': {
            'width': '300',
            'height': '250'
Example #2
0
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient


# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
pql_service = client.GetService(
    'PublisherQueryLanguageService', version='v201208')

# Create statement to select all targetable cities.
# A limit of 500 is set here. You may want to page through such a large
# result set.
# For criteria that do not have a "targetable" property, that predicate
# may be left off, i.e. just "SELECT * FROM Browser_Groups LIMIT 500"
select_statement = {'query':
                    'SELECT * FROM City WHERE targetable = true LIMIT 500'}

# Get cities by statement.
result_set = pql_service.Select(select_statement)[0]

# Display results.
if result_set:
  column_labels = [label['labelName'] for label in result_set['columnTypes']]
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient
from adspygoogle.common import Utils

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
placement_service = client.GetService('PlacementService', version='v201206')
inventory_service = client.GetService('InventoryService', version='v201206')

# Create placement object to store medium rectangle ad units.
medium_rectangle_ad_unit_placement = {
    'name': 'Medium rectangle AdUnit Placement #%s' % Utils.GetUniqueName(),
    'description': 'Contains ad units that can hold creatives of size 300x250',
    'targetedAdUnitIds': []
}

# Create placement object to store skyscraper ad units.
skyscraper_ad_unit_placement = {
    'name': 'Skyscraper AdUnit Placement #%s' % Utils.GetUniqueName(),
    'description': 'Contains ad units that can hold creatives of size 120x600',
    'targetedAdUnitIds': []
}
Example #4
0
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys

sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
custom_targeting_service = client.GetService('CustomTargetingService',
                                             version='v201306')

key_id = 'INSERT_CUSTOM_TARGETING_KEY_ID_HERE'
values = [{
    'key': 'keyId',
    'value': {
        'xsi_type': 'NumberValue',
        'value': key_id
    }
}]
filter_statement = {
    'query': 'WHERE customTargetingKeyId = :keyId LIMIT 500',
    'values': values
}

# Get custom targeting values by statement.
Example #5
0
              'Vincent Tsao')

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient
from adspygoogle.dfp import DfpUtils


# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..', '..'))

# Initialize appropriate service.
report_service = client.GetService('ReportService', version='v201308')

# Set the id of the completed report.
report_job_id = 'INSERT_REPORT_JOB_ID_HERE'

# Change to your preferred export format.
export_format = 'CSV_DUMP'

# Download report data.
data = DfpUtils.DownloadReport(report_job_id, export_format, report_service)

# Display results.
print 'Data for report job with id \'%s\':\n%s' % (report_job_id, data)
__author__ = '[email protected] (Jeff Sham)'

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
creative_template_service = client.GetService('CreativeTemplateService',
                                              version='v201306')

# Create statement object to only select system defined creative templates.
values = [{
    'key': 'creativeTemplateType',
    'value': {
        'xsi_type': 'TextValue',
        'value': 'SYSTEM_DEFINED'
    }
}]
filter_statement = {
    'query': 'WHERE type = :creativeTemplateType LIMIT 500',
    'values': values
}

# Get creative templates by statement.
Example #7
0
__author__ = '[email protected] (Jeff Sham)'

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
user_team_association_service = client.GetService('UserTeamAssociationService',
                                                  version='v201204')

# Set the users and team to add them to.
team_id = 'INSERT_TEAM_ID_HERE'
user_ids = ['INSERT_USER_ID_HERE']

user_team_associations = []
for user_id in user_ids:
    user_team_associations.append({'teamId': team_id, 'userId': user_id})

# Create the user team association on the server.
user_team_associations = (user_team_association_service.
                          createUserTeamAssociations(user_team_associations))

# Display results.
if user_team_associations:
Example #8
0
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
from datetime import date
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))
client.strict = False

# Initialize appropriate service.
forecast_service = client.GetService('ForecastService',
                                     'https://www.google.com', 'v201203')

# Set the placement that the prospective line item will target.
target_placement_ids = ['INSERT_PLACEMENT_ID_HERE']

# Create prospective line item.
line_item = {
    'targeting': {
        'inventoryTargeting': {
            'targetedPlacementIds': target_placement_ids
        }
    },
    'creativePlaceholders': [{
        'size': {
            'width': '300',
            'height': '250'
__author__ = '[email protected] (Jeff Sham)'

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient


# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
suggested_ad_unit_service = client.GetService(
    'SuggestedAdUnitService', version='v201204')

# Set the id of the suggested ad unit to get.
suggested_ad_unit_id = 'INSERT_SUGGESTED_AD_UNIT_ID_HERE'

# Get suggested ad unit.
suggested_ad_unit = suggested_ad_unit_service.GetSuggestedAdUnit(
    suggested_ad_unit_id)[0]

# Display results.
print ('Suggested ad unit with id \'%s\' and number of requests \'%s\' was '
       'found.') % (suggested_ad_unit['id'], suggested_ad_unit['numRequests'])
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient
from adspygoogle.dfp import DfpUtils

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..', '..'))

# Initialize appropriate service.
activity_service = client.GetService('ActivityService', version='v201311')

# Create statement object to only select active activities.
values = [{
    'key': 'status',
    'value': {
        'xsi_type': 'TextValue',
        'value': 'ACTIVE'
    }
}]

query = 'WHERE status = :status'

# Get activities by statement.
activities = DfpUtils.GetAllEntitiesByStatementWithService(activity_service,
                                                           query=query,
Example #11
0
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient


# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
content_service = client.GetService('ContentService', version='v201208')

network_service = client.GetService('NetworkService', version='v201208')

custom_targeting_service = client.GetService(
    'CustomTargetingService', version='v201208')

# Get the network's content browse custom targeting key.
network = network_service.GetCurrentNetwork()[0]
key_id = network['contentBrowseCustomTargetingKeyId']

# Create a statement to select the categories matching the name comedy.
values = [
    {
        'key': 'contentBrowseCustomTargetingKeyId',
        'value': {
Example #12
0
__author__ = '[email protected] (Jeff Sham)'

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
creative_service = client.GetService('CreativeService',
                                     'https://www.google.com', 'v201203')

# Create statement object to get all image creatives.
values = [{
    'key': 'type',
    'value': {
        'xsi_type': 'TextValue',
        'value': 'ImageCreative'
    }
}]
filter_statement = {
    'query': 'WHERE creativeType = :type LIMIT 500',
    'values': values
}

# Get creatives by statement.
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))
import time

# Import appropriate classes from the client library.
from adspygoogle import DfpClient
from adspygoogle.dfp import DfpUtils


# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate services.
line_item_service = client.GetService('LineItemService', version='v201208')
report_service = client.GetService('ReportService', version='v201208')

# Set the ID of the order to get line items from.
order_id = 'INSERT_ORDER_ID_HERE'

# Filter for line items of a given order.
values = [{
    'key': 'orderId',
    'value': {
        'xsi_type': 'NumberValue',
        'value': order_id
    }
}]
query = 'WHERE orderId = :orderId'
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

SUGGESTED_PAGE_LIMIT = 500

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..', '..'))

# Initialize appropriate service.
audience_segment_service = client.GetService('AudienceSegmentService',
                                             version='v201311')

# Get all audience segments.
offset, result_set_size = 0, 0

while True:
    # Create a statement to select audience segments.
    filter_statement = {
        'query': 'LIMIT %s OFFSET %s' % (SUGGESTED_PAGE_LIMIT, offset)
    }

    response = audience_segment_service.getAudienceSegmentsByStatement(
        filter_statement)[0]

    if 'results' in response:
        segments = response['results']
"""

__author__ = '[email protected] (Jeff Sham)'

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient
from adspygoogle.dfp import DfpUtils

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..', '..'))

# Initialize appropriate service.
team_service = client.GetService('TeamService', version='v201311')

# Get team by statement.
teams = DfpUtils.GetAllEntitiesByStatementWithService(team_service)

# Display results.
for team in teams:
    print('Team with ID \'%s\' and name \'%s\' was found.' %
          (team['id'], team['name']))

print
print 'Number of results found: %s' % len(teams)
__author__ = '[email protected] (Jeff Sham)'

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
order_service = client.GetService('OrderService', 'https://www.google.com',
                                  'v201203')

# Set id of the advertiser (company) to get orders for.
advertiser_id = 'INSERT_ADVERTISER_COMPANY_ID_HERE'

# Create statement object to get all orders for a given advertiser.
values = [{
    'key': 'advertiserId',
    'value': {
        'xsi_type': 'NumberValue',
        'value': advertiser_id
    }
}]
filter_statement = {
    'query': 'WHERE advertiserId = :advertiserId LIMIT 500',
    'values': values
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient


# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
third_party_slot_service = client.GetService(
    'ThirdPartySlotService', version='v201208')

company_id = 'INSERT_COMPANY_ID_HERE'
external_unique_id = 'INSERT_EXTERNAL_UNIQUE_ID_HERE'
external_unique_name = 'INSERT_EXTERNAL_UNIQUE_NAME_HERE'
creative_ids = ['INSERT_CREATIVE_ID_HERE']

# Create a third party slot object.
third_party_slot = {
    'companyId': company_id,
    'description': 'Third party slot description.',
    'externalUniqueId': external_unique_id,
    'externalUniqueName': external_unique_name,
    'creativeIds': creative_ids
}
Example #18
0
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys

sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
third_party_slot_service = client.GetService('ThirdPartySlotService',
                                             'https://www.google.com',
                                             'v201203')

company_id = 'INSERT_COMPANY_ID_HERE'
external_unique_id = 'INSERT_EXTERNAL_UNIQUE_ID_HERE'
external_unique_name = 'INSERT_EXTERNAL_UNIQUE_NAME_HERE'
creative_ids = ['INSERT_CREATIVE_ID_HERE']

# Create a third party slot object.
third_party_slot = {
    'companyId': company_id,
    'description': 'Third party slot description.',
    'externalUniqueId': external_unique_id,
    'externalUniqueName': external_unique_name,
    'creativeIds': creative_ids
}
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient
from adspygoogle.dfp import DfpUtils

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
lica_service = client.GetService('LineItemCreativeAssociationService',
                                 version='v201208')

# Set the id of the line item in which to deactivate LICAs.
line_item_id = 'INSERT_LINE_ITEM_ID_HERE'

# Create query.
values = [{
    'key': 'lineItemId',
    'value': {
        'xsi_type': 'NumberValue',
        'value': line_item_id
    }
}, {
    'key': 'status',
    'value': {
        'xsi_type': 'TextValue',
Example #20
0
video publishers."""

__author__ = '[email protected] (Jeff Sham)'

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient
from adspygoogle.dfp import DfpUtils

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..', '..'))

# Initialize appropriate service.
content_service = client.GetService('ContentService', version='v201311')

# Get content by statement.
content = DfpUtils.GetAllEntitiesByStatementWithService(content_service)

# Display results.
for content_item in content:
    print('Content with id \'%s\', name \'%s\', and status \'%s\' was found.' %
          (content_item['id'], content_item['name'], content_item['status']))

print
print 'Number of results found: %s' % len(content)
Example #21
0
"""This code example gets an order by its id. To determine which orders exist,
run get_all_orders.py."""

__author__ = '[email protected] (Jeff Sham)'

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys

sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
order_service = client.GetService('OrderService', version='v201302')

# Set the id of the order to get.
order_id = 'INSERT_ORDER_ID_HERE'

# Get order.
order = order_service.GetOrder(order_id)[0]

# Display results.
print('Order with id \'%s\', name \'%s\', and advertiser id \'%s\' was '
      'found.' % (order['id'], order['name'], order['advertiserId']))
        'name': 'Mobile_ad_unit_%s' % Utils.GetUniqueName(),
        'parentId': parent_id,
        'description': 'Mobile ad unit description.',
        'targetWindow': 'BLANK',
        'targetPlatform': 'MOBILE',
        'adUnitSizes': [ad_unit_size]
    }

    # Add ad units.
    ad_units = inventory_service.CreateAdUnits([web_ad_unit, mobile_ad_unit])

    # Display results.
    for ad_unit in ad_units:
        print(
            'Ad unit with ID \'%s\', name \'%s\', and target platform \'%s\' '
            'was created.' %
            (ad_unit['id'], ad_unit['name'], ad_unit['targetPlatform']))


if __name__ == '__main__':
    # Initialize client object.
    dfp_client = DfpClient(path=os.path.join('..', '..', '..', '..', '..'))

    # Get the Network Service.
    network_service = dfp_client.GetService('NetworkService',
                                            version='v201204')

    # Set the parent ad unit's ID for all ad units to be created under.
    parent_id = network_service.GetCurrentNetwork()[0]['effectiveRootAdUnitId']
    main(dfp_client, parent_id)
Example #23
0
# limitations under the License.

"""This code example gets all roles. This sample can be used to determine which
role id is needed when getting and creating users."""

__author__ = '[email protected] (Jeff Sham)'

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient


# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
user_service = client.GetService('UserService', version='v201306')

# Get all roles.
roles = user_service.GetAllRoles()

# Display results.
for role in roles:
  print ('Role with id \'%s\' and name \'%s\' was found.'
         % (role['id'], role['name']))
Example #24
0
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient


# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
lica_service = client.GetService(
    'LineItemCreativeAssociationService', 'https://www.google.com', 'v201203')
creative_service = client.GetService(
    'CreativeService', 'https://www.google.com', 'v201203')

# Set the line item ID and creative IDs to associate.
line_item_id = 'INSERT_LINE_ITEM_ID_HERE'
order_id = 'INSERT_ORDER_ID_HERE'
creative_ids = ['INSERT_CREATIVE_ID_HERE']

licas = []
for creative_id in creative_ids:
  licas.append({'creativeId': creative_id,
                'lineItemId': line_item_id})

# Create the LICAs remotely.
licas = lica_service.CreateLineItemCreativeAssociations(licas)
create_creatives.py."""

__author__ = ('Jeff Sham', 'Vincent Tsao')

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient
from adspygoogle.dfp import DfpUtils

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..', '..'))

# Initialize appropriate service.
creative_service = client.GetService('CreativeService', version='v201308')

# Get creatives by statement.
creatives = DfpUtils.GetAllEntitiesByStatementWithService(creative_service)

# Display results.
for creative in creatives:
    print('Creative with id \'%s\', name \'%s\', and type \'%s\' was found.' %
          (creative['id'], creative['name'], creative['Creative_Type']))

print
print 'Number of results found: %s' % len(creatives)
Example #26
0
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient


# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
label_service = client.GetService(
    'LabelService', 'https://www.google.com', 'v201203')

# Create a statement to select only active labels.
values = [
    {
        'key': 'isActive',
        'value': {
            'xsi_type': 'BooleanValue',
            'value': 'true'
        }
    }
]

filter_statement = {
    'query': 'WHERE isActive = :isActive LIMIT 500',
    'values': values}
exist, run get_all_line_items.py."""

__author__ = ('Jeff Sham', 'Vincent Tsao')

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys

sys.path.insert(0, os.path.join('..', '..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..', '..'))

# Initialize appropriate service.
line_item_service = client.GetService('LineItemService', version='v201302')

# Set the id of the line item to get.
line_item_id = 'INSERT_LINE_ITEM_ID_HERE'

# Get company.
line_item = line_item_service.GetLineItem(line_item_id)[0]

# Display results.
print('Line item with id \'%s\', belonging to order id \'%s\', and named '
      '\'%s\' was found.' %
      (line_item['id'], line_item['orderId'], line_item['name']))
            'oauth2credentials': credential
        })

    # OAuth2 credentials objects can be reused
    credentials = client.oauth2credentials
    print 'OAuth2 authorization successful!'

    # OAuth2 credential objects can be refreshed via credentials.refresh() - the
    # access token expires after 1 hour.
    credentials.refresh(httplib2.Http())

    # Note: you could simply set the credentials as below and skip the previous
    # steps once access has been granted.
    client.oauth2credentials = credentials

    network_service = client.GetService('NetworkService', version='v201208')

    # Get all networks that you have access to with the current login credentials.
    networks = network_service.GetAllNetworks()

    for network in networks:
        print(
            'Network with network code \'%s\' and display name \'%s\' was found.'
            % (network['networkCode'], network['displayName']))

    print
    print 'Number of results found: %s' % len(networks)


if __name__ == '__main__':
    main(APPLICATION_NAME, NETWORK_CODE, OAUTH2_CLIENT_ID,
__author__ = '[email protected] (Jeff Sham)'

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
label_service = client.GetService('LabelService', version='v201302')

# Create label objects.
labels = []
for i in xrange(5):
    label = {
        'name': 'Label #%d' % i,
        'isActive': 'true',
        'types': ['COMPETITIVE_EXCLUSION']
    }
    labels.append(label)

# Add Labels.
labels = label_service.CreateLabels(labels)

# Display results.
Example #30
0
__author__ = '[email protected] (Jeff Sham)'

# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfpClient

# Initialize client object.
client = DfpClient(path=os.path.join('..', '..', '..', '..'))

# Initialize appropriate service.
inventory_service = client.GetService('InventoryService',
                                      'https://www.google.com', 'v201203')

target_platform = 'WEB'

# Create statement object to only select web ad unit sizes.
values = [{
    'key': 'targetPlatform',
    'value': {
        'xsi_type': 'TextValue',
        'value': target_platform
    }
}]
filter_statement = {
    'query': 'WHERE targetPlatform = :targetPlatform',
    'values': values
}