# Copyright 2024 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
# This is the plural of `ServicePerimeter`, any changes here should be made to `ServicePerimeter` as well
name: 'ServicePerimeters'
api_resource_type_kind: ServicePerimeter
description: |
  Replace all existing Service Perimeters in an Access Policy with the Service Perimeters provided. This is done atomically.
  This is a bulk edit of all Service Perimeters and may override existing Service Perimeters created by `google_access_context_manager_service_perimeter`,
  thus causing a permadiff if used alongside `google_access_context_manager_service_perimeter` on the same parent.
references:
  guides:
    'Service Perimeter Quickstart': 'https://cloud.google.com/vpc-service-controls/docs/quickstart'
    'Guide to Ingress and Egress Rules': 'https://cloud.google.com/vpc-service-controls/docs/ingress-egress-rules'
  api: 'https://cloud.google.com/access-context-manager/docs/reference/rest/v1/accessPolicies.servicePerimeters'
docs:
id_format: '{{parent}}/servicePerimeters'
base_url: '{{parent}}/servicePerimeters:replaceAll'
self_link: '{{parent}}/servicePerimeters'
update_url: '{{parent}}/servicePerimeters:replaceAll'
update_verb: 'POST'
mutex: '{{parent}}'
import_format:
  - '{{parent}}/servicePerimeters'
timeouts:
  insert_minutes: 20
  update_minutes: 20
  delete_minutes: 20
autogen_async: true
async:
  actions: ['create', 'delete', 'update']
  type: 'OpAsync'
  operation:
    base_url: '{{op_id}}'
  result:
    resource_inside_response: true
custom_code:
  custom_delete: 'templates/terraform/custom_delete/replace_all_service_perimeters_empty_list.go.tmpl'
  custom_import: 'templates/terraform/custom_import/set_access_policy_parent_from_access_policy.go.tmpl'
# Skipping the sweeper due to the non-standard base_url
exclude_sweeper: true
# Exclude tests for examples becauses tests run in parallel and will conflict when trying to create the org level access policy
examples:
  - name: 'access_context_manager_service_perimeters_basic'
    primary_resource_id: 'service-perimeter'
    vars:
      access_level_name: 'chromeos_no_lock'
      service_perimeter_name: 'restrict_storage'
    exclude_test: true
parameters:
  # Parent is a path parameter that _cannot_ be read or sent in the request at all.
  # This must be done at the provider level.
  - name: 'parent'
    type: String
    description: |
      The AccessPolicy this ServicePerimeter lives in.
      Format: accessPolicies/{policy_id}
    required: true
    immutable: true
    ignore_read: true
