Skip to content

Latest commit

 

History

History
377 lines (268 loc) · 14.8 KB

SectionsApi.md

File metadata and controls

377 lines (268 loc) · 14.8 KB

asana.SectionsApi

All URIs are relative to https://app.asana.com/api/1.0

Method HTTP request Description
add_task_for_section POST /sections/{section_gid}/addTask Add task to section
create_section_for_project POST /projects/{project_gid}/sections Create a section in a project
delete_section DELETE /sections/{section_gid} Delete a section
get_section GET /sections/{section_gid} Get a section
get_sections_for_project GET /projects/{project_gid}/sections Get sections in a project
insert_section_for_project POST /projects/{project_gid}/sections/insert Move or Insert sections
update_section PUT /sections/{section_gid} Update a section

add_task_for_section

Add task to section

Add a task to a specific, existing section. This will remove the task from other sections of the project. The task will be inserted at the top of a section unless an insert_before or insert_after parameter is declared. This does not work for separators (tasks with the resource_subtype of section).

(more information)

Example

import asana
from asana.rest import ApiException
from pprint import pprint

configuration = asana.Configuration()
configuration.access_token = '<YOUR_ACCESS_TOKEN>'
api_client = asana.ApiClient(configuration)

# create an instance of the API class
sections_api_instance = asana.SectionsApi(api_client)
section_gid = "321654" # str | The globally unique identifier for the section.
opts = {
    'body': {"data": {"param1": "value1", "param2": "value2",}}, # dict | The task and optionally the insert location.
}

try:
    # Add task to section
    api_response = sections_api_instance.add_task_for_section(section_gid, opts)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling SectionsApi->add_task_for_section: %s\n" % e)

Parameters

Name Type Description Notes
section_gid str The globally unique identifier for the section.
body Dict The task and optionally the insert location. [optional]

Return type

dict

HTTP request headers

  • Content-Type: application/json; charset=UTF-8
  • Accept: application/json; charset=UTF-8

[Back to top] [Back to API list] [Back to README]

create_section_for_project

Create a section in a project

Creates a new section in a project. Returns the full record of the newly created section.

(more information)

Example

import asana
from asana.rest import ApiException
from pprint import pprint

configuration = asana.Configuration()
configuration.access_token = '<YOUR_ACCESS_TOKEN>'
api_client = asana.ApiClient(configuration)

# create an instance of the API class
sections_api_instance = asana.SectionsApi(api_client)
project_gid = "1331" # str | Globally unique identifier for the project.
opts = {
    'body': {"data": {"param1": "value1", "param2": "value2",}}, # dict | The section to create.
    'opt_fields': "created_at,name,project,project.name,projects,projects.name", # list[str] | This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include.
}

try:
    # Create a section in a project
    api_response = sections_api_instance.create_section_for_project(project_gid, opts)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling SectionsApi->create_section_for_project: %s\n" % e)

Parameters

Name Type Description Notes
project_gid str Globally unique identifier for the project.
body Dict The section to create. [optional]
opt_fields Dict This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include. [optional]

Return type

dict

HTTP request headers

  • Content-Type: application/json; charset=UTF-8
  • Accept: application/json; charset=UTF-8

[Back to top] [Back to API list] [Back to README]

delete_section

Delete a section

A specific, existing section can be deleted by making a DELETE request on the URL for that section. Note that sections must be empty to be deleted. The last remaining section cannot be deleted. Returns an empty data block.

(more information)

Example

import asana
from asana.rest import ApiException
from pprint import pprint

configuration = asana.Configuration()
configuration.access_token = '<YOUR_ACCESS_TOKEN>'
api_client = asana.ApiClient(configuration)

# create an instance of the API class
sections_api_instance = asana.SectionsApi(api_client)
section_gid = "321654" # str | The globally unique identifier for the section.


try:
    # Delete a section
    api_response = sections_api_instance.delete_section(section_gid)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling SectionsApi->delete_section: %s\n" % e)

Parameters

Name Type Description Notes
section_gid str The globally unique identifier for the section.

Return type

dict

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json; charset=UTF-8

[Back to top] [Back to API list] [Back to README]

get_section

Get a section

Returns the complete record for a single section.

(more information)

Example

import asana
from asana.rest import ApiException
from pprint import pprint

configuration = asana.Configuration()
configuration.access_token = '<YOUR_ACCESS_TOKEN>'
api_client = asana.ApiClient(configuration)

