Permissions: update

Memerlukan otorisasi

Memperbarui izin akun & penampung pengguna. Coba sekarang atau lihat contohnya.

Permintaan

Permintaan HTTP

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

Parameter

Nama parameter Nilai Deskripsi
Parameter jalur
accountId string ID Akun GTM.
permissionId string ID Pengguna GTM.

Otorisasi

Permintaan ini memerlukan otorisasi dengan cakupan berikut (baca selengkapnya tentang autentikasi dan otorisasi).

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

Isi permintaan

Dalam isi permintaan, berikan resource Izin dengan properti berikut:

Nama properti Nilai Deskripsi Catatan
Properti Opsional
accountAccess nested object Izin akses Akun GTM. dapat ditulis
accountAccess.permission[] list Daftar izin Akun. Izin akun yang valid adalah read dan manage. dapat ditulis
containerAccess[] list Izin akses Penampung GTM. dapat ditulis
containerAccess[].containerId string ID Penampung GTM. dapat ditulis
containerAccess[].permission[] list Daftar izin Penampung. Izin penampung yang valid adalah: read, edit, delete, publish. dapat ditulis

Respons

Jika berhasil, metode ini akan menampilkan resource Izin dalam isi respons.

Contoh

Catatan: Contoh kode yang tersedia untuk metode ini tidak merepresentasikan semua bahasa pemrograman yang didukung (lihat halaman library klien untuk mengetahui daftar bahasa yang didukung).

Java

Menggunakan library klien 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

Menggunakan library klien 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')

Cobalah!

Gunakan APIs Explorer di bawah untuk memanggil metode ini pada data live dan melihat respons.