<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 Bulk Editor For DV360 Parameters
Allows bulk editing DV360 through Sheets and BigQuery.
 1. Select <b>Create Sheet</b> and run the recipe.
 1. Fill in <i>Partners</i> tab filter.
 1. Run <b>Load Advertisers</b>.
 1. Fill in <i>Advertisers</i> tab filter.
 1. Run <b>Load Insertion Orders</b> or <b>Load Line Items</b> or <b>Load Creatives</b>.
 1. Fill in changes on all tabs with colored fields.
 1. Select <i>Audit</i> and run the recipe.
 1. Check the <b>Audit</b> and <b>Preview</b> tabs.
 1. Select <i>Patch</i> and run the recipe.
 1. Check the <b>Success</b> and <b>Error</b> tabs.
 1. Patch can be run multiple times.
 1. Patch ONLY changes edited fields.
Modify the values below for your use case, can be done multiple times, then click play.
Step4:  5. Execute Bulk Editor For DV360
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 = {
  'auth_dv': 'user',  # Credentials used for dv.
  'auth_sheet': 'user',  # Credentials used for sheet.
  'auth_bigquery': 'service',  # Credentials used for bigquery.
  'recipe_slug': '',  # Name of Google BigQuery dataset to create.
  'command': '',  # Action to take.
}
print("Parameters Set To: %s" % FIELDS)
Explanation: 4. Enter Bulk Editor For DV360 Parameters
Allows bulk editing DV360 through Sheets and BigQuery.
 1. Select <b>Create Sheet</b> and run the recipe.
 1. Fill in <i>Partners</i> tab filter.
 1. Run <b>Load Advertisers</b>.
 1. Fill in <i>Advertisers</i> tab filter.
 1. Run <b>Load Insertion Orders</b> or <b>Load Line Items</b> or <b>Load Creatives</b>.
 1. Fill in changes on all tabs with colored fields.
 1. Select <i>Audit</i> and run the recipe.
 1. Check the <b>Audit</b> and <b>Preview</b> tabs.
 1. Select <i>Patch</i> and run the recipe.
 1. Check the <b>Success</b> and <b>Error</b> tabs.
 1. Patch can be run multiple times.
 1. Patch ONLY changes edited fields.
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 = [
  {
    'dataset': {
      '__comment__': 'Ensure dataset exists.',
      'auth': 'user',
      'dataset': {'field': {'name': 'recipe_slug','prefix': 'DV_Sheet_','kind': 'string','order': 2,'default': '','description': 'Name of Google BigQuery dataset to create.'}}
    }
  },
  {
    'drive': {
      '__comment__': 'Copy the default template to sheet with the recipe name',
      'auth': 'user',
      'copy': {
        'source': 'https://docs.google.com/spreadsheets/d/10ByZKMIPZQQOEwJlskzggRhhQqe44on_ebUxkjmZI_w/',
        'destination': {'field': {'name': 'recipe_slug','prefix': 'DV Sheet ','kind': 'string','order': 3,'default': '','description': 'Name of Google Sheet to create.'}}
      }
    }
  },
  {
    'dv_sheets': {
      '__comment': 'Depending on users choice, execute a different part of the solution.',
      'auth_dv': {'field': {'name': 'auth_dv','kind': 'authentication','order': 1,'default': 'user','description': 'Credentials used for dv.'}},
      'auth_sheets': {'field': {'name': 'auth_sheet','kind': 'authentication','order': 2,'default': 'user','description': 'Credentials used for sheet.'}},
      'auth_bigquery': {'field': {'name': 'auth_bigquery','kind': 'authentication','order': 3,'default': 'service','description': 'Credentials used for bigquery.'}},
      'sheet': {'field': {'name': 'recipe_slug','prefix': 'DV Sheet ','kind': 'string','order': 4,'default': '','description': 'Name of Google Sheet to create.'}},
      'dataset': {'field': {'name': 'recipe_slug','prefix': 'DV_Sheet_','kind': 'string','order': 5,'default': '','description': 'Name of Google BigQuery dataset to create.'}},
      'command': {'field': {'name': 'command','kind': 'choice','choices': ['Clear Partners','Clear Advertisers','Clear Campaigns','Clear Creatives','Clear Insertion Orders','Clear Line Items','Clear Preview','Clear Patch','Load Partners','Load Advertisers','Load Campaigns','Load Creatives','Load Insertion Orders','Load Line Items','Preview','Patch'],'order': 6,'default': '','description': 'Action to take.'}}
    }
  }
]
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 Bulk Editor For DV360
This does NOT need to be modified unles you are changing the recipe, click play.
End of explanation
<END_TASK>