properties:
  - name: 'servicePerimeters'
    type: Array
    description: |
      The desired Service Perimeters that should replace all existing Service Perimeters in the Access Policy.
    custom_flatten: 'templates/terraform/custom_flatten/accesscontextmanager_serviceperimeters_custom_flatten.go.tmpl'
    item_type:
      type: NestedObject
      properties:
        - name: 'name'
          type: String
          description: |
            Resource name for the ServicePerimeter. The short_name component must
            begin with a letter and only include alphanumeric and '_'.
            Format: accessPolicies/{policy_id}/servicePerimeters/{short_name}
          required: true
          immutable: true
        - name: 'title'
          type: String
          description: |
            Human readable title. Must be unique within the Policy.
          required: true
        - name: 'description'
          type: String
          description: |
            Description of the ServicePerimeter and its use. Does not affect
            behavior.
        - name: 'createTime'
          type: Time
          description: |
            Time the AccessPolicy was created in UTC.
          output: true
        - name: 'updateTime'
          type: Time
          description: |
            Time the AccessPolicy was updated in UTC.
          output: true
        - name: 'perimeterType'
          type: Enum
          description: |
            Specifies the type of the Perimeter. There are two types: regular and
            bridge. Regular Service Perimeter contains resources, access levels,
            and restricted services. Every resource can be in at most
            ONE regular Service Perimeter.

            In addition to being in a regular service perimeter, a resource can also
            be in zero or more perimeter bridges. A perimeter bridge only contains
            resources. Cross project operations are permitted if all effected
            resources share some perimeter (whether bridge or regular). Perimeter
            Bridge does not contain access levels or services: those are governed
            entirely by the regular perimeter that resource is in.

            Perimeter Bridges are typically useful when building more complex
            topologies with many independent perimeters that need to share some data
            with a common perimeter, but should not be able to share data among
            themselves.
          immutable: true
          custom_flatten: 'templates/terraform/custom_flatten/default_if_empty.tmpl'
          default_value: "PERIMETER_TYPE_REGULAR"
          enum_values:
            - 'PERIMETER_TYPE_REGULAR'
            - 'PERIMETER_TYPE_BRIDGE'
        - name: 'status'
          type: NestedObject
          description: |
            ServicePerimeter configuration. Specifies sets of resources,
            restricted services and access levels that determine
            perimeter content and boundaries.
          properties:
            - name: 'resources'
              type: Array
              description: |
                A list of GCP resources that are inside of the service perimeter.
                Currently only projects are allowed.
                Format: projects/{project_number}
              is_set: true
              # TODO: (mbang) won't work for arrays yet, uncomment here once they are supported.
              # (github.com/hashicorp/terraform-plugin-sdk/issues/470)
              # at_least_one_of:
              #   - status.0.resources
              #   - status.0.access_levels
              #   - status.0.restricted_services
              item_type:
                type: String
            - name: 'accessLevels'
              type: Array
              description: |
                A list of AccessLevel resource names that allow resources within
                the ServicePerimeter to be accessed from the internet.
                AccessLevels listed must be in the same policy as this
                ServicePerimeter. Referencing a nonexistent AccessLevel is a
                syntax error. If no AccessLevel names are listed, resources within
                the perimeter can only be accessed via GCP calls with request
                origins within the perimeter. For Service Perimeter Bridge, must
                be empty.

                Format: accessPolicies/{policy_id}/accessLevels/{access_level_name}
              is_set: true
              # TODO: (mbang) won't work for arrays yet, uncomment here once they are supported.
              # (github.com/hashicorp/terraform-plugin-sdk/issues/470)
              # at_least_one_of:
              #   - spec.0.resources
              #   - spec.0.access_levels
              #   - spec.0.restricted_services
              item_type:
                type: String
            - name: 'restrictedServices'
              type: Array
              description: |
                GCP services that are subject to the Service Perimeter
                restrictions. Must contain a list of services. For example, if
                `storage.googleapis.com` is specified, access to the storage
                buckets inside the perimeter must meet the perimeter's access
                restrictions.
              is_set: true
              # TODO: (mbang) won't work for arrays yet, uncomment here once they are supported.
              # (github.com/hashicorp/terraform-plugin-sdk/issues/470)
              # at_least_one_of:
              #   - spec.0.resources
              #   - spec.0.access_levels
              #   - spec.0.restricted_services
              item_type:
                type: String
            - name: 'vpcAccessibleServices'
              type: NestedObject
              description: |
                Specifies how APIs are allowed to communicate within the Service
                Perimeter.
              properties:
                - name: 'enableRestriction'
                  type: Boolean
                  description: |
                    Whether to restrict API calls within the Service Perimeter to the
                    list of APIs specified in 'allowedServices'.
                - name: 'allowedServices'
                  type: Array
                  description: |
                    The list of APIs usable within the Service Perimeter.
                    Must be empty unless `enableRestriction` is True.
                  is_set: true
                  item_type:
                    type: String
            - name: 'ingressPolicies'
              type: Array
              description: |
                List of `IngressPolicies` to apply to the perimeter. A perimeter may
                have multiple `IngressPolicies`, each of which is evaluated
                separately. Access is granted if any `Ingress Policy` grants it.
                Must be empty for a perimeter bridge.
              is_set: true
              item_type:
                type: NestedObject
                properties:
                  - name: 'ingressFrom'
                    type: NestedObject
                    description: |
                      Defines the conditions on the source of a request causing this `IngressPolicy`
                      to apply.
                    properties:
                      - name: 'identityType'
                        type: Enum
                        description: |
                          Specifies the type of identities that are allowed access from outside the
                          perimeter. If left unspecified, then members of `identities` field will be
                          allowed access.
                        enum_values:
                          - 'IDENTITY_TYPE_UNSPECIFIED'
                          - 'ANY_IDENTITY'
                          - 'ANY_USER_ACCOUNT'
                          - 'ANY_SERVICE_ACCOUNT'
                      - name: 'identities'
                        type: Array
                        description: |
                          A list of identities that are allowed access through this ingress policy.
                          Should be in the format of email address. The email address should represent
                          individual user or service account only.
                        is_set: true
                        item_type:
                          type: String
                      - name: 'sources'
                        type: Array
                        description: |
                          Sources that this `IngressPolicy` authorizes access from.
                        item_type:
                          type: NestedObject
                          properties:
                            - name: 'accessLevel'
                              type: String
                              description: |
                                An `AccessLevel` resource name that allow resources within the
                                `ServicePerimeters` to be accessed from the internet. `AccessLevels` listed
                                must be in the same policy as this `ServicePerimeter`. Referencing a nonexistent
                                `AccessLevel` will cause an error. If no `AccessLevel` names are listed,
                                resources within the perimeter can only be accessed via Google Cloud calls
                                with request origins within the perimeter.
                                Example `accessPolicies/MY_POLICY/accessLevels/MY_LEVEL.`
                                If * is specified, then all IngressSources will be allowed.
                            - name: 'resource'
                              type: String
                              description: |
                                A Google Cloud resource that is allowed to ingress the perimeter.
                                Requests from these resources will be allowed to access perimeter data.
                                Currently only projects are allowed. Format `projects/{project_number}`
                                The project may be in any Google Cloud organization, not just the
                                organization that the perimeter is defined in. `*` is not allowed, the case
                                of allowing all Google Cloud resources only is not supported.
                  - name: 'ingressTo'
                    type: NestedObject
                    description: |
                      Defines the conditions on the `ApiOperation` and request destination that cause
                      this `IngressPolicy` to apply.
                    properties:
                      - name: 'resources'
                        type: Array
                        description: |
                          A list of resources, currently only projects in the form
                          `projects/<projectnumber>`, protected by this `ServicePerimeter`
                          that are allowed to be accessed by sources defined in the
                          corresponding `IngressFrom`. A request matches if it contains
                          a resource in this list. If `*` is specified for resources,
                          then this `IngressTo` rule will authorize access to all
                          resources inside the perimeter, provided that the request
                          also matches the `operations` field.
                        is_set: true
                        item_type:
                          type: String
                      - name: 'roles'
                        type: Array
                        item_type:
                          type: String
                        is_set: true
                        description: |
                          A list of IAM roles that represent the set of operations that the sources
                          specified in the corresponding `IngressFrom`
                          are allowed to perform.
                      - name: 'operations'
                        type: Array
                        description: |
                          A list of `ApiOperations` the sources specified in corresponding `IngressFrom`
                          are allowed to perform in this `ServicePerimeter`.
                        item_type:
                          type: NestedObject
                          properties:
                            - name: 'serviceName'
                              type: String
                              description: |
                                The name of the API whose methods or permissions the `IngressPolicy` or
                                `EgressPolicy` want to allow. A single `ApiOperation` with `serviceName`
                                field set to `*` will allow all methods AND permissions for all services.
                            - name: 'methodSelectors'
                              type: Array
                              description: |
                                API methods or permissions to allow. Method or permission must belong to
                                the service specified by serviceName field. A single `MethodSelector` entry
                                with `*` specified for the method field will allow all methods AND
                                permissions for the service specified in `serviceName`.
                              item_type:
                                type: NestedObject
                                properties:
                                  - name: 'method'
                                    type: String
                                    description: |
                                      Value for method should be a valid method name for the corresponding
                                      serviceName in `ApiOperation`. If `*` used as value for `method`, then
                                      ALL methods and permissions are allowed.
                                  - name: 'permission'
                                    type: String
                                    description: |
                                      Value for permission should be a valid Cloud IAM permission for the
                                      corresponding `serviceName` in `ApiOperation`.
                  - name: 'title'
                    type: 'string'
                    description: |
                      Human readable title. Must be unique within the perimeter. Does not affect behavior.
            - name: 'egressPolicies'
              type: Array
              description: |
                List of EgressPolicies to apply to the perimeter. A perimeter may
                have multiple EgressPolicies, each of which is evaluated separately.
                Access is granted if any EgressPolicy grants it. Must be empty for
                a perimeter bridge.
              item_type:
                type: NestedObject
                properties:
                  - name: 'egressFrom'
                    type: NestedObject
                    description: |
                      Defines conditions on the source of a request causing this `EgressPolicy` to apply.
                    properties:
                      - name: 'identityType'
                        type: Enum
                        description: |
                          Specifies the type of identities that are allowed access to outside the
                          perimeter. If left unspecified, then members of `identities` field will
                          be allowed access.
                        enum_values:
                          - 'IDENTITY_TYPE_UNSPECIFIED'
                          - 'ANY_IDENTITY'
                          - 'ANY_USER_ACCOUNT'
                          - 'ANY_SERVICE_ACCOUNT'
                      - name: 'identities'
                        type: Array
                        description: |
                          A list of identities that are allowed access through this `EgressPolicy`.
                          Should be in the format of email address. The email address should
                          represent individual user or service account only.
                        is_set: true
                        item_type:
                          type: String
                      - name: 'sources'
                        type: Array
                        description: 'Sources that this EgressPolicy authorizes access from.'
                        item_type:
                          type: NestedObject
                          properties:
                            - name: 'accessLevel'
                              type: String
                              description: 'An AccessLevel resource name that allows resources outside the ServicePerimeter to be accessed from the inside.'
                            - name: 'resource'
                              type: String
                              description: |
                                A Google Cloud resource that is allowed to egress the perimeter.
                                Requests from these resources are allowed to access data outside the perimeter.
                                Currently only projects are allowed. Project format: `projects/{project_number}`.
                                The resource may be in any Google Cloud organization, not just the
                                organization that the perimeter is defined in. `*` is not allowed, the
                                case of allowing all Google Cloud resources only is not supported.
                      - name: 'sourceRestriction'
                        type: Enum
                        description: 'Whether to enforce traffic restrictions based on `sources` field. If the `sources` field is non-empty, then this field must be set to `SOURCE_RESTRICTION_ENABLED`.'
                        enum_values:
                          - 'SOURCE_RESTRICTION_UNSPECIFIED'
                          - 'SOURCE_RESTRICTION_ENABLED'
                          - 'SOURCE_RESTRICTION_DISABLED'
                  - name: 'egressTo'
                    type: NestedObject
                    description: |
                      Defines the conditions on the `ApiOperation` and destination resources that
                      cause this `EgressPolicy` to apply.
                    properties:
                      - name: 'resources'
                        type: Array
                        description: |
                          A list of resources, currently only projects in the form
                          `projects/<projectnumber>`, that match this to stanza. A request matches
                          if it contains a resource in this list. If * is specified for resources,
                          then this `EgressTo` rule will authorize access to all resources outside
                          the perimeter.
                        is_set: true
                        item_type:
                          type: String
                      - name: 'externalResources'
                        type: Array
                        description: |
                          A list of external resources that are allowed to be accessed. A request
                          matches if it contains an external resource in this list (Example:
                          s3://bucket/path). Currently '*' is not allowed.
                        is_set: true
                        item_type:
                          type: String
                      - name: 'roles'
                        type: Array
                        item_type:
                          type: String
                        is_set: true
                        description: |
                          A list of IAM roles that represent the set of operations that the sources
                          specified in the corresponding `EgressFrom`
                          are allowed to perform.
                      - name: 'operations'
                        type: Array
                        description: |
                          A list of `ApiOperations` that this egress rule applies to. A request matches
                          if it contains an operation/service in this list.
                        item_type:
                          type: NestedObject
                          properties:
                            - name: 'serviceName'
                              type: String
                              description: |
                                The name of the API whose methods or permissions the `IngressPolicy` or
                                `EgressPolicy` want to allow. A single `ApiOperation` with serviceName
                                field set to `*` will allow all methods AND permissions for all services.
                            - name: 'methodSelectors'
                              type: Array
                              description: |
                                API methods or permissions to allow. Method or permission must belong
                                to the service specified by `serviceName` field. A single MethodSelector
                                entry with `*` specified for the `method` field will allow all methods
                                AND permissions for the service specified in `serviceName`.
                              item_type:
                                type: NestedObject
                                properties:
                                  - name: 'method'
                                    type: String
                                    description: |
                                      Value for `method` should be a valid method name for the corresponding
                                      `serviceName` in `ApiOperation`. If `*` used as value for method,
                                      then ALL methods and permissions are allowed.
                                  - name: 'permission'
                                    type: String
                                    description: |
                                      Value for permission should be a valid Cloud IAM permission for the
                                      corresponding `serviceName` in `ApiOperation`.
                  - name: 'title'
                    type: 'string'
                    description: |
                      Human readable title. Must be unique within the perimeter. Does not affect behavior.
        - name: 'spec'
          type: NestedObject
          description: |
            Proposed (or dry run) ServicePerimeter configuration.
            This configuration allows to specify and test ServicePerimeter configuration
            without enforcing actual access restrictions. Only allowed to be set when
            the `useExplicitDryRunSpec` flag is set.
          properties:
            - name: 'resources'
              type: Array
              description: |
                A list of GCP resources that are inside of the service perimeter.
                Currently only projects are allowed.
                Format: projects/{project_number}
              # TODO: (mbang) won't work for arrays yet, uncomment here once they are supported.
              # (github.com/hashicorp/terraform-plugin-sdk/issues/470)
              # at_least_one_of:
              #   - spec.0.resources
              #   - spec.0.access_levels
              #   - spec.0.restricted_services
              is_set: true
              item_type:
                type: String
            - name: 'accessLevels'
              type: Array
              description: |
                A list of AccessLevel resource names that allow resources within
                the ServicePerimeter to be accessed from the internet.
                AccessLevels listed must be in the same policy as this
                ServicePerimeter. Referencing a nonexistent AccessLevel is a
                syntax error. If no AccessLevel names are listed, resources within
                the perimeter can only be accessed via GCP calls with request
                origins within the perimeter. For Service Perimeter Bridge, must
                be empty.

                Format: accessPolicies/{policy_id}/accessLevels/{access_level_name}
              is_set: true
              item_type:
                type: String
            - name: 'restrictedServices'
              type: Array
              description: |
                GCP services that are subject to the Service Perimeter
                restrictions. Must contain a list of services. For example, if
                `storage.googleapis.com` is specified, access to the storage
                buckets inside the perimeter must meet the perimeter's access
                restrictions.
              is_set: true
              item_type:
                type: String
            - name: 'vpcAccessibleServices'
              type: NestedObject
              description: |
                Specifies how APIs are allowed to communicate within the Service
                Perimeter.
              properties:
                - name: 'enableRestriction'
                  type: Boolean
                  description: |
                    Whether to restrict API calls within the Service Perimeter to the
                    list of APIs specified in 'allowedServices'.
                - name: 'allowedServices'
                  type: Array
                  description: |
                    The list of APIs usable within the Service Perimeter.
                    Must be empty unless `enableRestriction` is True.
                  is_set: true
                  item_type:
                    type: String
            - name: 'ingressPolicies'
              type: Array
              description: |
                List of `IngressPolicies` to apply to the perimeter. A perimeter may
                have multiple `IngressPolicies`, each of which is evaluated
                separately. Access is granted if any `Ingress Policy` grants it.
                Must be empty for a perimeter bridge.
              item_type:
                type: NestedObject
                properties:
                  - name: 'ingressFrom'
                    type: NestedObject
                    description: |
                      Defines the conditions on the source of a request causing this `IngressPolicy`
                      to apply.
                    properties:
                      - name: 'identityType'
                        type: Enum
                        description: |
                          Specifies the type of identities that are allowed access from outside the
                          perimeter. If left unspecified, then members of `identities` field will be
                          allowed access.
                        enum_values:
                          - 'IDENTITY_TYPE_UNSPECIFIED'
                          - 'ANY_IDENTITY'
                          - 'ANY_USER_ACCOUNT'
                          - 'ANY_SERVICE_ACCOUNT'
                      - name: 'identities'
                        type: Array
                        description: |
                          A list of identities that are allowed access through this ingress policy.
                          Should be in the format of email address. The email address should represent
                          individual user or service account only.
                        is_set: true
                        item_type:
                          type: String
                      - name: 'sources'
                        type: Array
                        description: |
                          Sources that this `IngressPolicy` authorizes access from.
                        item_type:
                          type: NestedObject
                          properties:
                            - name: 'accessLevel'
                              type: String
                              description: |
                                An `AccessLevel` resource name that allow resources within the
                                `ServicePerimeters` to be accessed from the internet. `AccessLevels` listed
                                must be in the same policy as this `ServicePerimeter`. Referencing a nonexistent
                                `AccessLevel` will cause an error. If no `AccessLevel` names are listed,
                                resources within the perimeter can only be accessed via Google Cloud calls
                                with request origins within the perimeter.
                                Example `accessPolicies/MY_POLICY/accessLevels/MY_LEVEL.`
                                If * is specified, then all IngressSources will be allowed.
                            - name: 'resource'
                              type: String
                              description: |
                                A Google Cloud resource that is allowed to ingress the perimeter.
                                Requests from these resources will be allowed to access perimeter data.
                                Currently only projects are allowed. Format `projects/{project_number}`
                                The project may be in any Google Cloud organization, not just the
                                organization that the perimeter is defined in. `*` is not allowed, the case
                                of allowing all Google Cloud resources only is not supported.
                  - name: 'ingressTo'
                    type: NestedObject
                    description: |
                      Defines the conditions on the `ApiOperation` and request destination that cause
                      this `IngressPolicy` to apply.
                    properties:
                      - name: 'resources'
                        type: Array
                        description: |
                          A list of resources, currently only projects in the form
                          `projects/<projectnumber>`, protected by this `ServicePerimeter`
                          that are allowed to be accessed by sources defined in the
                          corresponding `IngressFrom`. A request matches if it contains
                          a resource in this list. If `*` is specified for resources,
                          then this `IngressTo` rule will authorize access to all
                          resources inside the perimeter, provided that the request
                          also matches the `operations` field.
                        is_set: true
                        item_type:
                          type: String
                      - name: 'roles'
                        type: Array
                        item_type:
                          type: String
                        is_set: true
                        description: |
                          A list of IAM roles that represent the set of operations that the sources
                          specified in the corresponding `IngressFrom`
                          are allowed to perform.
                      - name: 'operations'
                        type: Array
                        description: |
                          A list of `ApiOperations` the sources specified in corresponding `IngressFrom`
                          are allowed to perform in this `ServicePerimeter`.
                        item_type:
                          type: NestedObject
                          properties:
                            - name: 'serviceName'
                              type: String
                              description: |
                                The name of the API whose methods or permissions the `IngressPolicy` or
                                `EgressPolicy` want to allow. A single `ApiOperation` with `serviceName`
                                field set to `*` will allow all methods AND permissions for all services.
                            - name: 'methodSelectors'
                              type: Array
                              description: |
                                API methods or permissions to allow. Method or permission must belong to
                                the service specified by serviceName field. A single `MethodSelector` entry
                                with `*` specified for the method field will allow all methods AND
                                permissions for the service specified in `serviceName`.
                              item_type:
                                type: NestedObject
                                properties:
                                  - name: 'method'
                                    type: String
                                    description: |
                                      Value for method should be a valid method name for the corresponding
                                      serviceName in `ApiOperation`. If `*` used as value for `method`, then
                                      ALL methods and permissions are allowed.
                                  - name: 'permission'
                                    type: String
                                    description: |
                                      Value for permission should be a valid Cloud IAM permission for the
                                      corresponding `serviceName` in `ApiOperation`.
                  - name: 'title'
                    type: 'string'
                    description: |
                      Human readable title. Must be unique within the perimeter. Does not affect behavior.
            - name: 'egressPolicies'
              type: Array
              description: |
                List of EgressPolicies to apply to the perimeter. A perimeter may
                have multiple EgressPolicies, each of which is evaluated separately.
                Access is granted if any EgressPolicy grants it. Must be empty for
                a perimeter bridge.
              item_type:
                type: NestedObject
                properties:
                  - name: 'egressFrom'
                    type: NestedObject
                    description: |
                      Defines conditions on the source of a request causing this `EgressPolicy` to apply.
                    properties:
                      - name: 'identityType'
                        type: Enum
                        description: |
                          Specifies the type of identities that are allowed access to outside the
                          perimeter. If left unspecified, then members of `identities` field will
                          be allowed access.
                        enum_values:
                          - 'IDENTITY_TYPE_UNSPECIFIED'
                          - 'ANY_IDENTITY'
                          - 'ANY_USER_ACCOUNT'
                          - 'ANY_SERVICE_ACCOUNT'
                      - name: 'identities'
                        type: Array
                        description: |
                          Identities can be an individual user, service account, Google group,
                          or third-party identity. For third-party identity, only single identities
                          are supported and other identity types are not supported.The v1 identities
                          that have the prefix user, group and serviceAccount in
                          https://cloud.google.com/iam/docs/principal-identifiers#v1 are supported.
                        is_set: true
                        item_type:
                          type: String
                      - name: 'sources'
                        type: Array
                        description: 'Sources that this EgressPolicy authorizes access from.'
                        item_type:
                          type: NestedObject
                          properties:
                            - name: 'accessLevel'
                              type: String
                              description: 'An AccessLevel resource name that allows resources outside the ServicePerimeter to be accessed from the inside.'
                            - name: 'resource'
                              type: String
                              description: |
                                A Google Cloud resource that is allowed to egress the perimeter.
                                Requests from these resources are allowed to access data outside the perimeter.
                                Currently only projects are allowed. Project format: `projects/{project_number}`.
                                The resource may be in any Google Cloud organization, not just the
                                organization that the perimeter is defined in. `*` is not allowed, the
                                case of allowing all Google Cloud resources only is not supported.
                      - name: 'sourceRestriction'
                        type: Enum
                        description: 'Whether to enforce traffic restrictions based on `sources` field. If the `sources` field is non-empty, then this field must be set to `SOURCE_RESTRICTION_ENABLED`.'
                        enum_values:
                          - 'SOURCE_RESTRICTION_UNSPECIFIED'
                          - 'SOURCE_RESTRICTION_ENABLED'
                          - 'SOURCE_RESTRICTION_DISABLED'
                  - name: 'egressTo'
                    type: NestedObject
                    description: |
                      Defines the conditions on the `ApiOperation` and destination resources that
                      cause this `EgressPolicy` to apply.
                    properties:
                      - name: 'resources'
                        type: Array
                        description: |
                          A list of resources, currently only projects in the form
                          `projects/<projectnumber>`, that match this to stanza. A request matches
                          if it contains a resource in this list. If * is specified for resources,
                          then this `EgressTo` rule will authorize access to all resources outside
                          the perimeter.
                        is_set: true
                        item_type:
                          type: String
                      - name: 'externalResources'
                        type: Array
                        description: |
                          A list of external resources that are allowed to be accessed. A request
                          matches if it contains an external resource in this list (Example:
                          s3://bucket/path). Currently '*' is not allowed.
                        is_set: true
                        item_type:
                          type: String
                      - name: 'roles'
                        type: Array
                        item_type:
                          type: String
                        is_set: true
                        description: |
                          A list of IAM roles that represent the set of operations that the sources
                          specified in the corresponding `EgressFrom`
                          are allowed to perform.
                      - name: 'operations'
                        type: Array
                        description: |
                          A list of `ApiOperations` that this egress rule applies to. A request matches
                          if it contains an operation/service in this list.
                        item_type:
                          type: NestedObject
                          properties:
                            - name: 'serviceName'
                              type: String
                              description: |
                                The name of the API whose methods or permissions the `IngressPolicy` or
                                `EgressPolicy` want to allow. A single `ApiOperation` with serviceName
                                field set to `*` will allow all methods AND permissions for all services.
                            - name: 'methodSelectors'
                              type: Array
                              description: |
                                API methods or permissions to allow. Method or permission must belong
                                to the service specified by `serviceName` field. A single MethodSelector
                                entry with `*` specified for the `method` field will allow all methods
                                AND permissions for the service specified in `serviceName`.
                              item_type:
                                type: NestedObject
                                properties:
                                  - name: 'method'
                                    type: String
                                    description: |
                                      Value for `method` should be a valid method name for the corresponding
                                      `serviceName` in `ApiOperation`. If `*` used as value for method,
                                      then ALL methods and permissions are allowed.
                                  - name: 'permission'
                                    type: String
                                    description: |
                                      Value for permission should be a valid Cloud IAM permission for the
                                      corresponding `serviceName` in `ApiOperation`.
                  - name: 'title'
                    type: 'string'
                    description: |
                      Human readable title. Must be unique within the perimeter. Does not affect behavior.
        - name: 'useExplicitDryRunSpec'
          type: Boolean
          description: |
            Use explicit dry run spec flag. Ordinarily, a dry-run spec implicitly exists
            for all Service Perimeters, and that spec is identical to the status for those
            Service Perimeters. When this flag is set, it inhibits the generation of the
            implicit spec, thereby allowing the user to explicitly provide a
            configuration ("spec") to use in a dry-run version of the Service Perimeter.
            This allows the user to test changes to the enforced config ("status") without
            actually enforcing them. This testing is done through analyzing the differences
            between currently enforced and suggested restrictions. useExplicitDryRunSpec must
            bet set to True if any of the fields in the spec are set to non-default values.
