This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Working with Labels in Gmail
Overview
The following operations allow you to work with labels. Click an operation name to see details on how to use it.
For a sample proxy service that illustrates how to work with labels, see Sample configuration.
Operation | Description |
---|---|
Lists all labels | |
readLabel | Gets a label's details |
createLabels | Creates a new label |
updateLabels | Updates an existing label |
deleteLabel | Deletes a label |
Operation details
This section provides further details on the operations related to labels.
Listing all labels
The listLabels
operation lists all existing labels.
</gmail.listLabels>
Related Gmail documentation
https://developers.google.com/gmail/api/v1/reference/users/labels/list
Getting a label's details
The readLabel
operation gets a label's details.
<gmail.readLabel> <id>{$ctx:id}</id> </gmail.readLabel>
Properties
id
: The ID of the label whose details you want to retrieve.
Sample request
Following is a sample REST/JSON request that can be handled by the readLabel
operation.
{ "id":"Label_1" }
Related Gmail documentation
https://developers.google.com/gmail/api/v1/reference/users/labels/get
Creating a new label
The createLabels
operation creates a new label.
<gmail.createLabels> <name>{$ctx:name}</name> <messageListVisibility>{$ctx:messageListVisibility}</messageListVisibility> <labelListVisibility>{$ctx:labelListVisibility}</labelListVisibility> <type>{$ctx:type}</type> <messagesTotal>{$ctx:messagesTotal}</messagesTotal> <messagesUnread>{$ctx:messagesUnread}</messagesUnread> <threadsTotal>{$ctx:threadsTotal}</threadsTotal> <threadsUnread>{$ctx:threadsUnread}</threadsUnread> </gmail.createLabels>
Properties
name
: The display name of the label.messageListVisibility
: The visibility of messages with this label in the message list in the Gmail web interface.labelListVisibility
: The visibility of the label in the label list in the Gmail web interface.type
: The owner type for the label.messagesTotal
: The total number of messages with the label.messagesUnread
: The number of unread messages with the label.threadsTotal
: The total number of threads with the label.threadsUnread
: The number of unread threads with the label
Sample request
Following is a sample REST/JSON request that can be handled by the createLabels
operation.
{ "name": "TestESB2", "threadsUnread": 100, "messageListVisibility": "show", "threadsTotal": 100, "type": "user", "messagesTotal": 100, "messagesUnread": 100, "labelListVisibility": "labelShow" }
Related Gmail documentation
https://developers.google.com/gmail/api/v1/reference/users/labels/create
Update labels
The updateLabels
operation updates an existing label.
<gmail.updateLabels> <name>{$ctx:name}</name> <messageListVisibility>{$ctx:messageListVisibility}</messageListVisibility> <labelListVisibility>{$ctx:labelListVisibility}</labelListVisibility> <type>{$ctx:type}</type> <messagesTotal>{$ctx:messagesTotal}</messagesTotal> <messagesUnread>{$ctx:messagesUnread}</messagesUnread> <threadsTotal>{$ctx:threadsTotal}</threadsTotal> <threadsUnread>{$ctx:threadsUnread}</threadsUnread> <id>{$ctx:id}</id> </gmail.updateLabels>
Properties
name:
The display name of the label.messageListVisibility
: The visibility of messages with this label in the message list in the Gmail web interface.labelListVisibility
: The visibility of the label in the label list in the Gmail web interface.type
: The owner type for the label.messagesTotal
: The total number of messages with the label.messagesUnread
: The number of unread messages with the label.threadsTotal
: The total number of threads with the label.threadsUnread
: The number of unread threads with the label.id
:The ID of the label to update.
Sample request
Following is a sample REST/JSON request that can be handled by the updateLabels
operation.
{ "id":"426572682792", "name": "TestESB2", "threadsUnread": 100, "messageListVisibility": "show", "threadsTotal": 100, "type": "user", "messagesTotal": 100, "messagesUnread": 100, "labelListVisibility": "labelShow" }
Related Gmail documentation
https://developers.google.com/gmail/api/v1/reference/users/labels/update
Deleting a label
The deleteLabel
operation deletes a label.
<gmail.deleteLabel> <id>{$ctx:id}</id> </gmail.deleteLabel>
Properties
id
: The ID of the label to delete.
Sample request
Following is a sample REST/JSON request that can be handled by the deleteLabel
operation.
{ "id":"57648478394803" }
Related Gmail documentation
https://developers.google.com/gmail/api/v1/reference/users/labels/delete
Sample configuration
Following is a sample proxy service that illustrates how to connect to Gmail with the init
operation and use the readLabel
operation. The sample request for this proxy can be found in readLabel
sample request. You can use this sample as a template for using other operations in this category.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="gmail_listLabels" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <property name="id" expression="json-eval($.id)"/> <property name="format" expression="json-eval($.format)"/> <property name="metadataHeaders" expression="json-eval($.metadataHeaders)"/> <property name="userId" expression="json-eval($.userId)"/> <property name="refreshToken" expression="json-eval($.refreshToken)"/> <property name="clientId" expression="json-eval($.clientId)"/> <property name="clientSecret" expression="json-eval($.clientSecret)"/> <property name="accessToken" expression="json-eval($.accessToken)"/> <property name="registryPath" expression="json-eval($.registryPath)"/> <property name="apiUrl" expression="json-eval($.apiUrl)"/> <gmail.init> <userId>{$ctx:userId}</userId> <refreshToken>{$ctx:refreshToken}</refreshToken> <clientSecret>{$ctx:clientSecret}</clientSecret> <clientId>{$ctx:clientId}</clientId> <registryPath>{$ctx:registryPath}</registryPath> <accessToken>{$ctx:accessToken}</accessToken> <apiUrl>{$ctx:apiUrl}</apiUrl> </gmail.init> <gmail.readLabel> <id>{$ctx:id}</id> </gmail.readLabel> <respond/> </inSequence> <outSequence> <log/> <send/> </outSequence> </target> <parameter name="serviceType">proxy</parameter> <description/> </proxy>