{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/google-workspace/json-schema/google-workspace-membership-schema.json",
  "title": "Membership",
  "description": "A membership within the Cloud Identity Groups API. A `Membership` defines a relationship between a `Group` and an entity belonging to that `Group`, referred to as a \"member\".",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/google-workspace-cloudidentity-groups-api-openapi.yml#/components/schemas/Membership",
  "type": "object",
  "properties": {
    "name": {
      "description": "Output only. The [resource name](https://cloud.google.com/apis/design/resource_names) of the `Membership`. Shall be of the form `groups/{group}/memberships/{membership}`.",
      "readOnly": true,
      "type": "string"
    },
    "type": {
      "type": "string",
      "readOnly": true,
      "description": "Output only. The type of the membership.",
      "enum": [
        "TYPE_UNSPECIFIED",
        "USER",
        "SERVICE_ACCOUNT",
        "GROUP",
        "SHARED_DRIVE",
        "CBCM_BROWSER",
        "CHROME_OS_DEVICE",
        "PERSONAL_AGENT",
        "COWORKER_AGENT",
        "OTHER"
      ]
    },
    "roles": {
      "description": "The `MembershipRole`s that apply to the `Membership`. If unspecified, defaults to a single `MembershipRole` with `name` `MEMBER`. Must not contain duplicate `MembershipRole`s with the same `name`.",
      "items": {
        "$ref": "#/$defs/MembershipRole"
      },
      "type": "array"
    },
    "createTime": {
      "description": "Output only. The time when the `Membership` was created.",
      "readOnly": true,
      "format": "google-datetime",
      "type": "string"
    },
    "preferredMemberKey": {
      "$ref": "#/$defs/EntityKey",
      "description": "Required. Immutable. The `EntityKey` of the member."
    },
    "deliverySetting": {
      "type": "string",
      "description": "Output only. Delivery setting associated with the membership.",
      "readOnly": true,
      "enum": [
        "DELIVERY_SETTING_UNSPECIFIED",
        "ALL_MAIL",
        "DIGEST",
        "DAILY",
        "NONE",
        "DISABLED"
      ]
    },
    "updateTime": {
      "format": "google-datetime",
      "type": "string",
      "description": "Output only. The time when the `Membership` was last updated.",
      "readOnly": true
    }
  },
  "$defs": {
    "EntityKey": {
      "properties": {
        "id": {
          "type": "string",
          "description": "The ID of the entity. For Google-managed entities, the `id` should be the email address of an existing group or user. Email addresses need to adhere to [name guidelines for users and groups](https://support.google.com/a/answer/9193374). For external-identity-mapped entities, the `id` must be a string conforming to the Identity Source's requirements. Must be unique within a `namespace`."
        },
        "namespace": {
          "description": "The namespace in which the entity exists. If not specified, the `EntityKey` represents a Google-managed entity such as a Google user or a Google Group. If specified, the `EntityKey` represents an external-identity-mapped group. The namespace must correspond to an identity source created in Admin Console and must be in the form of `identitysources/{identity_source}`.",
          "type": "string"
        }
      },
      "description": "A unique identifier for an entity in the Cloud Identity Groups API. An entity can represent either a group with an optional `namespace` or a user without a `namespace`. The combination of `id` and `namespace` must be unique; however, the same `id` can be used with different `namespace`s.",
      "type": "object"
    },
    "ExpiryDetail": {
      "description": "The `MembershipRole` expiry details.",
      "type": "object",
      "properties": {
        "expireTime": {
          "format": "google-datetime",
          "type": "string",
          "description": "The time at which the `MembershipRole` will expire."
        }
      }
    },
    "MembershipRole": {
      "type": "object",
      "properties": {
        "name": {
          "description": "The name of the `MembershipRole`. Must be one of `OWNER`, `MANAGER`, `MEMBER`.",
          "type": "string"
        },
        "expiryDetail": {
          "$ref": "#/$defs/ExpiryDetail",
          "description": "The expiry details of the `MembershipRole`. Expiry details are only supported for `MEMBER` `MembershipRoles`. May be set if `name` is `MEMBER`. Must not be set if `name` is any other value."
        },
        "restrictionEvaluations": {
          "$ref": "#/$defs/RestrictionEvaluations",
          "description": "Evaluations of restrictions applied to parent group on this membership."
        }
      },
      "description": "A membership role within the Cloud Identity Groups API. A `MembershipRole` defines the privileges granted to a `Membership`."
    },
    "MembershipRoleRestrictionEvaluation": {
      "properties": {
        "state": {
          "enum": [
            "STATE_UNSPECIFIED",
            "COMPLIANT",
            "FORWARD_COMPLIANT",
            "NON_COMPLIANT",
            "EVALUATING"
          ],
          "description": "Output only. The current state of the restriction",
          "type": "string",
          "readOnly": true
        }
      },
      "type": "object",
      "description": "The evaluated state of this restriction."
    },
    "RestrictionEvaluations": {
      "description": "Evaluations of restrictions applied to parent group on this membership.",
      "type": "object",
      "properties": {
        "memberRestrictionEvaluation": {
          "$ref": "#/$defs/MembershipRoleRestrictionEvaluation",
          "description": "Evaluation of the member restriction applied to this membership. Empty if the user lacks permission to view the restriction evaluation."
        }
      }
    }
  }
}