Removes AdSense and AdSenseHost samples (moved to GitHub)
diff --git a/samples/adsense/README b/samples/adsense/README
index b2f88ac..84c604a 100644
--- a/samples/adsense/README
+++ b/samples/adsense/README
@@ -2,3 +2,4 @@
api: adsense
keywords: cmdline
+uri: https://github.com/googleads/googleads-adsense-examples
diff --git a/samples/adsense/client_secrets.json b/samples/adsense/client_secrets.json
deleted file mode 100644
index 323ffd0..0000000
--- a/samples/adsense/client_secrets.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "installed": {
- "client_id": "[[INSERT CLIENT ID HERE]]",
- "client_secret": "[[INSERT CLIENT SECRET HERE]]",
- "redirect_uris": [],
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
- "token_uri": "https://accounts.google.com/o/oauth2/token"
- }
-}
diff --git a/samples/adsense/generate_report.py b/samples/adsense/generate_report.py
deleted file mode 100644
index e1ca837..0000000
--- a/samples/adsense/generate_report.py
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Retrieves a saved report or a report for the specified ad client.
-
-To get ad clients, run get_all_ad_clients.py.
-
-Tags: reports.generate
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import argparse
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-# Declare command-line flags.
-argparser = argparse.ArgumentParser(add_help=False)
-argparser.add_argument(
- '--ad_client_id',
- help='The ID of the ad client for which to generate a report')
-argparser.add_argument(
- '--report_id',
- help='The ID of the saved report to generate')
-
-
-def main(argv):
- # Authenticate and construct service.
- service, flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[argparser],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- # Process flags and read their values.
- ad_client_id = flags.ad_client_id
- saved_report_id = flags.report_id
-
- try:
- # Retrieve report.
- if saved_report_id:
- result = service.reports().saved().generate(
- savedReportId=saved_report_id).execute()
- elif ad_client_id:
- result = service.reports().generate(
- startDate='2011-01-01', endDate='2011-08-31',
- filter=['AD_CLIENT_ID==' + ad_client_id],
- metric=['PAGE_VIEWS', 'AD_REQUESTS', 'AD_REQUESTS_COVERAGE',
- 'CLICKS', 'AD_REQUESTS_CTR', 'COST_PER_CLICK',
- 'AD_REQUESTS_RPM', 'EARNINGS'],
- dimension=['DATE'],
- sort=['+DATE']).execute()
- else:
- argparser.print_help()
- sys.exit(1)
- # Display headers.
- for header in result['headers']:
- print '%25s' % header['name'],
- print
-
- # Display results.
- for row in result['rows']:
- for column in row:
- print '%25s' % column,
- print
-
- # Display date range.
- print 'Report from %s to %s.' % (result['startDate'], result['endDate'])
- print
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/generate_report_with_paging.py b/samples/adsense/generate_report_with_paging.py
deleted file mode 100644
index 620d9ed..0000000
--- a/samples/adsense/generate_report_with_paging.py
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""This example retrieves a report for the specified ad client.
-
-Please only use pagination if your application requires it due to memory or
-storage constraints.
-If you need to retrieve more than 5000 rows, please check generate_report.py, as
-due to current limitations you will not be able to use paging for large reports.
-To get ad clients, run get_all_ad_clients.py.
-
-Tags: reports.generate
-"""
-
-__author__ = 'sergio.gomes@google.com (Sergio Gomes)'
-
-import argparse
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-MAX_PAGE_SIZE = 50
-# This is the maximum number of obtainable rows for paged reports.
-ROW_LIMIT = 5000
-
-# Declare command-line flags.
-argparser = argparse.ArgumentParser(add_help=False)
-argparser.add_argument(
- 'ad_client_id',
- help='The ID of the ad client for which to generate a report')
-
-
-def main(argv):
- # Authenticate and construct service.
- service, flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[argparser],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- ad_client_id = flags.ad_client_id
-
- try:
- # Retrieve report in pages and display data as we receive it.
- start_index = 0
- rows_to_obtain = MAX_PAGE_SIZE
- while True:
- result = service.reports().generate(
- startDate='2011-01-01', endDate='2011-08-31',
- filter=['AD_CLIENT_ID==' + ad_client_id],
- metric=['PAGE_VIEWS', 'AD_REQUESTS', 'AD_REQUESTS_COVERAGE',
- 'CLICKS', 'AD_REQUESTS_CTR', 'COST_PER_CLICK',
- 'AD_REQUESTS_RPM', 'EARNINGS'],
- dimension=['DATE'],
- sort=['+DATE'],
- startIndex=start_index,
- maxResults=rows_to_obtain).execute()
-
- # If this is the first page, display the headers.
- if start_index == 0:
- for header in result['headers']:
- print '%25s' % header['name'],
- print
-
- # Display results for this page.
- for row in result['rows']:
- for column in row:
- print '%25s' % column,
- print
-
- start_index += len(result['rows'])
-
- # Check to see if we're going to go above the limit and get as many
- # results as we can.
- if start_index + MAX_PAGE_SIZE > ROW_LIMIT:
- rows_to_obtain = ROW_LIMIT - start_index
- if rows_to_obtain <= 0:
- break
-
- if start_index >= int(result['totalMatchedRows']):
- break
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_account_tree.py b/samples/adsense/get_account_tree.py
deleted file mode 100644
index ef38252..0000000
--- a/samples/adsense/get_account_tree.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""This example gets a specific account for the logged in user.
-
-This includes the full tree of sub-accounts.
-
-Tags: accounts.get
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import argparse
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-# Declare command-line flags, and set them as required.
-argparser = argparse.ArgumentParser(add_help=False)
-argparser.add_argument(
- 'account_id',
- help='The ID of the account to use as the root of the tree')
-
-
-def main(argv):
- # Authenticate and construct service.
- service, flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[argparser],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- # Process flags and read their values.
- account_id = flags.account_id
-
- try:
- # Retrieve account.
- request = service.accounts().get(accountId=account_id, tree=True)
- account = request.execute()
-
- if account:
- display_tree(account)
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-
-def display_tree(account, level=0):
- print (' ' * level * 2 +
- 'Account with ID "%s" and name "%s" was found. ' %
- (account['id'], account['name']))
-
- if 'subAccounts' in account:
- for sub_account in account['subAccounts']:
- display_tree(sub_account, level + 1)
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_accounts.py b/samples/adsense/get_all_accounts.py
deleted file mode 100644
index 3683e20..0000000
--- a/samples/adsense/get_all_accounts.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""This example gets all accounts for the logged in user.
-
-Tags: accounts.list
-"""
-
-__author__ = 'sergio.gomes@google.com (Sergio Gomes)'
-
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-MAX_PAGE_SIZE = 50
-
-
-def main(argv):
- # Authenticate and construct service.
- service, unused_flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- try:
- # Retrieve account list in pages and display data as we receive it.
- request = service.accounts().list(maxResults=MAX_PAGE_SIZE)
-
- while request is not None:
- result = request.execute()
- accounts = result['items']
- for account in accounts:
- print ('Account with ID "%s" and name "%s" was found. '
- % (account['id'], account['name']))
-
- request = service.accounts().list_next(request, result)
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_ad_clients.py b/samples/adsense/get_all_ad_clients.py
deleted file mode 100644
index 5bc1ea6..0000000
--- a/samples/adsense/get_all_ad_clients.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""This example gets all ad clients for the logged in user's default account.
-
-Tags: adclients.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-MAX_PAGE_SIZE = 50
-
-
-def main(argv):
- # Authenticate and construct service.
- service, unused_flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- try:
- # Retrieve ad client list in pages and display data as we receive it.
- request = service.adclients().list(maxResults=MAX_PAGE_SIZE)
-
- while request is not None:
- result = request.execute()
- ad_clients = result['items']
- for ad_client in ad_clients:
- print ('Ad client for product "%s" with ID "%s" was found. '
- % (ad_client['productCode'], ad_client['id']))
-
- print ('\tSupports reporting: %s' %
- (ad_client['supportsReporting'] and 'Yes' or 'No'))
-
- request = service.adclients().list_next(request, result)
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_ad_clients_for_account.py b/samples/adsense/get_all_ad_clients_for_account.py
deleted file mode 100644
index 68a2cf1..0000000
--- a/samples/adsense/get_all_ad_clients_for_account.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""This example gets all ad clients for an account.
-
-Tags: accounts.adclients.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import argparse
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-MAX_PAGE_SIZE = 50
-
-# Declare command-line flags.
-argparser = argparse.ArgumentParser(add_help=False)
-argparser.add_argument('account_id',
- help='The ID of the account for which to get ad clients')
-
-
-def main(argv):
- # Authenticate and construct service.
- service, flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[argparser],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- account_id = flags.account_id
-
- try:
- # Retrieve ad client list in pages and display data as we receive it.
- request = service.accounts().adclients().list(accountId=account_id,
- maxResults=MAX_PAGE_SIZE)
-
- while request is not None:
- result = request.execute()
- ad_clients = result['items']
- for ad_client in ad_clients:
- print ('Ad client for product "%s" with ID "%s" was found. '
- % (ad_client['productCode'], ad_client['id']))
-
- print ('\tSupports reporting: %s' %
- (ad_client['supportsReporting'] and 'Yes' or 'No'))
-
- request = service.adclients().list_next(request, result)
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_ad_units.py b/samples/adsense/get_all_ad_units.py
deleted file mode 100644
index b4a273b..0000000
--- a/samples/adsense/get_all_ad_units.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""This example gets all ad units in an ad client.
-
-To get ad clients, run get_all_ad_clients.py.
-
-Tags: adunits.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import argparse
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-# Declare command-line flags.
-argparser = argparse.ArgumentParser(add_help=False)
-argparser.add_argument(
- 'ad_client_id',
- help='The ID of the ad client for which to generate a report')
-
-MAX_PAGE_SIZE = 50
-
-
-def main(argv):
- # Authenticate and construct service.
- service, flags = sample_tools.init(
- argv, 'adsense', 'v1.3', __doc__, __file__, parents=[argparser],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- ad_client_id = flags.ad_client_id
-
- try:
- # Retrieve ad unit list in pages and display data as we receive it.
- request = service.adunits().list(adClientId=ad_client_id,
- maxResults=MAX_PAGE_SIZE)
-
- while request is not None:
- result = request.execute()
- ad_units = result['items']
- for ad_unit in ad_units:
- print ('Ad unit with code "%s", name "%s" and status "%s" was found. ' %
- (ad_unit['code'], ad_unit['name'], ad_unit['status']))
-
- request = service.adunits().list_next(request, result)
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_ad_units_for_custom_channel.py b/samples/adsense/get_all_ad_units_for_custom_channel.py
deleted file mode 100644
index 7bad7b5..0000000
--- a/samples/adsense/get_all_ad_units_for_custom_channel.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""This example gets all ad units corresponding to a specified custom channel.
-
-To get custom channels, run get_all_custom_channels.py.
-
-Tags: accounts.customchannels.adunits.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import argparse
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-# Declare command-line flags.
-argparser = argparse.ArgumentParser(add_help=False)
-argparser.add_argument(
- 'account_id',
- help='The ID of the account with the specified custom channel')
-argparser.add_argument(
- 'ad_client_id',
- help='The ID of the ad client with the specified custom channel')
-argparser.add_argument(
- 'custom_channel_id',
- help='The ID of the custom channel for which to get ad units')
-
-MAX_PAGE_SIZE = 50
-
-
-def main(argv):
- # Authenticate and construct service.
- service, flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[argparser],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- # Process flags and read their values.
- account_id = flags.account_id
- ad_client_id = flags.ad_client_id
- custom_channel_id = flags.custom_channel_id
-
- try:
- # Retrieve ad unit list in pages and display data as we receive it.
- request = service.accounts().customchannels().adunits().list(
- accountId=account_id, adClientId=ad_client_id,
- customChannelId=custom_channel_id, maxResults=MAX_PAGE_SIZE)
-
- while request is not None:
- result = request.execute()
- ad_units = result['items']
- for ad_unit in ad_units:
- print ('Ad unit with code "%s", name "%s" and status "%s" was found. ' %
- (ad_unit['code'], ad_unit['name'], ad_unit['status']))
-
- request = service.adunits().list_next(request, result)
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_alerts.py b/samples/adsense/get_all_alerts.py
deleted file mode 100644
index 100ca24..0000000
--- a/samples/adsense/get_all_alerts.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2013 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Gets all alerts available for the logged in user's default account.
-
-Tags: metadata.alerts.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-
-def main(argv):
- # Authenticate and construct service.
- service, unused_flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[],
- scope='https://www.googleapis.com/auth/adsense')
-
- try:
- # Retrieve alerts list in pages and display data as we receive it.
- request = service.alerts().list()
-
- if request is not None:
- result = request.execute()
- if 'items' in result:
- alerts = result['items']
- for alert in alerts:
- print ('Alert id "%s" with severity "%s" and type "%s" was found. '
- % (alert['id'], alert['severity'], alert['type']))
- # Uncomment to dismiss alert. Note that this cannot be undone.
- # service.alerts().delete(alertId=alert['id']).execute()
- else:
- print 'No alerts found!'
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_custom_channels.py b/samples/adsense/get_all_custom_channels.py
deleted file mode 100644
index 2c51e9a..0000000
--- a/samples/adsense/get_all_custom_channels.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""This example gets all custom channels in an ad client.
-
-To get ad clients, run get_all_ad_clients.py.
-
-Tags: customchannels.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import argparse
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-# Declare command-line flags.
-argparser = argparse.ArgumentParser(add_help=False)
-argparser.add_argument('ad_client_id',
- help='The ad client ID for which to get custom channels')
-
-MAX_PAGE_SIZE = 50
-
-
-def main(argv):
- # Authenticate and construct service.
- service, flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[argparser],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- ad_client_id = flags.ad_client_id
-
- try:
- # Retrieve custom channel list in pages and display data as we receive it.
- request = service.customchannels().list(adClientId=ad_client_id,
- maxResults=MAX_PAGE_SIZE)
-
- while request is not None:
- result = request.execute()
- custom_channels = result['items']
- for custom_channel in custom_channels:
- print ('Custom channel with id "%s" and name "%s" was found. '
- % (custom_channel['id'], custom_channel['name']))
-
- if 'targetingInfo' in custom_channel:
- print ' Targeting info:'
- targeting_info = custom_channel['targetingInfo']
- if 'adsAppearOn' in targeting_info:
- print ' Ads appear on: %s' % targeting_info['adsAppearOn']
- if 'location' in targeting_info:
- print ' Location: %s' % targeting_info['location']
- if 'description' in targeting_info:
- print ' Description: %s' % targeting_info['description']
- if 'siteLanguage' in targeting_info:
- print ' Site language: %s' % targeting_info['siteLanguage']
-
- request = service.customchannels().list_next(request, result)
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_custom_channels_for_ad_unit.py b/samples/adsense/get_all_custom_channels_for_ad_unit.py
deleted file mode 100644
index 4c0a638..0000000
--- a/samples/adsense/get_all_custom_channels_for_ad_unit.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""This example gets all custom channels an ad unit has been added to.
-
-To get ad clients, run get_all_ad_clients.py. To get ad units, run
-get_all_ad_units.py.
-
-Tags: customchannels.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import argparse
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-# Declare command-line flags.
-argparser = argparse.ArgumentParser(add_help=False)
-argparser.add_argument(
- 'account_id',
- help='The ID of the account with the specified ad unit')
-argparser.add_argument(
- 'ad_client_id',
- help='The ID of the ad client with the specified ad unit')
-argparser.add_argument(
- 'ad_unit_id',
- help='The ID of the ad unit for which to get custom channels')
-
-MAX_PAGE_SIZE = 50
-
-
-def main(argv):
- # Authenticate and construct service.
- service, flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[argparser],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- # Process flags and read their values.
- account_id = flags.account_id
- ad_client_id = flags.ad_client_id
- ad_unit_id = flags.ad_unit_id
-
- try:
- # Retrieve custom channel list in pages and display data as we receive it.
- request = service.accounts().adunits().customchannels().list(
- accountId=account_id, adClientId=ad_client_id, adUnitId=ad_unit_id,
- maxResults=MAX_PAGE_SIZE)
-
- while request is not None:
- result = request.execute()
- custom_channels = result['items']
- for custom_channel in custom_channels:
- print ('Custom channel with code "%s" and name "%s" was found. '
- % (custom_channel['code'], custom_channel['name']))
-
- if 'targetingInfo' in custom_channel:
- print ' Targeting info:'
- targeting_info = custom_channel['targetingInfo']
- if 'adsAppearOn' in targeting_info:
- print ' Ads appear on: %s' % targeting_info['adsAppearOn']
- if 'location' in targeting_info:
- print ' Location: %s' % targeting_info['location']
- if 'description' in targeting_info:
- print ' Description: %s' % targeting_info['description']
- if 'siteLanguage' in targeting_info:
- print ' Site language: %s' % targeting_info['siteLanguage']
-
- request = service.customchannels().list_next(request, result)
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_dimensions.py b/samples/adsense/get_all_dimensions.py
deleted file mode 100644
index fe83e76..0000000
--- a/samples/adsense/get_all_dimensions.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2013 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Gets all dimensions available for the logged in user's default account.
-
-Tags: metadata.dimensions.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-
-def main(argv):
- # Authenticate and construct service.
- service, unused_flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- try:
- # Retrieve metrics list in pages and display data as we receive it.
- request = service.metadata().dimensions().list()
-
- if request is not None:
- result = request.execute()
- if 'items' in result:
- dimensions = result['items']
- for dimension in dimensions:
- print ('Dimension id "%s" for product(s): [%s] was found. '
- % (dimension['id'], ', '.join(dimension['supportedProducts'])))
- else:
- print 'No dimensions found!'
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_metrics.py b/samples/adsense/get_all_metrics.py
deleted file mode 100644
index 0ae2811..0000000
--- a/samples/adsense/get_all_metrics.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2013 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Gets all metrics available for the logged in user's default account.
-
-Tags: metadata.metrics.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-
-def main(argv):
- # Authenticate and construct service.
- service, unused_flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- try:
- # Retrieve metrics list in pages and display data as we receive it.
- request = service.metadata().metrics().list()
-
- if request is not None:
- result = request.execute()
- if 'items' in result:
- metrics = result['items']
- for metric in metrics:
- print ('Metric id "%s" for product(s): [%s] was found. '
- % (metric['id'], ', '.join(metric['supportedProducts'])))
- else:
- print 'No metrics found!'
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_payments.py b/samples/adsense/get_all_payments.py
deleted file mode 100644
index a299287..0000000
--- a/samples/adsense/get_all_payments.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2013 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Gets all payments available for the logged in user's default account.
-
-Tags: payments.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-def main(argv):
- # Authenticate and construct service.
- service, unused_flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[],
- scope='https://www.googleapis.com/auth/adsense.readonly')
- try:
- # Retrieve payments list in pages and display data as we receive it.
- request = service.payments().list()
- if request is not None:
- result = request.execute()
- print result
- if 'items' in result:
- payments = result['items']
- for payment in payments:
- print ('Payment with id "%s" of %s %s and date %s was found. '
- % (str(payment['id']),
- payment['paymentAmount'],
- payment['paymentAmountCurrencyCode'],
- payment.get('paymentDate', 'unknown')))
- else:
- print 'No payments found!'
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_saved_ad_styles.py b/samples/adsense/get_all_saved_ad_styles.py
deleted file mode 100644
index bc2e9ed..0000000
--- a/samples/adsense/get_all_saved_ad_styles.py
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Gets all the saved ad styles for the user's default account.
-
-Tags: savedadstyles.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-MAX_PAGE_SIZE = 50
-
-
-def main(argv):
- # Authenticate and construct service.
- service, unused_flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- try:
- # Retrieve ad client list in pages and display data as we receive it.
- request = service.savedadstyles().list(maxResults=MAX_PAGE_SIZE)
-
- while request is not None:
- result = request.execute()
- saved_ad_styles = result['items']
- for saved_ad_style in saved_ad_styles:
- print ('Saved ad style with ID "%s" and background color "#%s" was '
- 'found.'
- % (saved_ad_style['id'],
- saved_ad_style['adStyle']['colors']['background']))
- if ('corners' in saved_ad_style['adStyle']
- and 'font' in saved_ad_style['adStyle']):
- print ('It has "%s" corners and a "%s" size font.' %
- (saved_ad_style['adStyle']['corners'],
- saved_ad_style['adStyle']['font']['size']))
-
- request = service.savedadstyles().list_next(request, result)
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_saved_reports.py b/samples/adsense/get_all_saved_reports.py
deleted file mode 100644
index 6a15f3e..0000000
--- a/samples/adsense/get_all_saved_reports.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Gets all the saved reports for user's default account.
-
-Tags: savedreports.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-MAX_PAGE_SIZE = 50
-
-
-def main(argv):
- # Authenticate and construct service.
- service, unused_flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- try:
- # Retrieve ad client list in pages and display data as we receive it.
- request = service.reports().saved().list(maxResults=MAX_PAGE_SIZE)
-
- while request is not None:
- result = request.execute()
- saved_reports = result['items']
- for saved_report in saved_reports:
- print ('Saved ad style with ID "%s" and name "%s" was found.'
- % (saved_report['id'], saved_report['name']))
-
- request = service.reports().saved().list_next(request, result)
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/samples/adsense/get_all_url_channels.py b/samples/adsense/get_all_url_channels.py
deleted file mode 100644
index 9ffc814..0000000
--- a/samples/adsense/get_all_url_channels.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2011 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""This example gets all URL channels in an ad client.
-
-To get ad clients, run get_all_ad_clients.py.
-
-Tags: urlchannels.list
-"""
-
-__author__ = 'jalc@google.com (Jose Alcerreca)'
-
-import argparse
-import sys
-
-from apiclient import sample_tools
-from oauth2client import client
-
-MAX_PAGE_SIZE = 50
-
-# Declare command-line flags.
-argparser = argparse.ArgumentParser(add_help=False)
-argparser.add_argument('ad_client_id',
- help='The ad client ID for which to get URL channels')
-
-
-def main(argv):
- # Authenticate and construct service.
- service, flags = sample_tools.init(
- argv, 'adsense', 'v1.4', __doc__, __file__, parents=[argparser],
- scope='https://www.googleapis.com/auth/adsense.readonly')
-
- ad_client_id = flags.ad_client_id
-
- try:
- # Retrieve URL channel list in pages and display data as we receive it.
- request = service.urlchannels().list(adClientId=ad_client_id,
- maxResults=MAX_PAGE_SIZE)
-
- while request is not None:
- result = request.execute()
-
- url_channels = result['items']
- for url_channel in url_channels:
- print ('URL channel with URL pattern "%s" was found.'
- % url_channel['urlPattern'])
-
- request = service.customchannels().list_next(request, result)
-
- except client.AccessTokenRefreshError:
- print ('The credentials have been revoked or expired, please re-run the '
- 'application to re-authorize')
-
-if __name__ == '__main__':
- main(sys.argv)