Patches a ServiceAccount
.
HTTP request
PATCH https://iam.googleapis.com/v1/{serviceAccount.name=projects/*/serviceAccounts/*}
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
service |
The resource name of the service account. Use one of the following formats:
As an alternative, you can use the
When possible, avoid using the |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "serviceAccount": { "name": string, "projectId": string, "uniqueId": string, "email": string, "displayName": string, "etag": string, "description": string, "oauth2ClientId": string, "disabled": boolean }, "updateMask": string } |
Fields | |
---|---|
service |
Output only. The ID of the project that owns the service account. |
service |
Output only. The unique, stable numeric ID for the service account. Each service account retains its unique ID even if you delete the service account. For example, if you delete a service account, then create a new service account with the same name, the new service account has a different unique ID than the deleted service account. |
service |
Output only. The email address of the service account. |
service |
Optional. A user-specified, human-readable name for the service account. The maximum length is 100 UTF-8 bytes. |
serviceAccount.etag |
Deprecated. Do not use. A base64-encoded string. |
service |
Optional. A user-specified, human-readable description of the service account. The maximum length is 256 UTF-8 bytes. |
service |
Output only. The OAuth 2.0 client ID for the service account. |
service |
Output only. Whether the service account is disabled. |
update |
This is a comma-separated list of fully qualified names of fields. Example: |
Response body
If successful, the response body contains an instance of ServiceAccount
.
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/iam
https://www.googleapis.com/auth/cloud-platform
For more information, see the Authentication Overview.
Uses the Node.js client library.Examples
// BEFORE RUNNING:
// ---------------
// 1. If not already done, enable the Identity and Access Management (IAM) API
// and check the quota for your project at
// https://console.developers.google.com/apis/api/iam
// 2. This sample uses Application Default Credentials for authentication.
// If not already done, install the gcloud CLI from
// https://cloud.google.com/sdk and run
// `gcloud beta auth application-default login`.
// For more information, see
// https://developers.google.com/identity/protocols/application-default-credentials
// 3. Install the Node.js client library by running
// `npm install googleapis --save`
const {google} = require('googleapis');
const iam = google.iam('v1');
async function main () {
const authClient = await authorize();
const request = {
// The resource name of the service account in the following format:
// `projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}`.
// Requests using `-` as a wildcard for the `PROJECT_ID` will infer the
// project from the `account` and the `ACCOUNT` value can be the `email`
// address or the `unique_id` of the service account.
// In responses the resource name will always be in the format
// `projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}`.
name: 'projects/my-project/serviceAccounts/my-service-account', // TODO: Update placeholder value.
resource: {
// TODO: Add desired properties to the request body. Only these properties
// will be changed.
},
auth: authClient,
};
try {
const response = (await iam.projects.serviceAccounts.patch(request)).data;
// TODO: Change code below to process the `response` object:
console.log(JSON.stringify(response, null, 2));
} catch (err) {
console.error(err);
}
}
main();
async function authorize() {
const auth = new google.auth.GoogleAuth({
scopes: ['https://www.googleapis.com/auth/cloud-platform']
});
return await auth.getClient();
}