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 Calendars in Google Calendar



Overview

The following operations allow you to work with calendars. Click an operation name to see details on how to use it.

OperationDescription
clearCalendarClears a primary calendar.
createCalendarCreates a secondary calendar,
deleteCalendarDeletes a secondary calendar.
getCalendarReturns metadata for a calendar.
patchCalendarUpdates metadata for a calendar.

For a sample proxy service that illustrates how to work with calendars, see  Sample configuration .

Operation details

Following is more information about each of the operations.

Clearing a calendar

To clear a primary calendar, use googlecalendar.clearCalendar and specify the calendarId property. This operation deletes all the data associated with the primary calendar of an account and cannot be undone.

clearCalendar
<googlecalendar.clearCalendar>
	<calendarId>{$ctx:calendarId}</calendarId>
</googlecalendar.clearCalendar>
Properties
  • calendarId: Required - The calendar Identifier.
Sample request

Following is a sample REST request that can be handled by the clearCalendar operation. 

Sample Request for clearCalendar
 {
"apiUrl":"https://www.googleapis.com",
"accessToken":"ya29.1.AADtN_XkV7CJODQeWv12ZvqA3oAcQ51tkMiZmx1i3PWJOOOh9rbP--RCUKkkLVMfMA",
"calendarId":"a06igjtg8d6v4hmsvp6o2s5vbg@group.calendar.google.com"
}
Related Google Calendar documentation

https://developers.google.com/google-apps/calendar/v3/reference/calendars/clear

Creating a calendar

To create a secondary calendar, use googlecalendar.createCalendar and specify the relevant properties.

createCalendar
<googlecalendar.createCalendar>
	<fields>{$ctx:fields}</fields>
	<summary>{$ctx:summary}</summary>
    <description>{$ctx:description}</description>
   	<etag>{$ctx:etag}</etag>
    <id>{$ctx:id}</id>
    <kind>{$ctx:kind}</kind>
    <location>{$ctx:location}</location>
    <timeZone>{$ctx:timeZone}</timeZone>
</googlecalendar.createCalendar>
  Properties
  • fields: Selector specifying which fields to include in a partial response.
  • summary: Required - The title of the calendar.
  • description: Optional - Description of the calendar.
  • etag: ETag of the resource.
  • id: The identifier of the calendar.
  • kind: The type of the resource.
  • location: Optional - The geographic location of the calendar as free-form text.
  • timeZone: Optional - The time zone of the calendar.
Sample request

Following is a sample REST request that can be handled by the createCalendar operation. 

Sample Request for createCalendar
 {
	"apiUrl":"https://www.googleapis.com",
	"accessToken":"ya29.1.AADtN_V49E5Y5a4SjtW4b0wdqLAdzSQwQNfC2Wy2tKkzinXnGdJH9owGQmio80zmBUkUsrC8",
	"fields":"description,etag,id,kind,summary,location",
	"summary":"CALENDAR_1",
	"description":"some description",
	"etag":"uz4dSMPAwpogj1sIr_PP7Gm-AxY/df0l2GtmRpH7Pn3FWAvvSHhatrM",
	"id":"",
	"kind":"calendar#calendar",
	"location":"Colombo-Western Provice",
	"timeZone":""	
}
Related Google Calendar documentation

https://developers.google.com/google-apps/calendar/v3/reference/calendars/insert

Deleting a calendar

To delete a secondary calendar, use googlecalendar.deleteCalendar and specify the calendarId property.

deleteCalendar
<googlecalendar.deleteCalendar>
	<calendarId>{$ctx:calendarId}</calendarId>
</googlecalendar.deleteCalendar>	 
  Properties
  • calendarId: Required - Calendar Identifier.
Sample request

Following is a sample REST request that can be handled by the deleteCalendar operation.

Sample Request for deleteCalendar
 {
"apiUrl":"https://www.googleapis.com",
"accessToken":"ya29.1.AADtN_XcBWc2mBP2ay7r8HRKPlTLYJ6J81Hi89qfJ_EaAu3w08ZqjeW4DK9e8wtSUDWC-n5t",
"calendarId":"b5ip8t9ievatrl8hfd8vq340oo@group.calendar.google.com"
}
Related Google Calendar documentation

https://developers.google.com/google-apps/calendar/v3/reference/calendars/delete

Returning metadata for a calendar

To return metadata for a calendar, use googlecalendar.getCalendar and specify the relevant properties.

getCalendar
<googlecalendar.getCalendar>
	<calendarId>{$ctx:calendarId}</calendarId>
    <fields>{$ctx:fields}</fields>
