<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 1. Install Dependencies
First install the libraries needed to execute recipes, this only needs to be done once, then click play.
Step1:  2. Get Cloud Project ID
To run this recipe requires a Google Cloud Project, this only needs to be done once, then click play.
Step2:  3. Get Client Credentials
To read and write to various endpoints requires downloading client credentials, this only needs to be done once, then click play.
Step3:  4. Enter DV360 API To BigQuery Parameters
Write the current state of advertisers, campaigns, sites, insertion orders, and line items to BigQuery for a given list of DV360 accounts.
 1. Specify the name of the dataset, several tables will be created here.
 1. If dataset exists, it is unchanged.
 1. Add DV360 advertiser ids for the accounts to pull data from.
Modify the values below for your use case, can be done multiple times, then click play.
Step4:  5. Execute DV360 API To BigQuery
This does NOT need to be modified unles you are changing the recipe, click play.
<ASSISTANT_TASK:>
Python Code:
!pip install git+https://github.com/google/starthinker
Explanation: 1. Install Dependencies
First install the libraries needed to execute recipes, this only needs to be done once, then click play.
End of explanation
CLOUD_PROJECT = 'PASTE PROJECT ID HERE'
print("Cloud Project Set To: %s" % CLOUD_PROJECT)
Explanation: 2. Get Cloud Project ID
To run this recipe requires a Google Cloud Project, this only needs to be done once, then click play.
End of explanation
CLIENT_CREDENTIALS = 'PASTE CREDENTIALS HERE'
print("Client Credentials Set To: %s" % CLIENT_CREDENTIALS)
Explanation: 3. Get Client Credentials
To read and write to various endpoints requires downloading client credentials, this only needs to be done once, then click play.
End of explanation
FIELDS = {
  'endpoint': '',
  'auth_read': 'user',  # Credentials used for reading data.
  'auth_write': 'service',  # Credentials used for writing data.
  'dataset': '',  # Google BigQuery dataset to create tables in.
  'partners': [],  # Comma separated partners ids.
  'advertisers': [],  # Comma separated advertisers ids.
}
print("Parameters Set To: %s" % FIELDS)
Explanation: 4. Enter DV360 API To BigQuery Parameters
Write the current state of advertisers, campaigns, sites, insertion orders, and line items to BigQuery for a given list of DV360 accounts.
 1. Specify the name of the dataset, several tables will be created here.
 1. If dataset exists, it is unchanged.
 1. Add DV360 advertiser ids for the accounts to pull data from.
Modify the values below for your use case, can be done multiple times, then click play.
End of explanation
from starthinker.util.project import project
from starthinker.script.parse import json_set_fields
USER_CREDENTIALS = '/content/user.json'
TASKS = [
  {
    'dv360_api': {
      'auth': 'user',
      'endpoints': {'field': {'name': 'endpoint','kind': 'choice','choices': ['advertisers','advertisers.campaigns','advertisers.channels','advertisers.channels.sites','advertisers.creatives','advertisers.insertionOrders','advertisers.lineItems','advertisers.lineItems.targetingTypes','advertisers.locationLists','advertisers.locationLists.assignedLocations','advertisers.negativeKeywordLists','advertisers.negativeKeywordLists.negativeKeywords','advertisers.targetingTypes.assignedTargetingOptions','combinedAudiences','customBiddingAlgorithms','customLists','firstAndThirdPartyAudiences','floodlightGroups','googleAudiences','inventorySourceGroups','inventorySourceGroups.assignedInventorySources','inventorySources','partners','partners.channels','partners.channels.sites','floodlightActivityGroups','partners.targetingTypes.assignedTargetingOptions','targetingTypes.targetingOptions','users'],'default': ''}},
      'partners': {
        'single_cell': True,
        'values': {'field': {'name': 'partners','kind': 'integer_list','order': 2,'default': [],'description': 'Comma separated partners ids.'}}
      },
      'advertisers': {
        'single_cell': True,
        'values': {'field': {'name': 'advertisers','kind': 'integer_list','order': 2,'default': [],'description': 'Comma separated advertisers ids.'}}
      },
      'out': {
        'auth': 'user',
        'dataset': {'field': {'name': 'dataset','kind': 'string','order': 1,'default': '','description': 'Google BigQuery dataset to create tables in.'}}
      }
    }
  }
]
json_set_fields(TASKS, FIELDS)
project.initialize(_recipe={ 'tasks':TASKS }, _project=CLOUD_PROJECT, _user=USER_CREDENTIALS, _client=CLIENT_CREDENTIALS, _verbose=True, _force=True)
project.execute(_force=True)
Explanation: 5. Execute DV360 API To BigQuery
This does NOT need to be modified unles you are changing the recipe, click play.
End of explanation
<END_TASK>