Skip to content

Latest commit

 

History

History
326 lines (232 loc) · 15.3 KB

File metadata and controls

326 lines (232 loc) · 15.3 KB

asana.WorkspacesApi

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

Method HTTP request Description
add_user_for_workspace POST /workspaces/{workspace_gid}/addUser Add a user to a workspace or organization
get_workspace GET /workspaces/{workspace_gid} Get a workspace
get_workspace_events GET /workspaces/{workspace_gid}/events Get workspace events
get_workspaces GET /workspaces Get multiple workspaces
remove_user_for_workspace POST /workspaces/{workspace_gid}/removeUser Remove a user from a workspace or organization
update_workspace PUT /workspaces/{workspace_gid} Update a workspace

add_user_for_workspace

Add a user to a workspace or organization

Add a user to a workspace or organization. The user can be referenced by their globally unique user ID or their email address. Returns the full user record for the invited user.

(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
workspaces_api_instance = asana.WorkspacesApi(api_client)
body = {"data": {"<PARAM_1>": "<VALUE_1>", "<PARAM_2>": "<VALUE_2>",}} # dict | The user to add to the workspace.
workspace_gid = "12345" # str | Globally unique identifier for the workspace or organization.
opts = {
    'opt_fields': "email,name,photo,photo.image_1024x1024,photo.image_128x128,photo.image_21x21,photo.image_27x27,photo.image_36x36,photo.image_60x60", # list[str] | This endpoint returns a 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:
    # Add a user to a workspace or organization
    api_response = workspaces_api_instance.add_user_for_workspace(body, workspace_gid, opts)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling WorkspacesApi->add_user_for_workspace: %s\n" % e)

Parameters

Name Type Description Notes
body Dict The user to add to the workspace.
workspace_gid str Globally unique identifier for the workspace or organization.
opt_fields Dict This endpoint returns a 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]

get_workspace

Get a workspace

Required scope: workspaces:read Returns the full workspace record for a single workspace.

(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
workspaces_api_instance = asana.WorkspacesApi(api_client)
workspace_gid = "12345" # str | Globally unique identifier for the workspace or organization.
opts = {
    'opt_fields': "email_domains,is_organization,name", # list[str] | This endpoint returns a 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 workspace
    api_response = workspaces_api_instance.get_workspace(workspace_gid, opts)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling WorkspacesApi->get_workspace: %s\n" % e)

Parameters

Name Type Description Notes
workspace_gid str Globally unique identifier for the workspace or organization.
opt_fields Dict This endpoint returns a 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_workspace_events

Get workspace events

Returns the full record for all events that have occurred since the sync token was created. The response is a list of events and the schema of each event is as described here. Asana limits a single sync token to 1000 events. If more than 1000 events exist for a given domain, has_more: true will be returned in the response, indicating that there are more events to pull.

(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
workspaces_api_instance = asana.WorkspacesApi(api_client)
workspace_gid = "12345" # str | Globally unique identifier for the workspace or organization.
opts = {
    'sync': "de4774f6915eae04714ca93bb2f5ee81", # str | A sync token received from the last request, or none on first sync. Events will be returned from the point in time that the sync token was generated. *Note: On your first request, omit the sync token. The response will be the same as for an expired sync token, and will include a new valid sync token. If the sync token is too old (which may happen from time to time) the API will return a `412 Precondition Failed` error, and include a fresh sync token in the response.*
}

try:
    # Get workspace events
    api_response = workspaces_api_instance.get_workspace_events(workspace_gid, opts)
    for data in api_response:
        pprint(data)
except ApiException as e:
    print("Exception when calling WorkspacesApi->get_workspace_events: %s\n" % e)

Parameters

Name Type Description Notes
workspace_gid str Globally unique identifier for the workspace or organization.
sync str A sync token received from the last request, or none on first sync. Events will be returned from the point in time that the sync token was generated. Note: On your first request, omit the sync token. The response will be the same as for an expired sync token, and will include a new valid sync token. If the sync token is too old (which may happen from time to time) the API will return a `412 Precondition Failed` error, and include a fresh sync token in the response. [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]

get_workspaces

Get multiple workspaces

Required scope: workspaces:read Returns the compact records for all workspaces visible to the authorized user.

(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
workspaces_api_instance = asana.WorkspacesApi(api_client)
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': "email_domains,is_organization,name,offset,path,uri", # list[str] | This endpoint returns a 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 multiple workspaces
    api_response = workspaces_api_instance.get_workspaces(opts)
    for data in api_response:
        pprint(data)
except ApiException as e:
    print("Exception when calling WorkspacesApi->get_workspaces: %s\n" % e)

Parameters

Name Type Description Notes
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 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]

remove_user_for_workspace

Remove a user from a workspace or organization

Remove a user from a workspace or organization. The user making this call must be an admin in the workspace. The user can be referenced by their globally unique user ID or their email address. When invoked using a Service Account Token (SAT), this endpoint follows the same behavior as the SCIM API Delete endpoint. To learn more about how Asana handles user deprovisioning, refer to our Help Center article on deprovisioning users. When invoked using a Personal Access Token (PAT), the endpoint behaves similarly, except that ownership of the user’s resources is transferred to the PAT owner instead of the admin specified in the Admin Console. Note: If you wish to retain access to a user’s private resources (i.e., those visible only to that user), you have to make them public manually (or ask the user to do so) before removal. Returns an empty data 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
workspaces_api_instance = asana.WorkspacesApi(api_client)
body = {"data": {"<PARAM_1>": "<VALUE_1>", "<PARAM_2>": "<VALUE_2>",}} # dict | The user to remove from the workspace.
workspace_gid = "12345" # str | Globally unique identifier for the workspace or organization.


try:
    # Remove a user from a workspace or organization
    api_response = workspaces_api_instance.remove_user_for_workspace(body, workspace_gid)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling WorkspacesApi->remove_user_for_workspace: %s\n" % e)

Parameters

Name Type Description Notes
body Dict The user to remove from the workspace.
workspace_gid str Globally unique identifier for the workspace or organization.

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_workspace

Update a workspace

A specific, existing workspace can be updated by making a PUT request on the URL for that workspace. Only the fields provided in the data block will be updated; any unspecified fields will remain unchanged. Currently the only field that can be modified for a workspace is its name. Returns the complete, updated workspace 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
workspaces_api_instance = asana.WorkspacesApi(api_client)
body = {"data": {"<PARAM_1>": "<VALUE_1>", "<PARAM_2>": "<VALUE_2>",}} # dict | The workspace object with all updated properties.
workspace_gid = "12345" # str | Globally unique identifier for the workspace or organization.
opts = {
    'opt_fields': "email_domains,is_organization,name", # list[str] | This endpoint returns a 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 workspace
    api_response = workspaces_api_instance.update_workspace(body, workspace_gid, opts)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling WorkspacesApi->update_workspace: %s\n" % e)

Parameters

Name Type Description Notes
body Dict The workspace object with all updated properties.
workspace_gid str Globally unique identifier for the workspace or organization.
opt_fields Dict This endpoint returns a 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]