Permissions: update

נדרשת הרשאה

עדכון של חשבון המשתמש ושל ההרשאות למאגר התגים. אפשר לנסות עכשיו או לראות דוגמה.

בקשה

בקשת HTTP

PUT https://www.googleapis.com/tagmanager/v1/accounts/accountId/permissions/permissionId

פרמטרים

שם הפרמטר Value התיאור
פרמטרים של נתיב
accountId string מספר החשבון ב-GTM.
permissionId string מזהה המשתמש ב-GTM.

הרשאות

בקשה זו מחייבת הרשאה בהיקף הבא (למידע נוסף על אימות והרשאה).

היקף
https://www.googleapis.com/auth/tagmanager.manage.users

גוף הבקשה

בגוף הבקשה, מספקים משאב הרשאות עם המאפיינים הבאים:

שם הנכס Value התיאור הערות
מאפיינים אופציונליים
accountAccess nested object הרשאות הגישה לחשבון GTM. ניתן לכתיבה
accountAccess.permission[] list רשימת הרשאות החשבון. הרשאות החשבון החוקיות הן read וmanage. ניתן לכתיבה
containerAccess[] list הרשאות גישה לקונטיינר ב-GTM. ניתן לכתיבה
containerAccess[].containerId string מזהה מאגר תגים של GTM. ניתן לכתיבה
containerAccess[].permission[] list רשימת הרשאות בקונטיינר. ההרשאות החוקיות למאגר הן: read, edit, delete, publish. ניתן לכתיבה

תשובה

אם הפעולה בוצעה ללא שגיאות, השיטה הזו מחזירה משאב של הרשאות בגוף התגובה.

דוגמאות

הערה: דוגמאות הקוד הזמינות לשיטה זו לא מייצגות את כל שפות התכנות הנתמכות (רשימת השפות הנתמכות זמינה בדף של ספריות המשתמשים).

Java

משתמש בספריית הלקוח של Java.

/*
 * Note: This code assumes you have an authorized tagmanager service object.
 */

/*
 * This request updates a user's permissions to access a GTM account.
 */

// Construct the container access object.
ContainerAccess container = new ContainerAccess();
container.setContainerId("789443");
container.setPermission(Arrays.asList("read"));

// Construct the account access object.
AccountAccess account = new AccountAccess();
account.setPermission(Arrays.asList("read"));

// Construct the user access object.
UserAccess userAccess = new UserAccess();
userAccess.setEmailAddress("username@example.com");
userAccess.setAccountAccess(account);
userAccess.setContainerAccess(Arrays.asList(container));

try {
  UserAccess response = tagmanager.accounts().
      permissions().update("123456", "00123456789", userAccess).execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}

/*
 * The results of the update method are stored in the response object.
 * The following code shows how to access the updated name and fingerprint.
 */
System.out.println("Updated Name = " + response.getName());
System.out.println("Updated Fingerprint = " + response.getFingerprint());

Python

עושה שימוש בספריית הלקוח של Python.

# Note: This code assumes you have an authorized tagmanager service object.

# This request updates a user's permissions to access a GTM account.
try:
  response = tagmanager.accounts().permissions().update(
      accountId='123456',
      permissionId='00123456789',
      body={
          'emailAddress': 'username@example.com',
          'accountAccess': {
              'permission': [
                  'read'
              ]
          },
          'containerAccess': {
              'containerId': '54321',
              'permission': [
                  'read'
              ]
          }
      }
  ).execute()
except TypeError, error:
  # Handle errors in constructing a query.
  print 'There was an error in constructing your query : %s' % error

except HttpError, error:
  # Handle API errors.
  print ('There was an API error : %s : %s' %
         (error.resp.status, error.resp.reason))

# The results of the update method are stored in the response object.
# The following code shows how to access the updated name and fingerprint.
print 'Updated Name = %s' % response.get('name')
print 'Updated Fingerprint = %s' % response.get('fingerprint')

רוצה לנסות?

ניתן להשתמש ב-APIs Explorer שבהמשך כדי לקרוא לשיטה הזו בנתונים בזמן אמת ולראות את התגובה.