Organízate con las colecciones
Guarda y clasifica el contenido según tus preferencias.
Puede definir u obtener la política de Gestión de Identidades y Accesos (IAM) o de control de acceso de una o varias pruebas de conectividad. Además, puede ver los permisos que tiene un usuario o una cuenta de servicio para una prueba de conectividad específica.
En este documento se muestran ejemplos de control de acceso que usan la API Network Management.
Para seguir estos pasos en la consola Google Cloud o mediante comandos de gcloud, consulta las guías prácticas de gestión de identidades y accesos.
Para obtener información sobre los roles y permisos de gestión de identidades y accesos necesarios para ejecutar pruebas de conectividad, consulta Roles y permisos.
Definir una política de control de acceso
Este procedimiento define la política de control de acceso en el recurso Connectivity Tests especificado.
TEST_ID: el ID del objeto Connectivity Tests (prueba) que estás ejecutando
VERSION: especifica el formato de la política. Los valores válidos son 0, 1 y 3. Cualquier operación que afecte a las vinculaciones de roles condicionales debe especificar la versión 3.
ETAG: se usa para el control de concurrencia optimista como una forma de evitar que las actualizaciones simultáneas de una política se sobrescriban entre sí (un ejemplo de etag es BwWbrqiZFRs=).
ROLE: un rol asignado a principales
(por ejemplo, roles/networkmanagement.admin)
TEST_ID: el ID del objeto Connectivity Tests (prueba) que estás ejecutando
VERSION: especifica el formato de la política. Los valores válidos son 0, 1 y 3. Cualquier operación que afecte a las vinculaciones de roles condicionales debe especificar la versión 3.
ETAG: se usa para el control de concurrencia optimista
como forma de evitar que las actualizaciones simultáneas de una política se sobrescriban
entre sí (un ejemplo de etag es BwWbrqiZFRs=).
ROLE: un rol asignado a principales (por ejemplo, roles/networkmanagement.admin)
[[["Es fácil de entender","easyToUnderstand","thumb-up"],["Me ofreció una solución al problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Es difícil de entender","hardToUnderstand","thumb-down"],["La información o el código de muestra no son correctos","incorrectInformationOrSampleCode","thumb-down"],["Me faltan las muestras o la información que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-21 (UTC)."],[],[],null,["# Manage access policies\n\nYou can set or get the Identity and Access Management (IAM), or access control, policy for\none or more Connectivity Tests. In addition, you can view the\npermissions that a user or service account has for a specific\nConnectivity Test.\n\nThis document shows access control examples that use the Network Management API.\nTo follow these steps in the Google Cloud console or by using `gcloud` commands,\nsee the [IAM how-to guides](/iam/docs/how-to).\n\nFor information about policy bindings and etags listed in the following commands,\nsee the [API reference for IAM policies](/iam/docs/reference/rest/v1/Policy).\n\nFor information about the IAM roles and permissions needed to run\nConnectivity Tests, see\n[Roles and permissions](/network-intelligence-center/docs/connectivity-tests/concepts/access-control).\n\nSet an access control policy\n----------------------------\n\nThis procedure sets the access control policy on the specified\nConnectivity Tests resource. \n\n### API\n\nUse the [`networkmanagement.connectivitytests.setIamPolicy`](/network-intelligence-center/docs/connectivity-tests/reference/networkmanagement/rest/v1/projects.locations.global.connectivityTests/setIamPolicy)\nmethod to set the access control policy for a \u003cvar translate=\"no\"\u003eUSER\u003c/var\u003e,\n\u003cvar translate=\"no\"\u003eROLE\u003c/var\u003e, and \u003cvar translate=\"no\"\u003eTEST_ID\u003c/var\u003e.\n\nThe following example sets a policy that binds the role of\n`networkmanagement.admin` to `username@yourcompany.com` for `mytest-1`. \n\n```\n POST https: //networkmanagement.googleapis.com/v1/{resource=projects/*/locations/global/connectivityTests/TEST_ID}:setIamPolicy\n {\n \"version\": \"VERSION\",\n \"etag\": \"ETAG\",\n \"bindings\": [{\n \"role\": \"ROLE\",\n \"members\": [\n \"PRINCIPAL\"\n ]\n }]\n }\n```\n\nReplace the following values:\n\n- \u003cvar translate=\"no\"\u003eTEST_ID\u003c/var\u003e: the ID of the Connectivity Tests object (test) that you are running\n- \u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e: specifies the format of the policy; valid values are `0`, `1`, and `3`---any operation that affects conditional role bindings must specify version `3`\n- \u003cvar translate=\"no\"\u003eETAG\u003c/var\u003e: used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other (an example etag is `BwWbrqiZFRs=`)\n- \u003cvar translate=\"no\"\u003eROLE\u003c/var\u003e: a role that is assigned to principals (for example, `roles/networkmanagement.admin`)\n- \u003cvar translate=\"no\"\u003ePRINCIPAL\u003c/var\u003e: specifies the identities requesting access for a Google Cloud resource (for example, `user:username@yourcompany.com`); for a list of principal, or member, types, see the [API reference for IAM policies](/iam/docs/reference/rest/v1/Policy)\n\nGet an access control policy\n----------------------------\n\nThis procedure gets the access control policy for the specified\nConnectivity Tests resource. \n\n### API\n\nUse the [`networkmanagement.connectivitytests.getIamPolicy`](/network-intelligence-center/docs/connectivity-tests/reference/networkmanagement/rest/v1/projects.locations.global.connectivityTests/getIamPolicy)\nmethod to set the access control policy for a \u003cvar translate=\"no\"\u003ePRINCIPAL\u003c/var\u003e,\n\u003cvar translate=\"no\"\u003eROLE\u003c/var\u003e, and \u003cvar translate=\"no\"\u003eTEST_ID\u003c/var\u003e.\n\nThe following example gets a policy that binds the role of\n`networkmanagement.admin` to `username@yourcompany.com` for `mytest-1`. \n\n```\n GET https: //networkmanagement.googleapis.com/v1/{resource=projects/*/locations/global/connectivityTests/TEST_ID}:getIamPolicy\n {\n \"version\": \"VERSION\",\n \"etag\": \"ETAG\",\n \"bindings\": [{\n \"role\": \"ROLE\",\n \"members\": [\n \"PRINCIPAL\"\n ]\n }]\n }\n```\n\nReplace the following values:\n\n- \u003cvar translate=\"no\"\u003eTEST_ID\u003c/var\u003e: the ID of the Connectivity Tests object (test) that you are running\n- \u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e: specifies the format of the policy; valid values are `0`, `1`, and `3`---any operation that affects conditional role bindings must specify version `3`\n- \u003cvar translate=\"no\"\u003eETAG\u003c/var\u003e: used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other (an example etag is `BwWbrqiZFRs=`)\n- \u003cvar translate=\"no\"\u003eROLE\u003c/var\u003e: a role that is assigned to principals (for example, `roles/networkmanagement.admin`)\n- \u003cvar translate=\"no\"\u003ePRINCIPAL\u003c/var\u003e: specifies the identities requesting access for a Google Cloud resource (for example, `user:username@yourcompany.com`); for a list of principal types, see the [API reference for IAM policies](/iam/docs/reference/rest/v1/Policy)\n\nTest IAM permissions\n--------------------\n\nThis procedure returns permissions that a user or service account has for a\nConnectivity Tests resource. \n\n### API\n\nUse the [`networkmanagement.connectivitytests.testIamPermissions`](/network-intelligence-center/docs/connectivity-tests/reference/networkmanagement/rest/v1/projects.locations.global.connectivityTests/testIamPermissions)\nmethod to return the permissions assigned to a \u003cvar translate=\"no\"\u003eTEST_ID\u003c/var\u003e.\n\nThe following example verifies that `username@yourcompany.com` has the\n`networkmanagement.connectivitytests.get` permission for `mytest-1`. \n\n```\n POST https://networkmanagement.googleapis.com/v1/{resource=projects/*/locations/global/connectivityTests/TEST_ID}:testIamPermissions\n {\n \"permissions\": [\n \"networkmanagement.connectivitytests.get\"\n ]\n }\n```\n\nReplace \u003cvar translate=\"no\"\u003eTEST_ID\u003c/var\u003e with the ID of the\nConnectivity Tests object (test) that you are running.\n\nWhat's next\n-----------\n\n- [Learn about Connectivity Tests](/network-intelligence-center/docs/connectivity-tests/concepts/overview)\n- [Troubleshoot Connectivity Tests](/network-intelligence-center/docs/connectivity-tests/support/troubleshooting)"]]