इस दस्तावेज़ में, बार-बार होने वाले इवेंट और उनके इंस्टेंस के साथ काम करने का तरीका बताया गया है.
बार-बार होने वाले इवेंट बनाना
बार-बार होने वाले इवेंट बनाना, event संसाधन के recurrence फ़ील्ड को सेट करके, सामान्य (एक बार होने वाला) इवेंट बनाने जैसा ही है.
प्रोटोकॉल
POST /calendar/v3/calendars/primary/events ... { "summary": "Appointment", "location": "Somewhere", "start": { "dateTime": "2011-06-03T10:00:00.000-07:00", "timeZone": "America/Los_Angeles" }, "end": { "dateTime": "2011-06-03T10:25:00.000-07:00", "timeZone": "America/Los_Angeles" }, "recurrence": [ "RRULE:FREQ=WEEKLY;UNTIL=20110701T170000Z", ], "attendees": [ { "email": "attendeeEmail", # Other attendee's data... }, # ... ], }
Java
Event event = new Event(); event.setSummary("Appointment"); event.setLocation("Somewhere"); ArrayList<EventAttendee> attendees = new ArrayList<EventAttendee>(); attendees.add(new EventAttendee().setEmail("attendeeEmail")); // ... event.setAttendees(attendees); DateTime start = DateTime.parseRfc3339("2011-06-03T10:00:00.000-07:00"); DateTime end = DateTime.parseRfc3339("2011-06-03T10:25:00.000-07:00"); event.setStart(new EventDateTime().setDateTime(start).setTimeZone("America/Los_Angeles")); event.setEnd(new EventDateTime().setDateTime(end).setTimeZone("America/Los_Angeles")); event.setRecurrence(Arrays.asList("RRULE:FREQ=WEEKLY;UNTIL=20110701T170000Z")); Event recurringEvent = service.events().insert("primary", event).execute(); System.out.println(createdEvent.getId());
.NET
Event event = new Event() { Summary = "Appointment", Location = "Somewhere", Start = new EventDateTime() { DateTime = new DateTime("2011-06-03T10:00:00.000:-07:00") TimeZone = "America/Los_Angeles" }, End = new EventDateTime() { DateTime = new DateTime("2011-06-03T10:25:00.000:-07:00") TimeZone = "America/Los_Angeles" }, Recurrence = new String[] { "RRULE:FREQ=WEEKLY;UNTIL=20110701T170000Z" }, Attendees = new List<EventAttendee>() { new EventAttendee() { Email: "attendeeEmail" }, // ... } }; Event recurringEvent = service.Events.Insert(event, "primary").Fetch(); Console.WriteLine(recurringEvent.Id);
Python
event = { 'summary': 'Appointment', 'location': 'Somewhere', 'start': { 'dateTime': '2011-06-03T10:00:00.000-07:00', 'timeZone': 'America/Los_Angeles' }, 'end': { 'dateTime': '2011-06-03T10:25:00.000-07:00', 'timeZone': 'America/Los_Angeles' }, 'recurrence': [ 'RRULE:FREQ=WEEKLY;UNTIL=20110701T170000Z', ], 'attendees': [ { 'email': 'attendeeEmail', # Other attendee's data... }, # ... ], } recurring_event = service.events().insert(calendarId='primary', body=event).execute() print recurring_event['id']
PHP
$event = new Google_Service_Calendar_Event(); $event->setSummary('Appointment'); $event->setLocation('Somewhere'); $start = new Google_Service_Calendar_EventDateTime(); $start->setDateTime('2011-06-03T10:00:00.000-07:00'); $start->setTimeZone('America/Los_Angeles'); $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); $end->setDateTime('2011-06-03T10:25:00.000-07:00'); $end->setTimeZone('America/Los_Angeles'); $event->setEnd($end); $event->setRecurrence(array('RRULE:FREQ=WEEKLY;UNTIL=20110701T170000Z')); $attendee1 = new Google_Service_Calendar_EventAttendee(); $attendee1->setEmail('attendeeEmail'); // ... $attendees = array($attendee1, // ... ); $event->attendees = $attendees; $recurringEvent = $service->events->insert('primary', $event); echo $recurringEvent->getId();
Ruby
event = Google::Apis::CalendarV3::Event.new( summary: 'Appointment', location: 'Somewhere', start: { date_time: '2011-06-03T10:00:00.000-07:00', time_zone: 'America/Los_Angeles' }, end: { date_time: '2011-06-03T10:25:00.000-07:00', time_zone: 'America/Los_Angeles' }, recurrence: ['RRULE:FREQ=WEEKLY;UNTIL=20110701T170000Z'] attendees: [ { email: 'attendeeEmail' }, #... ] ) response = client.insert_event('primary', event) print response.id
इंस्टेंस ऐक्सेस करना
किसी तय समय पर बार-बार होने वाले इवेंट के सभी उदाहरण देखने के लिए, events.instances() अनुरोध का इस्तेमाल किया जा सकता है.
events.list() अनुरोध डिफ़ॉल्ट रूप से, सिर्फ़ एक बार होने वाले इवेंट, बार-बार होने वाले इवेंट, और अपवादों को दिखाता है. अपवाद नहीं माने जाने वाले इंस्टेंस नहीं दिखाए जाते.
अगर singleEvents पैरामीटर को true पर सेट किया जाता है, तो नतीजे में सभी अलग-अलग इंस्टेंस दिखते हैं. हालांकि, बार-बार होने वाले इवेंट नहीं दिखते. जब किसी ऐसे उपयोगकर्ता के पास
के लिए, उपलब्धता की जानकारी देखने की अनुमति होती है जो events.list() से क्वेरी करता है, तो यह इस तरह काम करता है जैसे singleEvent, true हो. ऐक्सेस कंट्रोल लिस्ट के नियमों के बारे में ज़्यादा जानने के लिए, Acl देखें.
अलग-अलग इंस्टेंस, सिंगल इवेंट की तरह होते हैं. पैरंट के तौर पर मौजूद पुनरावर्ती इवेंट के उलट, इंस्टेंस के लिए recurrence फ़ील्ड सेट नहीं होता.
यहां दिए गए इवेंट फ़ील्ड, इंस्टेंस के लिए खास तौर पर बनाए गए हैं:
recurringEventId— यह इंस्टेंस जिस पैरंट बार-बार होने वाले इवेंट का हिस्सा है उसका आईडीoriginalStartTime— यह इंस्टेंस, बार-बार होने वाले पैरंट इवेंट के दोहराए जाने के डेटा के हिसाब से कब शुरू होगा. अगर इंस्टेंस को फिर से शेड्यूल किया गया था, तो यह असलstartसमय से अलग हो सकता है. यह बार-बार होने वाले इवेंट की सीरीज़ में मौजूद इंस्टेंस की यूनीक पहचान करता है. भले ही, इंस्टेंस को दूसरी जगह ले जाया गया हो.
उदाहरणों में बदलाव करना या उन्हें मिटाना
किसी एक इंस्टेंस में बदलाव करने (अपवाद बनाना) के लिए, क्लाइंट ऐप्लिकेशन को पहले इंस्टेंस को वापस पाना होगा. इसके बाद, उसे अपडेट करना होगा. इसके लिए, उसे इंस्टेंस में बदलाव करने वाले यूआरएल पर, अनुमति वाला PUT अनुरोध भेजना होगा. साथ ही, अपडेट किए गए डेटा को बॉडी में शामिल करना होगा. यूआरएल इस फ़ॉर्मैट में होता है:
https://www.googleapis.com/calendar/v3/calendars/calendarId/events/instanceId
calendarId और instanceId की जगह सही वैल्यू का इस्तेमाल करें.
अनुरोध पूरा होने पर, सर्वर अपडेट किए गए इंस्टेंस के साथ एचटीटीपी 200 OK स्टेटस कोड दिखाता है. यहां दिए गए उदाहरण में, बार-बार होने वाले इवेंट के किसी इंस्टेंस को रद्द करने का तरीका बताया गया है.
प्रोटोकॉल
PUT /calendar/v3/calendars/primary/events/instanceId
...
{
"kind": "calendar#event",
"id": "instanceId",
"etag": "instanceEtag",
"status": "cancelled",
"htmlLink": "https://www.google.com/calendar/event?eid=instanceEid",
"created": "2011-05-23T22:27:01.000Z",
"updated": "2011-05-23T22:27:01.000Z",
"summary": "Recurring event",
"location": "Somewhere",
"creator": {
"email": "userEmail"
},
"recurringEventId": "recurringEventId",
"originalStartTime": "2011-06-03T10:00:00.000-07:00",
"organizer": {
"email": "userEmail",
"displayName": "userDisplayName"
},
"start": {
"dateTime": "2011-06-03T10:00:00.000-07:00",
"timeZone": "America/Los_Angeles"
},
"end": {
"dateTime": "2011-06-03T10:25:00.000-07:00",
"timeZone": "America/Los_Angeles"
},
"iCalUID": "eventUID",
"sequence": 0,
"attendees": [
{
"email": "attendeeEmail",
"displayName": "attendeeDisplayName",
"responseStatus": "needsAction"
},
# ...
{
"email": "userEmail",
"displayName": "userDisplayName",
"responseStatus": "accepted",
"organizer": true,
"self": true
}
],
"guestsCanInviteOthers": false,
"guestsCanSeeOtherGuests": false,
"reminders": {
"useDefault": true
}
}Java
// First retrieve the instances from the API. Events instances = service.events().instances("primary", "recurringEventId").execute(); // Select the instance to cancel. Event instance = instances.getItems().get(0); instance.setStatus("cancelled"); Event updatedInstance = service.events().update("primary", instance.getId(), instance).execute(); // Print the updated date. System.out.println(updatedInstance.getUpdated());
.NET
// First retrieve the instances from the API. Events instances = service.Events.Instances("primary", "recurringEventId").Fetch(); // Select the instance to cancel. Event instance = instances.Items[0]; instance.Status = "cancelled"; Event updatedInstance = service.Events.Update(instance, "primary", instance.Id).Fetch(); // Print the updated date. Console.WriteLine(updatedInstance.Updated);
Python
# First retrieve the instances from the API. instances = service.events().instances(calendarId='primary', eventId='recurringEventId').execute() # Select the instance to cancel. instance = instances['items'][0] instance['status'] = 'cancelled' updated_instance = service.events().update(calendarId='primary', eventId=instance['id'], body=instance).execute() # Print the updated date. print updated_instance['updated']
PHP
$events = $service->events->instances("primary", "eventId"); // Select the instance to cancel. $instance = $events->getItems()[0]; $instance->setStatus('cancelled'); $updatedInstance = $service->events->update('primary', $instance->getId(), $instance); // Print the updated date. echo $updatedInstance->getUpdated();
Ruby
# First retrieve the instances from the API. instances = client.list_event_instances('primary', 'recurringEventId') # Select the instance to cancel. instance = instances.items[0] instance.status = 'cancelled' response = client.update_event('primary', instance.id, instance) print response.updated