Acl: update

透過集合功能整理內容 你可以依據偏好儲存及分類內容。

更新存取權控管規則。立即試用查看範例

要求

HTTP 要求

PUT https://www.googleapis.com/calendar/v3/calendars/calendarId/acl/ruleId

參數

參數名稱 說明
路徑參數
calendarId string 日曆 ID。如要擷取日曆 ID,請呼叫 calendarList.list 方法。如要存取目前登入使用者的主要日曆,請使用 [primary] 關鍵字。
ruleId string ACL 規則識別碼。
選用查詢參數
sendNotifications boolean 是否要傳送日曆共用設定變更通知。請注意,移除存取權並不會收到相關通知。選用,預設值為 True。

授權

此要求需要以下範圍的授權:

範圍
https://www.googleapis.com/auth/calendar

詳情請參閱驗證和授權頁面。

要求主體

在要求內容中,請提供具有以下屬性的 Acl 資源

資源名稱 說明 Notes
必要屬性
scope object 這項 ACL 規則授予的日曆存取權範圍。
scope.type string 範圍類型。可能的值包括:
  • default」:公開範圍。這是預設值。
  • user」:將範圍限制為單一使用者。
  • group」:將範圍限制在某個群組。
  • domain」:將範圍限定在某個網域。
注意:「default」或公開範圍的權限授予任何使用者 (無論是否經過驗證)。
選填屬性
role string 指派給範圍的角色。可能的值包括:
  • none」:不提供存取權。
  • freeBusyReader」:提供有空/忙碌資訊的讀取權限。
  • reader」:提供日曆的讀取權限。具備讀取權限的使用者會看到私人活動,但系統會隱藏活動詳細資訊。
  • writer」:提供日曆的讀寫權限。具有寫入者存取權的使用者可以看到私人活動,而使用者也能看到活動詳細資訊。
  • owner」:提供日曆擁有權。這個角色具備寫入者角色的所有權限,並且具備查看和操控 ACL 的權限。
可寫入
scope.value string 使用者或群組的電子郵件地址 (或範圍名稱),視範圍類型而定。「default」類型時省略。 可寫入

回應

如果成功,此方法會在回應主體中傳回 Acl 資源

範例

注意:這個方法適用的程式語言眾多,我們只在此提供部分程式碼範例,完整的支援語言清單請參閱用戶端程式庫頁面

Java

使用 Java 用戶端程式庫

import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.AclRule;

// ...

// Initialize Calendar service with valid OAuth credentials
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials)
    .setApplicationName("applicationName").build();

// Retrieve the access rule from the API
AclRule rule = service.acl().get('primary', "ruleId").execute();

// Make a change
rule.setRole("newRole");

// Update the access rule
AclRule updatedRule = service.acl().update('primary', rule.getId(), rule).execute();
System.out.println(updatedRule.getEtag());

Python

使用 Python 用戶端程式庫

rule = service.acl().get(calendarId='primary', ruleId='ruleId').execute()
rule['role'] = 'newRole'

updated_rule = service.acl().update(calendarId='primary', ruleId=rule['id'], body=rule).execute()
print updated_rule['etag']

PHP

使用 PHP 用戶端程式庫

$rule = $service->acl->get('primary', 'ruleId');
$rule->setRole('newRole');

$updatedRule = $service->acl->update('primary', $rule->getId(), $rule);
echo $updatedRule->getEtag();

Ruby

使用 Ruby 用戶端程式庫

rule = client.get_acl('primary', 'ruleId')
rule.role = 'newRole'
result = client.update_acl('primary', rule.id, rule)
print result.etag

試試看!

使用 APIs Explorer 針對即時資料呼叫這個方法,並查看回應。