# Method: services.roles.add

- [HTTP request](https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.roles/add#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.roles/add#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.roles/add#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.roles/add#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.roles/add#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.roles/add#body.aspect)
- [PolicyBinding](https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.roles/add#PolicyBinding)
  - [JSON representation](https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.roles/add#PolicyBinding.SCHEMA_REPRESENTATION)
- [Try it!](https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.roles/add#try-it)

Service producers can use this method to add roles in the shared VPC host project. Each role is bound to the provided member. Each role must be selected from within an allowlisted set of roles. Each role is applied at only the granularity specified in the allowlist.

### HTTP request

`POST https://servicenetworking.googleapis.com/v1/{parent=services/*}/roles:add`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. This is in a form services/{service} where {service} is the name of the private access management service. For example 'service-peering.example.com'. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `parent`: - `servicenetworking.services.addSubnetwork` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "consumerNetwork": string, "policyBinding": [ { object (`https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.roles/add#PolicyBinding`) } ] } ``` |

| Fields ||
|---|---|
| `consumerNetwork` | `string` Required. The network that the consumer is using to connect with services. Must be in the form of projects/{project}/global/networks/{network} {project} is a project number, as in '12345' {network} is a network name. |
| `policyBinding[]` | ``object (`https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.roles/add#PolicyBinding`)`` Required. List of policy bindings to add to shared VPC host project. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/operations#Operation`.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/service.management`
- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).

## PolicyBinding

Grouping of IAM role and IAM member.

| JSON representation |
|---|
| ``` { "role": string, "member": string } ``` |

| Fields ||
|---|---|
| `role` | `string` Required. Role to apply. Only allowlisted roles can be used at the specified granularity. The role must be one of the following: - 'roles/container.hostServiceAgentUser' applied on the shared VPC host project - 'roles/compute.securityAdmin' applied on the shared VPC host project - 'roles/compute.networkAdmin' applied on the shared VPC host project - 'roles/tpu.xpnAgent' applied on the shared VPC host project - 'roles/dns.admin' applied on the shared VPC host project - 'roles/logging.admin' applied on the shared VPC host project - 'roles/monitoring.viewer' applied on the shared VPC host project - 'roles/servicemanagement.quotaViewer' applied on the shared VPC host project |
| `member` | `string` Required. Member to bind the role with. See [IAM policy bindings](https://docs.cloud.google.com/iam/docs/reference/rest/v1/Policy#Binding) for how to format each member. Eg. - user:[myuser@mydomain.com](mailto:myuser@mydomain.com) - serviceAccount:[my-service-account@app.gserviceaccount.com](mailto:my-service-account@app.gserviceaccount.com) |