Asana / python-asana

Official Python client library for the Asana API v1
MIT License
299 stars 103 forks source link

project_template.py #152

Closed MitchHare closed 1 year ago

MitchHare commented 2 years ago

project_template.py does not seem to have been updated since inception. image image

jv-asana commented 1 year ago

Hi @MitchHare, this project_template.py has all of it's methods inherited from gen/project_templates.py

You should be able to use the up-to-date project template methods with v2.0.0. Here are some examples:

import os
import asana
from pprint import pprint

client = asana.Client.access_token(os.environ['ASANA_PERSONAL_ACCESS_TOKEN'])

# GET /project_templates/{project_template_gid}
# https://developers.asana.com/docs/get-a-project-template
result = client.project_templates.get_project_template('<YOUR_PROJECT_TEMPLATE_GID>')
pprint(result)

# GET /project_templates
# https://developers.asana.com/docs/get-multiple-project-templates
result = client.project_templates.get_project_templates({'workspace': '<YOUR_WORKSPACE_GID>'})
pprint(list(result))

# GET /teams/{team_gid}/project_templates
# https://developers.asana.com/docs/get-a-teams-project-templates
result = client.project_templates.get_project_templates_for_team('<YOUR_TEAM_GID>')
pprint(list(result))

# POST /project_templates/{project_template_gid}/instantiateProject
# https://developers.asana.com/docs/instantiate-a-project-from-a-project-template
result = client.project_templates.instantiate_project(
    '<YOUR_PROJECT_TEMPLATE_GID>',
    {
        'workspace': '<YOUR_WORKSPACE_GID>',
        'name': 'New project from template',
        'public': True,
    }
)
pprint(result)