# create an instance of the API class
sections_api_instance = asana.SectionsApi(api_client)
section_gid = "321654" # str | The globally unique identifier for the section.
opts = {
    'opt_fields': "created_at,name,project,project.name,projects,projects.name", # list[str] | This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include.
}

try:
    # Get a section
    api_response = sections_api_instance.get_section(section_gid, opts)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling SectionsApi->get_section: %s\n" % e)

Parameters

Name Type Description Notes
section_gid str The globally unique identifier for the section.
opt_fields Dict This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include. [optional]

Return type

dict

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json; charset=UTF-8

[Back to top] [Back to API list] [Back to README]

get_sections_for_project

Get sections in a project

Returns the compact records for all sections in the specified project.

(more information)

Example

import asana
from asana.rest import ApiException
from pprint import pprint

configuration = asana.Configuration()
configuration.access_token = '<YOUR_ACCESS_TOKEN>'
api_client = asana.ApiClient(configuration)

# create an instance of the API class
sections_api_instance = asana.SectionsApi(api_client)
project_gid = "1331" # str | Globally unique identifier for the project.
opts = {
    'limit': 50, # int | Results per page. The number of objects to return per page. The value must be between 1 and 100.
    'offset': "eyJ0eXAiOJiKV1iQLCJhbGciOiJIUzI1NiJ9", # str | Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.'
    'opt_fields': "created_at,name,offset,path,project,project.name,projects,projects.name,uri", # list[str] | This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include.
}

try:
    # Get sections in a project
    api_response = sections_api_instance.get_sections_for_project(project_gid, opts)
    for data in api_response:
        pprint(data)
except ApiException as e:
    print("Exception when calling SectionsApi->get_sections_for_project: %s\n" % e)

Parameters

Name Type Description Notes
project_gid str Globally unique identifier for the project.
limit int Results per page. The number of objects to return per page. The value must be between 1 and 100. [optional]
offset str Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' [optional]
opt_fields Dict This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include. [optional]

Return type

generator

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json; charset=UTF-8

[Back to top] [Back to API list] [Back to README]

insert_section_for_project

Move or Insert sections

Move sections relative to each other. One of before_section or after_section is required. Sections cannot be moved between projects. Returns an empty data block.

(more information)

Example

import asana
from asana.rest import ApiException
from pprint import pprint

configuration = asana.Configuration()
configuration.access_token = '<YOUR_ACCESS_TOKEN>'
api_client = asana.ApiClient(configuration)

# create an instance of the API class
sections_api_instance = asana.SectionsApi(api_client)
project_gid = "1331" # str | Globally unique identifier for the project.
opts = {
    'body': {"data": {"param1": "value1", "param2": "value2",}}, # dict | The section's move action.
}

try:
    # Move or Insert sections
    api_response = sections_api_instance.insert_section_for_project(project_gid, opts)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling SectionsApi->insert_section_for_project: %s\n" % e)

Parameters

Name Type Description Notes
project_gid str Globally unique identifier for the project.
body Dict The section's move action. [optional]

Return type

dict

HTTP request headers

  • Content-Type: application/json; charset=UTF-8
  • Accept: application/json; charset=UTF-8

[Back to top] [Back to API list] [Back to README]

update_section

Update a section

A specific, existing section can be updated by making a PUT request on the URL for that project. Only the fields provided in the data block will be updated; any unspecified fields will remain unchanged. (note that at this time, the only field that can be updated is the name field.) When using this method, it is best to specify only those fields you wish to change, or else you may overwrite changes made by another user since you last retrieved the task. Returns the complete updated section record.

(more information)

Example

import asana
from asana.rest import ApiException
from pprint import pprint

configuration = asana.Configuration()
configuration.access_token = '<YOUR_ACCESS_TOKEN>'
api_client = asana.ApiClient(configuration)

# create an instance of the API class
sections_api_instance = asana.SectionsApi(api_client)
section_gid = "321654" # str | The globally unique identifier for the section.
opts = {
    'body': {"data": {"param1": "value1", "param2": "value2",}}, # dict | The section to create.
    'opt_fields': "created_at,name,project,project.name,projects,projects.name", # list[str] | This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include.
}

try:
    # Update a section
    api_response = sections_api_instance.update_section(section_gid, opts)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling SectionsApi->update_section: %s\n" % e)

Parameters

Name Type Description Notes
section_gid str The globally unique identifier for the section.
body Dict The section to create. [optional]
opt_fields Dict This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include. [optional]

Return type

dict

HTTP request headers

  • Content-Type: application/json; charset=UTF-8
  • Accept: application/json; charset=UTF-8

[Back to top] [Back to API list] [Back to README]