Skip to content

Latest commit

 

History

History
247 lines (173 loc) · 9.43 KB

WorkspacesApi.md

File metadata and controls

247 lines (173 loc) · 9.43 KB

Asana.WorkspacesApi

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

Method HTTP request Description
addUserForWorkspace POST /workspaces/{workspace_gid}/addUser Add a user to a workspace or organization
getWorkspace GET /workspaces/{workspace_gid} Get a workspace
getWorkspaces GET /workspaces Get multiple workspaces
removeUserForWorkspace POST /workspaces/{workspace_gid}/removeUser Remove a user from a workspace or organization
updateWorkspace PUT /workspaces/{workspace_gid} Update a workspace

addUserForWorkspace

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

const Asana = require('asana');

let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let workspacesApiInstance = new Asana.WorkspacesApi();
let body = {"data": {"<PARAM_1>": "<VALUE_1>", "<PARAM_2>": "<VALUE_2>",}}; // Object | The user to add to the workspace.
let workspace_gid = "12345"; // String | Globally unique identifier for the workspace or organization.
let opts = { 
    'opt_fields': "email,name,photo,photo.image_1024x1024,photo.image_128x128,photo.image_21x21,photo.image_27x27,photo.image_36x36,photo.image_60x60"
};
workspacesApiInstance.addUserForWorkspace(body, workspace_gid, opts).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

Parameters

Name Type Description Notes
body Object The user to add to the workspace.
workspace_gid String Globally unique identifier for the workspace or organization.
opt_fields Object 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

object

HTTP request headers

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

getWorkspace

Get a workspace

Returns the full workspace record for a single workspace.

(more information)

Example

const Asana = require('asana');

let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let workspacesApiInstance = new Asana.WorkspacesApi();
let workspace_gid = "12345"; // String | Globally unique identifier for the workspace or organization.
let opts = { 
    'opt_fields': "email_domains,is_organization,name"
};
workspacesApiInstance.getWorkspace(workspace_gid, opts).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

Parameters

Name Type Description Notes
workspace_gid String Globally unique identifier for the workspace or organization.
opt_fields Object 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

object

HTTP request headers

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

getWorkspaces

Get multiple workspaces

Returns the compact records for all workspaces visible to the authorized user.

(more information)

Example

const Asana = require('asana');

let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let workspacesApiInstance = new Asana.WorkspacesApi();
let opts = { 
    'limit': 50, 
    'offset': "eyJ0eXAiOJiKV1iQLCJhbGciOiJIUzI1NiJ9", 
    'opt_fields': "email_domains,is_organization,name,offset,path,uri"
};
workspacesApiInstance.getWorkspaces(opts).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

Parameters

Name Type Description Notes
limit Number Results per page. The number of objects to return per page. The value must be between 1 and 100. [optional]
offset String 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 Object 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

object

HTTP request headers

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

removeUserForWorkspace

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. Returns an empty data record.

(more information)

Example

const Asana = require('asana');

let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let workspacesApiInstance = new Asana.WorkspacesApi();
let body = {"data": {"<PARAM_1>": "<VALUE_1>", "<PARAM_2>": "<VALUE_2>",}}; // Object | The user to remove from the workspace.
let workspace_gid = "12345"; // String | Globally unique identifier for the workspace or organization.

workspacesApiInstance.removeUserForWorkspace(body, workspace_gid).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

Parameters

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

Return type

object

HTTP request headers

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

updateWorkspace

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

const Asana = require('asana');

let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';

let workspacesApiInstance = new Asana.WorkspacesApi();
let body = {"data": {"<PARAM_1>": "<VALUE_1>", "<PARAM_2>": "<VALUE_2>",}}; // Object | The workspace object with all updated properties.
let workspace_gid = "12345"; // String | Globally unique identifier for the workspace or organization.
let opts = { 
    'opt_fields': "email_domains,is_organization,name"
};
workspacesApiInstance.updateWorkspace(body, workspace_gid, opts).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});

Parameters

Name Type Description Notes
body Object The workspace object with all updated properties.
workspace_gid String Globally unique identifier for the workspace or organization.
opt_fields Object 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

object

HTTP request headers

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