</googlecalendar.getCalendar>
Properties
  • calendarId: Required - The calendar identifier.
  • fields: Selector specifying which fields to include in a partial response.
Sample request

Following is a sample REST request that can be handled by the getCalendar operation.

Sample Request for getCalendar
 {
"apiUrl":"https://www.googleapis.com",
"accessToken":"ya29.1.AADtN_XjaNHS89iI6ms7CYm-EoZQkO8CKJTDiZBcgl1kltjdAURorNpYWwZOjYKSpw",
"calendarId":"pa76dcsrgf8o9udhaqnpqsmslc@group.calendar.google.com",
"fields":"description,etag,id,kind,location,summary,timeZone"
}

Following is more information about the fields parameter:

  • fields: Includes values such as description,etag, id, kind, location, summary and timeZone.
Related Google Calendar documentation

https://developers.google.com/google-apps/calendar/v3/reference/calendars/get

Updating a calendar

To update metadata of a calendar, use googlecalendar.patchCalendar and specify the relevant properties.

patchCalendar
<googlecalendar.patchCalendar>
	<calendarId>{$ctx:calendarId}</calendarId>
    <fields>{$ctx:fields}</fields>
	<description>{$ctx:description}</description>
	<etag>{$ctx:etag}</etag>
	<id>{$ctx:id}</id>
	<kind>{$ctx:kind}</kind>
	<location>{$ctx:location}</location>
	<summary>{$ctx:summary}</summary>
	<timeZone>{$ctx:timeZone}</timeZone>
</googlecalendar.patchCalendar> 
  Properties
  • calendarId: Required - The calendar identifier.
  • fields: Selector specifying which fields to include in a partial response.
  • description: Optional - Description of the calendar. To set an empty description, a space has to be sent as the description. i.e., description:" "
  • etag: ETag of the resource.
  • id: The identifier of the calendar.
  • kind: The type of the resource.
  • location: Optional - The geographic location of the calendar as free-form text. To set an empty location, a space needs to be sent as the location. i.e.,location:" "
  • summary: Required - The title of the calendar.
  • timeZone: Optional - The time zone of the calendar.To set an empty timeZone, a space needs to be sent as the timeZone. i.e., timeZone:" "
Sample Request

Following is a sample REST request that can be handled by the patchCalendar operation.  

Sample Request for patchCalendar
 {
	"apiUrl": "https://www.googleapis.com",
	"accessToken": "ya29.1.AADtN_XANN7ZP08GGZx24eN4mPGgLiyc4xltOoGIDSNDJso9xenf9vPfYD-r-8Z9gA4Fsoaw",
	"calendarId": "wso2connector.abdera@gmail.com"
}

Following is more information about the fields parameter:

  • fields: Includes values such as description,etag, id, kind, location, summary and timeZone.
Related Google Calendar documentation

https://developers.google.com/google-apps/calendar/v3/reference/calendars/patch

Sample configuration

Following is a sample proxy service that illustrates how to connect to Google Calendar with the init operation as well as how to use the clearCalendar operation to clear a primary calendar.

To view the sample request for this proxy, see sample request for the clearCalendar operation . You can use this sample as a template for using other operations in this category.

 As a best practice, create a separate sequence for handling the response payload for errors. In the following sample, this sequence is faultHandlerSeq.

Sample Proxy
<proxy xmlns="http://ws.apache.org/ns/synapse" 
name="googlecalendar_clearCalendar" 
transports="https,http" 
statistics="disable" 
trace="disable" 
startOnLoad="true">
  <target>
    <inSequence onError="faultHandlerSeq">
	  <property name="apiUrl" expression="json-eval($.apiUrl)"/>
      <property name="accessToken" expression="json-eval($.accessToken)"/>
	  <property name="calendarId" expression="json-eval($.calendarId)"/>     
	  <googlecalendar.init>
        <apiUrl>{$ctx:apiUrl}</apiUrl>
        <accessToken>{$ctx:accessToken}</accessToken>
      </googlecalendar.init>	  
      <googlecalendar.clearCalendar>
        <calendarId>{$ctx:calendarId}</calendarId>
      </googlecalendar.clearCalendar>	  
	  <respond></respond>
    </inSequence>
    <outSequence>
      <send></send>
    </outSequence>
	<faultSequence>
		 <property name="ERROR_CODE" value="600500"/>
		 <property name="ERROR_MESSAGE" value="Internal Server Error"/>
		 <property name="messageType" value="application/json" scope="axis2"/>
         <sequence key="faultHandlerSeq"/>
    </faultSequence>
  </target>
</proxy>