Documentation ¶
Overview ¶
Package asana provides a client for the Asana API
Index ¶
- Constants
- func IsAuthError(err error) bool
- func IsNotFoundError(err error) bool
- func IsPayloadTooLarge(err error) bool
- func IsRateLimited(err error) bool
- func IsRecoverableError(err error) bool
- func RetryAfter(err error) time.Duration
- type AddCustomFieldSettingRequest
- type AddDependenciesRequest
- type AddDependentsRequest
- type AddProjectRequest
- type App
- type AppConfig
- type Attachment
- type Client
- func (c *Client) AllWorkspaces(options ...*Options) ([]*Workspace, error)
- func (c *Client) CreateCustomField(request *CreateCustomFieldRequest) (*CustomField, error)
- func (c *Client) CreateProject(project *CreateProjectRequest) (*Project, error)
- func (c *Client) CreateTask(task *CreateTaskRequest) (*Task, error)
- func (c *Client) CurrentUser() (*User, error)
- func (c *Client) QueryTasks(query *TaskQuery, opts ...*Options) ([]*Task, *NextPage, error)
- func (c *Client) Workspaces(options ...*Options) ([]*Workspace, *NextPage, error)
- type CreateCustomFieldRequest
- type CreateMembership
- type CreateProjectRequest
- type CreateTaskRequest
- type CustomField
- type CustomFieldBase
- type CustomFieldSetting
- type CustomFieldValue
- type Date
- type Dates
- type EnumValue
- type EnumValueBase
- type Error
- type ExternalData
- type Feature
- type FieldType
- type Format
- type LabelPosition
- type Membership
- type NewAttachment
- type NextPage
- type Options
- type Portfolio
- type Project
- func (p *Project) AddCustomFieldSetting(request *AddCustomFieldSettingRequest) (*CustomFieldSetting, error)
- func (p *Project) CreateSection(section *SectionBase) (*Section, error)
- func (p *Project) Fetch(opts ...*Options) error
- func (p *Project) InsertSection(request *SectionInsertRequest) error
- func (p *Project) RemoveCustomFieldSetting(customFieldID string) error
- func (p *Project) Sections(opts ...*Options) ([]*Section, *NextPage, error)
- func (p *Project) Tasks(opts ...*Options) ([]*Task, *NextPage, error)
- func (p *Project) Update(request *UpdateProjectRequest, opts ...*Options) error
- type ProjectBase
- type ProjectStatus
- type Response
- type Section
- type SectionBase
- type SectionInsertRequest
- type SectionMigrationStatus
- type SetParentRequest
- type Story
- type StoryBase
- type StorySubtypeFields
- type Tag
- type TagBase
- type Task
- func (t *Task) AddDependencies(request *AddDependenciesRequest) error
- func (t *Task) AddDependents(request *AddDependentsRequest) error
- func (t *Task) AddProject(request *AddProjectRequest) error
- func (t *Task) Attachments(opts ...*Options) ([]*Attachment, *NextPage, error)
- func (t *Task) CreateAttachment(request *NewAttachment) (*Attachment, error)
- func (t *Task) CreateComment(story *StoryBase) (*Story, error)
- func (t *Task) CreateSubtask(task *Task) (*Task, error)
- func (t *Task) Delete(client *Client) error
- func (t *Task) Fetch(client *Client) error
- func (t *Task) RemoveProject(projectID string) error
- func (t *Task) SetParent(request *SetParentRequest) error
- func (t *Task) Stories(opts ...*Options) ([]*Story, *NextPage, error)
- func (t *Task) Subtasks(opts ...*Options) ([]*Task, *NextPage, error)
- func (t *Task) Update(update *UpdateTaskRequest) error
- type TaskBase
- type TaskQuery
- type Team
- type UpdateProjectRequest
- type UpdateTaskRequest
- type User
- type Validator
- type View
- type Workspace
- func (w *Workspace) AllCustomFields(options ...*Options) ([]*CustomField, error)
- func (w *Workspace) AllFavoriteProjects(options ...*Options) ([]*Project, error)
- func (w *Workspace) AllProjects(options ...*Options) ([]*Project, error)
- func (w *Workspace) AllTags(options ...*Options) ([]*Tag, error)
- func (w *Workspace) AllTeams(options ...*Options) ([]*Team, error)
- func (w *Workspace) AllUsers(options ...*Options) ([]*User, error)
- func (w *Workspace) CreateTag(tag *TagBase) (*Tag, error)
- func (w *Workspace) CustomFields(options ...*Options) ([]*CustomField, *NextPage, error)
- func (w *Workspace) FavoriteProjects(options ...*Options) ([]*Project, *NextPage, error)
- func (w *Workspace) Fetch(client *Client) error
- func (w *Workspace) Portfolios(options ...*Options) ([]*Portfolio, *NextPage, error)
- func (w *Workspace) Projects(options ...*Options) ([]*Project, *NextPage, error)
- func (w *Workspace) Tags(options ...*Options) ([]*Tag, *NextPage, error)
- func (w *Workspace) Teams(options ...*Options) ([]*Team, *NextPage, error)
- func (w *Workspace) Users(options ...*Options) ([]*User, *NextPage, error)
Constants ¶
const ( Currency = "currency" Identifier = "identifier" Percentage = "percentage" Custom = "custom" None = "none" )
const (
// BaseURL is the default URL used to access the Asana API
BaseURL = "https://app.asana.com/api/1.0"
)
Variables ¶
This section is empty.
Functions ¶
func IsAuthError ¶
IsAuthError checks if the provided error represents a 401 Authorization error response from the API
func IsNotFoundError ¶
IsNotFoundError checks if the provided error represents a 404 not found response from the API
func IsPayloadTooLarge ¶
IsRateLimited returns true if the error was a rate limit error
func IsRateLimited ¶
IsRateLimited returns true if the error was a rate limit error
func IsRecoverableError ¶
func RetryAfter ¶
RetryAfter returns a Duration indicating after how many seconds a rate-limited requests may be retried or nil if the error was not a rate limit error
Types ¶
type AddDependenciesRequest ¶
type AddDependenciesRequest struct { // Required: An array of task IDs that this task should depend on. Dependencies []string `json:"dependencies"` }
AddDependenciesRequest
type AddDependentsRequest ¶
type AddDependentsRequest struct { // Required: An array of task IDs that this task should depend on. Dependents []string `json:"dependents"` }
AddDependentsRequest
type AddProjectRequest ¶
type AddProjectRequest struct { Project string // Required: The project to add the task to. InsertAfter string // A task in the project to insert the task after, or "-" to insert at the beginning of the list. InsertBefore string // A task in the project to insert the task before, or "-" to insert at the end of the list. Section string // A section in the project to insert the task into. The task will be inserted at the bottom of the section. }
AddProjectRequest defines the location a task should be added to a project
type App ¶
type App struct {
// contains filtered or unexported fields
}
App represents an Asana client application
type AppConfig ¶
AppConfig provides the details needed to authenticate users with Asana on behalf of an Asana client application
type Attachment ¶
type Attachment struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` // Read-only. The name of the object. Name string `json:"name,omitempty"` // Read-only. The task this object is attached to. Parent *Task `json:"parent,omitempty"` // Read-only. The time at which this object was created. CreatedAt *time.Time `json:"created_at,omitempty"` // Read-only. The URL containing the content of the attachment. // // Note: May be null if the attachment is hosted by box. If present, this // URL may only be valid for 1 hour from the time of retrieval. You should // avoid persisting this URL somewhere and just refresh it on demand to // ensure you do not keep stale URLs. DownloadURL string `json:"download_url,omitempty"` // Read-only. The service hosting the attachment. Valid values are asana, // dropbox, gdrive and box. Host string `json:"host,omitempty"` // Read-only. The URL where the attachment can be viewed, which may be // friendlier to users in a browser than just directing them to a raw // file. ViewURL string `json:"view_url,omitempty"` // Undocumented. A permanent asana.com link which should be a permalink PermanentURL string `json:"permanent_url,omitempty"` // contains filtered or unexported fields }
Attachment represents any file attached to a task in Asana, whether it’s an uploaded file or one associated via a third-party service such as Dropbox or Google Drive.
type Client ¶
type Client struct { BaseURL *url.URL HTTPClient *http.Client Debug bool Verbose []bool DefaultOptions Options }
Client is the root client for the Asana API. The nested HTTPClient should provide Authorization header injection.
func NewClient ¶
NewClient instantiates a new Asana client with the given HTTP client and the default base URL
func NewClientWithAccessToken ¶
NewClientWithAccessToken creates a new instance of the Asana client which uses a Personal Access Token for authentication
func (*Client) AllWorkspaces ¶
AllWorkspaces repeatedly pages through all available workspaces for a client
func (*Client) CreateCustomField ¶
func (c *Client) CreateCustomField(request *CreateCustomFieldRequest) (*CustomField, error)
func (*Client) CreateProject ¶
func (c *Client) CreateProject(project *CreateProjectRequest) (*Project, error)
CreateProject adds a new project to a workspace
func (*Client) CreateTask ¶
func (c *Client) CreateTask(task *CreateTaskRequest) (*Task, error)
CreateTask creates a new task in the given project
func (*Client) CurrentUser ¶
CurrentUser gets the currently authorized user
func (*Client) QueryTasks ¶
QueryTasks returns the compact task records for some filtered set of tasks. Use one or more of the parameters provided to filter the tasks returned. You must specify a project or tag if you do not specify assignee and workspace.
type CreateCustomFieldRequest ¶
type CreateCustomFieldRequest struct { CustomFieldBase // Required: The workspace to create a custom field in. Workspace string `json:"workspace"` // The discrete values the custom field can assume. // Required if the custom field is of type ‘enum’. EnumOptions []*EnumValueBase `json:"enum_options,omitempty"` }
type CreateMembership ¶
type CreateProjectRequest ¶
type CreateProjectRequest struct { ProjectBase Workspace string `json:"workspace,omitempty"` Team string `json:"team,omitempty"` Owner string `json:"owner,omitempty"` CustomFields map[string]interface{} `json:"custom_fields,omitempty"` }
CreateProjectRequest represents a request to create a new project
type CreateTaskRequest ¶
type CreateTaskRequest struct { TaskBase Assignee string `json:"assignee,omitempty"` // User to which this task is assigned, or null if the task is unassigned. Followers []string `json:"followers,omitempty"` // Array of users following this task. Workspace string `json:"workspace,omitempty"` Parent string `json:"parent,omitempty"` Projects []string `json:"projects,omitempty"` Memberships []*CreateMembership `json:"memberships,omitempty"` Tags []string `json:"tags,omitempty"` CustomFields map[string]interface{} `json:"custom_fields,omitempty"` }
CreateTaskRequest represents a request to create a new Task
func (*CreateTaskRequest) Validate ¶
func (t *CreateTaskRequest) Validate() error
Validate checks the task data and fixes any problems
type CustomField ¶
type CustomField struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` CustomFieldBase // Only relevant for custom fields of type ‘Enum’. This array specifies // the possible values which an enum custom field can adopt. EnumOptions []*EnumValue `json:"enum_options,omitempty"` // contains filtered or unexported fields }
Custom Fields store the metadata that is used in order to add user- specified information to tasks in Asana. Be sure to reference the Custom Fields developer documentation for more information about how custom fields relate to various resources in Asana. Users in Asana can lock custom fields, which will make them read-only when accessed by other users. Attempting to edit a locked custom field will return HTTP error code 403 Forbidden.
func (*CustomField) Fetch ¶
func (f *CustomField) Fetch(options ...*Options) error
Fetch loads the full details for this CustomField
type CustomFieldBase ¶
type CustomFieldBase struct { // ISO 4217 currency code to format this custom field. This will be null // if the format is not currency. CurrencyCode string `json:"currency_code,omitempty"` // This is the string that appears next to the custom field value. // This will be null if the format is not custom. CustomLabel string `json:"custom_label,omitempty"` // Only relevant for custom fields with custom format. This depicts where to place the custom label. // This will be null if the format is not custom. CustomLabelPosition LabelPosition `json:"custom_label_position,omitempty"` // The description of the custom field. Description string `json:"description,omitempty"` // Opt In. The description of the custom field. Enabled *bool `json:"enabled,omitempty"` // The format of this custom field. Format Format `json:"format,omitempty"` // Conditional. This flag describes whether a follower of a task with this // field should receive inbox notifications from changes to this field. HasNotificationsEnabled *bool `json:"has_notifications_enabled,omitempty"` // This flag describes whether this custom field is available to every container // in the workspace. Before project-specific custom fields, this field was always true. IsGlobalToWorkspace *bool `json:"is_global_to_workspace,omitempty"` // Read-only. The name of the object. Name string `json:"name,omitempty"` // Only relevant for custom fields of type ‘Number’. This field dictates the number of places after // the decimal to round to, i.e. 0 is integer values, 1 rounds to the nearest tenth, and so on. // Must be between 0 and 6, inclusive. // For percentage format, this may be unintuitive, as a value of 0.25 has a precision of 0, while a // value of 0.251 has a precision of 1. This is due to 0.25 being displayed as 25%. // The identifier format will always have a precision of 0. Precision *int `json:"precision,omitempty"` // The type of the custom field. Must be one of the given values: // 'text', 'enum', 'number' ResourceSubtype FieldType `json:"resource_subtype"` }
type CustomFieldSetting ¶
type CustomFieldSetting struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` CustomField *CustomField `json:"custom_field"` Project *Project `json:"project,omitempty"` Important bool `json:"is_important,omitempty"` }
type CustomFieldValue ¶
type CustomFieldValue struct { CustomField // Custom fields of type text will return a text_value property containing // the string of text for the field. TextValue *string `json:"text_value,omitempty"` // Custom fields of type number will return a number_value property // containing the number for the field. NumberValue *float64 `json:"number_value,omitempty"` // Custom fields of type enum will return an enum_value property // containing an object that represents the selection of the enum value. EnumValue *EnumValue `json:"enum_value,omitempty"` }
When a custom field is associated with a project, tasks in that project can carry additional custom field values which represent the value of the field on that particular task - for instance, the selected item from an enum type custom field. These custom fields will appear as an array in a custom_fields property of the task, along with some basic information which can be used to associate the custom field value with the custom field metadata.
type Date ¶
Date wraps the default time.Time type with appropriate JSON formatting for the Asana API when a date is required: '2012-03-26'
func (*Date) MarshalJSON ¶
MarshalJSON implements the json.Marshaller interface
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaller interface
type EnumValue ¶
type EnumValue struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` EnumValueBase Enabled bool `json:"enabled"` }
type EnumValueBase ¶
type Error ¶
type Error struct { StatusCode int Type string Message string `json:"message"` Phrase string `json:"phrase"` Help string `json:"help"` RetryAfter time.Duration `json:"-"` RequestID string `json:"-"` }
Error is an error message returned by the API
func IsAsanaError ¶
type ExternalData ¶
ExternalData allows a client application to add app-specific metadata to Tasks in the API. The custom data includes a string id that can be used to retrieve objects and a data blob that can store character strings.
The blob may store unicode-safe serialized data such as JSON or YAML. The external id is capped at 1,024 characters, while data blobs are capped at 32,768 characters. Each object supporting external data can have one id and one data blob stored with it. You can also use either or both of those fields.
The external id field is a good choice to create a reference between a resource in Asana and another database, such as cross-referencing an Asana task with a customer record in a CRM, or a bug in a dedicated bug tracker. Since it is just a unicode string, this field can store numeric IDs as well as URIs, however, when using URIs extra care must be taken when forming queries that the parameter is escaped correctly. By assigning an external id you can use the notation external:custom_id to reference your object anywhere that you may use the original object id.
Note: that you will need to authenticate with Oauth, as the id and data are app-specific, and these fields are not visible in the UI. This also means that external data set by one Oauth app will be invisible to all other Oauth apps. However, the data is visible to all users of the same app that can view the resource to which the data is attached, so this should not be used for private user data.
type LabelPosition ¶
type LabelPosition string
const ( Prefix LabelPosition = "prefix" Suffix LabelPosition = "suffix" )
type Membership ¶
type Membership struct { Project *Project `json:"project,omitempty"` Section *Section `json:"section,omitempty"` }
Membership describes projects a task is associated with and the section it is in.
type NewAttachment ¶
type NewAttachment struct { Reader io.ReadCloser FileName string ContentType string }
type Options ¶
type Options struct { // Provides the response in “pretty” output. In the case of JSON this // means doing proper line breaking and indentation to make it readable. // This will take extra time and increase the response size so it is // advisable only to use this during debugging. Pretty bool `json:"pretty,omitempty" url:"opt_pretty,omitempty"` // In environments that do not support the full range of HTTP verbs, this // can be helpful to override the request method sent by the browser, // allowing access to the full range of actions in the API. This should // only be used when absolutely necessary, as circumventing the browser’s // normal interpretation of the HTTP verbs can cause issues. For security // reasons, you cannot use this parameter from a GET request, you can only // use it to transform a POST request into something else (like a PUT or // DELETE). Method string `json:"method,omitempty" url:"-"` // Some requests return compact representations of objects, to conserve // resources and complete the request more efficiently. Other times // requests return more information than you may need. This option allows // you to list the exact set of fields that the API should be sure to // return for the objects. The field names should be provided as paths, // described below. The id of included objects will always be returned, // regardless of the field options. Fields []string `json:"fields,omitempty" url:"opt_fields,omitempty,comma"` // Query results and sub-objects are returned in compact form by default. // This option can be used to expand query results or sub-objects to // return more detailed information. Be sure you really need the // information in the expanded form, as executing a query with many // results in expanded form can be costly and return you a lot of data to // consume. If the fields option is also used, it will take precedence // over the expand option and prevent expansion. Expand []string `json:"expand,omitempty" url:"opt_expand,omitempty,comma"` // Returns the output in JSON-P format instead of plain JSON, to allow // requests to come from within browsers and work around the “same origin // policy.” The function named as the value of the opt_jsonp parameter // will be called with a single argument, a JavaScript object representing // the response. JSONP string `json:"jsonp,omitempty" url:"opt_jsonp,omitempty"` // The number of objects to return per page. The value must be between 1 and 100. Limit int `json:"limit,omitempty" url:"limit,omitempty"` // 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. Offset string `json:"offset,omitempty" url:"offset,omitempty"` // Headers FastAPI bool `json:"-" url:"-"` Enable []Feature `json:"-" url:"-"` Disable []Feature `json:"-" url:"-"` // Filters Workspace string `json:"workspace,omitempty" url:"workspace,omitempty"` Owner string `json:"owner,omitempty" url:"owner,omitempty"` }
Options - In addition to providing fields and their values in a request, you may also specify options to control how your request is interpreted and how the response is generated. For GET requests, options are specified as URL parameters prefixed with opt_. For POST or PUT requests, options are specified in the body, inside the top-level options object (a sibling of the data object).
These options can be used in combination in a single request, though some of them may conflict in their impact on the response.
type Portfolio ¶
type Portfolio struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` // contains filtered or unexported fields }
type Project ¶
type Project struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` ProjectBase // Read-only. The time at which this object was created. CreatedAt *time.Time `json:"created_at,omitempty"` // Read-only. Array of Custom Field Settings (in compact form). CustomFieldSettings []*CustomFieldSetting `json:"custom_field_settings,omitempty"` // Read-only. Array of users who are members of this project. Members []*User `json:"members,omitempty"` // Read-only. The time at which this object was last modified. // // Note: This does not currently reflect any changes in associations such // as tasks or comments that may have been added or removed from the // object. ModifiedAt *time.Time `json:"modified_at,omitempty"` // Create-only. The workspace or organization this object is associated // with. Once created, objects cannot be moved to a different workspace. // This attribute can only be specified at creation time. Workspace *Workspace `json:"workspace,omitempty"` // Array of custom field values set on the project for a custom field applied // to a parent portfolio. Take care to avoid confusing these custom field values // with the custom field settings in the custom_field_settings property. // // Please note that the gid returned on each custom field value is identical to // the gid of the custom field, which allows referencing the custom field through // the /custom_fields/{custom_field_gid} endpoint. CustomFields []*CustomFieldValue `json:"custom_fields,omitempty"` // Read-only. Array of users following this project. Followers are a // subset of members who receive all notifications for a project, the // default notification setting when adding members to a project in- // product. Followers []*User `json:"followers,omitempty"` // The current owner of the project, may be null. Owner *User `json:"owner,omitempty"` // Create-only. The team that this project is shared with. This field only // exists for projects in organizations. Team *Team `json:"team,omitempty"` // contains filtered or unexported fields }
Project represents a prioritized list of tasks in Asana. It exists in a single workspace or organization and is accessible to a subset of users in that workspace or organization, depending on its permissions.
Projects in organizations are shared with a single team. You cannot currently change the team of a project via the API. Non-organization workspaces do not have teams and so you should not specify the team of project in a regular workspace.
Followers of a project are a subset of the members of that project. Followers of a project will receive all updates including tasks created, added and removed from that project. Members of the project have access to and will receive status updates of the project. Adding followers to a project will add them as members if they are not already, removing followers from a project will not affect membership.
func (*Project) AddCustomFieldSetting ¶
func (p *Project) AddCustomFieldSetting(request *AddCustomFieldSettingRequest) (*CustomFieldSetting, error)
func (*Project) CreateSection ¶
func (p *Project) CreateSection(section *SectionBase) (*Section, error)
CreateSection creates a new section in the given project
func (*Project) InsertSection ¶
func (p *Project) InsertSection(request *SectionInsertRequest) error
InsertSection moves sections relative to each other in a board view. One of before_section or after_section is required.
Sections cannot be moved between projects.
At this point in time, moving sections is not supported in list views, only board views.
func (*Project) RemoveCustomFieldSetting ¶
func (*Project) Update ¶
func (p *Project) Update(request *UpdateProjectRequest, opts ...*Options) error
Update
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.
Updates the referenced project object
type ProjectBase ¶
type ProjectBase struct { // True if the project is archived, false if not. Archived projects do not // show in the UI by default and may be treated differently for queries. Archived bool `json:"archived,omitempty"` // Color of the object. Must be either null or one of: dark-pink, dark- // green, dark-blue, dark-red, dark-teal, dark-brown, dark-orange, dark- // purple, dark-warm-gray, light-pink, light-green, light-blue, light-red, // light-teal, light-yellow, light-orange, light-purple, light-warm-gray. Color string `json:"color,omitempty"` // A description of the project’s status containing a color (must be // either null or one of: green, yellow, red) and a short description. CurrentStatus *ProjectStatus `json:"current_status,omitempty"` // The layout (board or list view) of the project. DefaultView View `json:"default_view,omitempty"` // The day on which this project is due. This takes a date with format // YYYY-MM-DD. DueOn *Date `json:"due_on,omitempty"` // The notes of the text with formatting as HTML. HTMLNotes string `json:"html_notes,omitempty"` Icon string `json:"icon,omitempty"` // Opt In. Determines if the project is a template. IsTemplate bool `json:"is_template,omitempty"` // Read-only. The name of the object. Name string `json:"name,omitempty"` // More detailed, free-form textual information associated with the // object. Notes string `json:"notes,omitempty"` // True if the project is public to the organization. If false, do not // share this project with other users in this organization without // explicitly checking to see if they have access. Public bool `json:"public,omitempty"` // The day on which this project starts. This takes a date with format // YYYY-MM-DD. StartOn *Date `json:"start_on,omitempty"` }
ProjectBase contains the parts of Project which are not related to a specific instance
type ProjectStatus ¶
type ProjectStatus struct { Color string `json:"color,omitempty"` Text string `json:"text,omitempty"` Author *User `json:"author,omitempty"` }
ProjectStatus is a description of the project’s status containing a color (must be either null or one of: green, yellow, red) and a short description.
type Response ¶
type Response struct { Data json.RawMessage `json:"data"` NextPage *NextPage `json:"next_page"` Errors []*Error `json:"errors"` }
An API response
type Section ¶
type Section struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` SectionBase // Read-only. The time at which this object was created. CreatedAt *time.Time `json:"created_at,omitempty"` // Read-only. The project which contains the section. Project *Project `json:"project,omitempty"` // contains filtered or unexported fields }
A Section is a subdivision of a project that groups tasks together. It can either be a header above a list of tasks in a list view or a column in a board view of a project.
Sections are largely a shared idiom in Asana’s API for both list and board views of a project regardless of the project’s layout.
The ‘memberships’ property when getting a task will return the information for the section or the column under ‘section’ in the response.
type SectionBase ¶
type SectionBase struct { // Read-only. The name of the object. Name string `json:"name,omitempty"` }
type SectionInsertRequest ¶
type SectionMigrationStatus ¶
type SectionMigrationStatus string
const ( NotMigrated SectionMigrationStatus = "not_migrated" InProgress SectionMigrationStatus = "in_progress" Completed SectionMigrationStatus = "completed" )
type SetParentRequest ¶
type SetParentRequest struct { Parent string // Required: The new parent of the task, or null for no parent. InsertAfter string // A subtask of the parent to insert the task after, or "-" to insert at the beginning of the list. InsertBefore string // A subtask of the parent to insert the task before, or "-" to insert at the end of the list. }
SetParentRequest changes the parent of a task. Each task may only be a subtask of a single parent, or no parent task at all. When using insert_before and insert_after, at most one of those two options can be specified, and they must already be subtasks of the parent.
type Story ¶
type Story struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` StoryBase // Read-only. The time at which this object was created. CreatedAt *time.Time `json:"created_at,omitempty"` // True if the story is liked by the authorized user, false if not. // Note: This property only exists for stories that provide likes. Liked bool `json:"liked,omitempty"` // Read-only. Array of users who have liked this story. // Note: This property only exists for stories that provide likes. Likes []*User `json:"likes,omitempty"` // Read-only. The number of users who have liked this story. // Note: This property only exists for stories that provide likes. NumLikes int32 `json:"num_likes,omitempty"` // The user who created the story. CreatedBy *User `json:"created_by,omitempty"` // Read-only. The object this story is associated with. Currently may only // be a task. Target *Task `json:"target,omitempty"` // Read-only. The component of the Asana product the user used to trigger // the story. Source string `json:"source,omitempty"` // Read-only. The type of story. This provides fine-grained information about what // triggered the story’s creation. There are many story subtypes, so inspect the // data returned from Asana’s API to find the value for your use case. ResourceSubtype string `json:"resource_subtype,omitempty"` // A union of all possible subtype fields StorySubtypeFields // contains filtered or unexported fields }
Story represents an activity associated with an object in the Asana system. Stories are generated by the system whenever users take actions such as creating or assigning tasks, or moving tasks between projects. Comments are also a form of user-generated story.
Stories are a form of history in the system, and as such they are read- only. Once generated, it is not possible to modify a story.
func (*Story) UpdateStory ¶
UpdateStory updates the story and returns the full record for the updated story. Only comment stories can have their text updated, and only comment stories and attachment stories can be pinned. Only one of text and html_text can be specified.
type StoryBase ¶
type StoryBase struct { // Human-readable text for the story or comment. This will // not include the name of the creator. Can be edited only if the story is a comment. // // Note: This is not guaranteed to be stable for a given type of story. // For example, text for a reassignment may not always say “assigned to …” // as the text for a story can both be edited and change based on the language // settings of the user making the request. Use the resource_subtype property to // discover the action that created the story. Text string `json:"text,omitempty"` // HTML formatted text for a comment. This will not include the name of the creator. // Can be edited only if the story is a comment. // // Note: This field is only returned if explicitly requested using the // opt_fields query parameter. HTMLText string `json:"html_text,omitempty"` // Whether the story should be pinned on the resource. // Note: This field is only present on comment and attachment stories. IsPinned bool `json:"is_pinned,omitempty"` }
StoryBase contains the text of a story, as used when creating a new comment
type StorySubtypeFields ¶
type StorySubtypeFields struct { // Whether the text of the story has been edited after creation. // Note: This field is only present on comment stories. IsEdited bool `json:"is_edited,omitempty"` // Present for due_date_changed, dependency_due_date_changed NewDates *Dates `json:"new_dates,omitempty"` // Present for due_date_changed OldDates *Dates `json:"old_dates,omitempty"` // Present for name_changed OldName string `json:"old_name,omitempty"` NewName string `json:"new_name,omitempty"` // Present for resource_subtype_changed OldResourceSubtype string `json:"old_resource_subtype,omitempty"` NewResourceSubtype string `json:"new_resource_subtype,omitempty"` // Present for comment_liked, completion_liked Story *Story `json:"story,omitempty"` // Present for attachment_liked Attachment *Attachment `json:"attachment,omitempty"` // Present for assigned Assignee *User `json:"assignee,omitempty"` // Present for follower_added Follower *User `json:"follower,omitempty"` // Present for section_changed OldSection *Section `json:"old_section,omitempty"` NewSection *Section `json:"new_section,omitempty"` // Present for added_to_task, removed_from_task Task *Task `json:"task,omitempty"` // Present for added_to_project, removed_from_project Project *Project `json:"project,omitempty"` // Present for added_to_tag, removed_from_tag Tag *Tag `json:"tag,omitempty"` // Present for text_custom_field_changed, number_custom_field_changed, enum_custom_field_changed OldTextValue string `json:"old_text_value,omitempty"` NewTextValue string `json:"new_text_value,omitempty"` OldNumberValue float64 `json:"old_number_value,omitempty"` NewNumberValue float64 `json:"new_number_value,omitempty"` OldEnumValue *EnumValue `json:"old_enum_value,omitempty"` NewEnumValue *EnumValue `json:"new_enum_value,omitempty"` // Present for duplicate_merged, marked_duplicate, duplicate_unmerged DuplicateOf *Task `json:"duplicate_of,omitempty"` // Present for duplicated DuplicatedFrom *Task `json:"duplicated_from,omitempty"` // Present for dependency_added, dependency_removed, dependency_marked_complete, dependency_marked_incomplete, // dependency_due_date_changed Dependency *Task `json:"duplicated_from,omitempty"` // Present for dependent_added, dependent_removed Dependent *Task `json:"duplicated_from,omitempty"` }
type Tag ¶
type Tag struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` TagBase // Read-only. The time at which this object was created. CreatedAt *time.Time `json:"created_at,omitempty"` // Create-only. The workspace or organization this object is associated // with. Once created, objects cannot be moved to a different workspace. // This attribute can only be specified at creation time. Workspace *Workspace `json:"workspace,omitempty"` // Read-only. Array of users following this tag. Followers are a // subset of members who receive all notifications for a project, the // default notification setting when adding members to a project in- // product. Followers []*User `json:"followers,omitempty"` // contains filtered or unexported fields }
Tag is a label that can be attached to any task in Asana. It exists in a single workspace or organization.
Tags have some metadata associated with them, but it is possible that we will simplify them in the future so it is not encouraged to rely too heavily on it. Unlike projects, tags do not provide any ordering on the tasks they are associated with.
type TagBase ¶
type TagBase struct { // Read-only. The name of the object. Name string `json:"name,omitempty"` // More detailed, free-form textual information associated with the // object. Notes string `json:"notes,omitempty"` // Color of the object. Must be either null or one of: dark-pink, dark- // green, dark-blue, dark-red, dark-teal, dark-brown, dark-orange, dark- // purple, dark-warm-gray, light-pink, light-green, light-blue, light-red, // light-teal, light-yellow, light-orange, light-purple, light-warm-gray. Color string `json:"color,omitempty"` }
TagBase contains the modifiable fields for a Tag
type Task ¶
type Task struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` TaskBase // Read-only. The task this object is attached to. Parent *Task `json:"parent,omitempty"` // Read-only. The time at which this object was created. CreatedAt *time.Time `json:"created_at,omitempty"` // Read-only. The time at which this object was last modified. // // Note: This does not currently reflect any changes in associations such // as tasks or comments that may have been added or removed from the // object. ModifiedAt *time.Time `json:"modified_at,omitempty"` // Create-only. The workspace or organization this object is associated // with. Once created, objects cannot be moved to a different workspace. // This attribute can only be specified at creation time. Workspace *Workspace `json:"workspace,omitempty"` // True if the task is liked by the authorized user, false if not. Liked bool `json:"liked,omitempty"` // Read-only. Array of users who have liked this task. Likes []*User `json:"likes,omitempty"` // Read-only. The number of users who have liked this task. NumLikes int32 `json:"num_likes,omitempty"` // Read-only. Opt In. The number of subtasks on this task. NumSubtasks int32 `json:"num_subtasks,omitempty"` // Read-only. Array of users following this task. Followers are a // subset of members who receive all notifications for a project, the // default notification setting when adding members to a project in- // product. Followers []*User `json:"followers,omitempty"` // User to which this task is assigned, or null if the task is unassigned. Assignee *User `json:"assignee,omitempty"` // Scheduling status of this task for the user it is assigned to. This // field can only be set if the assignee is non-null. AssigneeStatus string `json:"assignee_status,omitempty"` // Read-only. The time at which this task was completed, or null if the // task is incomplete. CompletedAt *time.Time `json:"completed_at,omitempty"` // Array of custom fields applied to the task. These custom fields // represent the values recorded on this task for a particular custom // field. For example, these fields will contain an enum_value property // for custom fields of type enum, a string_value property for custom // fields of type string, and so on. Please note that the id returned on // each custom field value is identical to the id of the custom field, // which allows referencing the custom field metadata through the // /custom_fields/custom_field-id endpoint. CustomFields []*CustomFieldValue `json:"custom_fields,omitempty"` // Create-only. Array of projects this task is associated with. At task // creation time, this array can be used to add the task to many projects // at once. After task creation, these associations can be modified using // the addProject and removeProject endpoints. Projects []*Project `json:"projects,omitempty"` // Create-only. Array of projects this task is associated with and the // section it is in. At task creation time, this array can be used to add // the task to specific sections. After task creation, these associations // can be modified using the addProject and removeProject endpoints. Note // that over time, more types of memberships may be added to this // property. Memberships []*Membership `json:"memberships,omitempty"` // Create-only. Array of tags associated with this task. This property may // be specified on creation using just an array of tag IDs. In order to // change tags on an existing task use addTag and removeTag. Tags []*Tag `json:"tags,omitempty"` // Read-only. Array of resources referencing tasks that this task depends on. // The objects contain only the ID of the dependency. Dependencies []*Task `json:"dependencies,omitempty"` // Read-only. Array of resources referencing tasks that depend on this task. // The objects contain only the ID of the dependent. Dependents []*Task `json:"dependents,omitempty"` // contains filtered or unexported fields }
Task is the basic object around which many operations in Asana are centered. In the Asana application, multiple tasks populate the middle pane according to some view parameters, and the set of selected tasks determines the more detailed information presented in the details pane.
A section, at its core, is a task whose name ends with the colon character :. Sections are unique in that they will be included in the memberships field of task objects returned in the API when the task is within a section. As explained below they can also be used to manipulate the ordering of a task within a project.
Queries return a compact representation of each object which is typically the id and name fields. Interested in a specific set of fields or all of the fields? Use field selectors to manipulate what data is included in a response.
func (*Task) AddDependencies ¶
func (t *Task) AddDependencies(request *AddDependenciesRequest) error
AddDependencies marks a set of tasks as dependencies of this task, if they are not already dependencies. A task can have at most 15 dependencies.
func (*Task) AddDependents ¶
func (t *Task) AddDependents(request *AddDependentsRequest) error
AddDependents marks a set of tasks as dependents of this task, if they are not already dependents. A task can have at most 30 dependents.
func (*Task) AddProject ¶
func (t *Task) AddProject(request *AddProjectRequest) error
AddProject adds this task to an existing project at the provided location
func (*Task) Attachments ¶
func (t *Task) Attachments(opts ...*Options) ([]*Attachment, *NextPage, error)
Attachments lists all attachments attached to a task
func (*Task) CreateAttachment ¶
func (t *Task) CreateAttachment(request *NewAttachment) (*Attachment, error)
func (*Task) CreateComment ¶
CreateComment adds a comment story to a task
func (*Task) CreateSubtask ¶
CreateSubtask creates a new task as a subtask of this task
func (*Task) RemoveProject ¶
func (*Task) SetParent ¶
func (t *Task) SetParent(request *SetParentRequest) error
SetParent changes the parent of a task
func (*Task) Update ¶
func (t *Task) Update(update *UpdateTaskRequest) error
Update applies new values to a Task record
type TaskBase ¶
type TaskBase struct { // Name of the task. This is generally a short sentence fragment that // fits on a line in the UI for maximum readability. However, it can be longer. Name string `json:"name,omitempty"` // The type of task. Different subtypes of tasks retain many of // the same fields and behavior, but may render differently in Asana or // represent tasks with different semantic meaning. ResourceSubtype string `json:"resource_subtype,omitempty"` // More detailed, free-form textual information associated with the // task. Notes string `json:"notes,omitempty"` // The notes of the text with formatting as HTML. HTMLNotes string `json:"html_notes,omitempty"` // Scheduling status of this task for the user it is assigned to. This // field can only be set if the assignee is non-null. AssigneeStatus string `json:"assignee_status,omitempty"` // True if the task is currently marked complete, false if not. Completed *bool `json:"completed,omitempty"` // Date on which this task is due, or null if the task has no due date. // This takes a date with YYYY-MM-DD format and should not be used // together with due_at. DueOn *Date `json:"due_on,omitempty"` // Date and time on which this task is due, or null if the task has no due // time. This takes a UTC timestamp and should not be used together with // due_on. DueAt *time.Time `json:"due_at,omitempty"` // Date on which this task is due, or null if the task has no start date. // This field takes a date with YYYY-MM-DD format. // Note: due_on or due_at must be present in the request when setting or // unsetting the start_on parameter. StartOn *Date `json:"start_on,omitempty"` // Oauth Required. The external field allows you to store app-specific // metadata on tasks, including an id that can be used to retrieve tasks // and a data blob that can store app-specific character strings. Note // that you will need to authenticate with Oauth to access or modify this // data. Once an external id is set, you can use the notation // external:custom_id to reference your object anywhere in the API where // you may use the original object id. See the page on Custom External // Data for more details. External *ExternalData `json:"external,omitempty"` // Indicates whether a default task is rendered as bolded and underlined // when viewed in a list of subtasks or in a user’s My Tasks. // Requires that the NewSections deprecation is enabled. IsRenderedAsSeparator bool `json:"is_rendered_as_separator,omitempty"` }
TaskBase contains the modifiable fields for the Task object
type TaskQuery ¶
type TaskQuery struct { // The assignee to filter tasks on. // // Note: If you specify assignee, you must also specify the workspace to filter on. // // May be a GID, 'me' or user email string ('14113', 'me', 'me@example.com') Assignee string `url:"assignee,omitempty"` // The project to filter tasks on Project string `url:"project,omitempty"` // The section to filter tasks on. // // Note: Currently, this is only supported in board views. Section string `url:"section,omitempty"` // The workspace or organization to filter tasks on. // // Note: If you specify workspace, you must also specify the assignee to filter on. Workspace string `url:"workspace,omitempty"` // Only return tasks that are either incomplete or that have been completed since this time. // // May be 'now' or a date string CompletedSince string `url:"completed_since,omitempty"` // Only return tasks that have been modified since the given time. // // Note: A task is considered “modified” if any of its properties change, // or associations between it and other objects are modified (e.g. a task // being added to a project). A task is not considered modified just // because another object it is associated with (e.g. a subtask) is // modified. Actions that count as modifying the task include assigning, // renaming, completing, and adding stories. // // May be 'now' or a date string ModifiedSince string `url:"modified_since,omitempty"` }
TaskQuery specifies which tasks to return from QueryTasks
type Team ¶
type Team struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` // Read-only. The name of the object. Name string `json:"name,omitempty"` // The description of the team with formatting as HTML. Description string `json:"description,omitempty"` // The description of the team with formatting as HTML. HTMLDescription string `json:"html_description,omitempty"` Organization *Workspace `json:"organization,omitempty"` // contains filtered or unexported fields }
Team is used to group related projects and people together within an organization. Each project in an organization is associated with a team.
func (*Team) AllProjects ¶
AllProjects repeatedly pages through all available projects in a team
func (*Team) CreateProject ¶
func (t *Team) CreateProject(c *Client, project *CreateProjectRequest) (*Project, error)
CreateProject adds a new project to a team
type UpdateProjectRequest ¶
type UpdateProjectRequest struct { ProjectBase Owner string `json:"owner,omitempty"` CustomFields map[string]interface{} `json:"custom_fields,omitempty"` }
UpdateProjectRequest represents a request to update a project
type UpdateTaskRequest ¶
type User ¶
type User struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` // Read-only. The name of the object. Name string `json:"name,omitempty"` // Read-only. The user’s email address. Email string `json:"email,omitempty"` // Read-only. A map of the user’s profile photo in various sizes, or null // if no photo is set. Sizes provided are 21, 27, 36, 60, and 128. Images // are in PNG format. Photo map[string]string `json:"photo,omitempty"` // Read-only. Workspaces and organizations this user may access. // // Note: The API will only return workspaces and organizations that also // contain the authenticated user. Workspaces []*Workspace `json:"workspaces,omitempty"` // contains filtered or unexported fields }
User represents an account in Asana that can be given access to various workspaces, projects, and tasks.
Like other objects in the system, users are referred to by numerical IDs. However, the special string identifier me can be used anywhere a user ID is accepted, to refer to the current authenticated user.
type Validator ¶
type Validator interface {
Validate() error
}
Validator types have a Validate method which is called before posting the data to the API
type Workspace ¶
type Workspace struct { // Read-only. Globally unique ID of the object ID string `json:"gid,omitempty"` // Read-only. The name of the object. Name string `json:"name,omitempty"` // Whether the workspace is an organization. IsOrganization bool `json:"is_organization,omitempty"` // Undocumented in API docs EmailDomains []string `json:"email_domains,omitempty"` // contains filtered or unexported fields }
Workspace is the highest-level organizational unit in Asanc. All projects and tasks have an associated workspace.
An organization is a special kind of workspace that represents a company. In an organization, you can group your projects into teams. You can read more about how organizations work on the Asana Guide. To tell if your workspace is an organization or not, check its is_organization property.
Over time, we intend to migrate most workspaces into organizations and to release more organization-specific functionality. We may eventually deprecate using workspace-based APIs for organizations. Currently, and until after some reasonable grace period following any further announcements, you can still reference organizations in any workspace parameter.
func (*Workspace) AllCustomFields ¶
func (w *Workspace) AllCustomFields(options ...*Options) ([]*CustomField, error)
AllCustomFields repeatedly pages through all available custom fields in a workspace
func (*Workspace) AllFavoriteProjects ¶
AllProjects repeatedly pages through all available projects in a workspace
func (*Workspace) AllProjects ¶
AllProjects repeatedly pages through all available projects in a workspace
func (*Workspace) CustomFields ¶
func (w *Workspace) CustomFields(options ...*Options) ([]*CustomField, *NextPage, error)
CustomFields returns the compact records for all custom fields in the workspace
func (*Workspace) FavoriteProjects ¶
FavoriteProjects returns a list of the current user's favorite projects in this workspace
func (*Workspace) Portfolios ¶
Projects returns a list of projects in this workspace