Permissions: update

Wymaga autoryzacji

Aktualizuje uprawnienia użytkownika do konta i kontenera. Wypróbuj lub zobacz przykład.

Prośba

Żądanie HTTP

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

Parametry

Nazwa parametru Wartość Opis
Parametry ścieżki
accountId string Identyfikator konta Menedżera tagów Google.
permissionId string Identyfikator użytkownika Menedżera tagów Google.

Upoważnienie

To żądanie wymaga autoryzacji z tym zakresem (więcej informacji o uwierzytelnianiu i autoryzacji).

Zakres
https://www.googleapis.com/auth/tagmanager.manage.users

Treść żądania

W treści żądania podaj zasób uprawnień z tymi właściwościami:

nazwa usługi, Wartość Opis Uwagi
Właściwości opcjonalne
accountAccess nested object Uprawnienia dostępu do konta Menedżera tagów Google. z możliwością zapisu
accountAccess.permission[] list Lista uprawnień dotyczących konta. Prawidłowe uprawnienia konta to read i manage. z możliwością zapisu
containerAccess[] list Uprawnienia dostępu do kontenera Menedżera tagów Google. z możliwością zapisu
containerAccess[].containerId string Identyfikator kontenera Menedżera tagów Google. z możliwością zapisu
containerAccess[].permission[] list Lista uprawnień dotyczących kontenerów. Prawidłowe uprawnienia kontenera to: read, edit, delete, publish. z możliwością zapisu

Odpowiedź

Jeśli operacja się uda, metoda zwróci w treści odpowiedzi zasób uprawnień.

Przykłady

Uwaga: dostępne dla tej metody przykłady kodu nie odzwierciedlają wszystkich obsługiwanych języków programowania. Listę obsługiwanych języków znajdziesz na stronie z bibliotekami klienta.

Java

Korzysta z biblioteki klienta 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

Używa biblioteki klienta dla języka 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')

Wypróbuj

Użyj Eksploratora interfejsów API poniżej, aby wywołać tę metodę na aktywnych danych i zobaczyć odpowiedź.