Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #27 from gtema/dev
Browse files Browse the repository at this point in the history
feat: further extend identity
  • Loading branch information
gtema authored Feb 29, 2024
2 parents 3db1e5e + dfdac80 commit a46ac99
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 35 deletions.
13 changes: 9 additions & 4 deletions codegenerator/openapi/keystone_schemas/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,30 +134,35 @@ def _get_schema_ref(
# Domain Config
elif name in [
"DomainsConfigDefaultGetResponse",
"DomainsConfigGetResponse",
"DomainsConfigPutRequest",
"DomainsConfigPutResponse",
"DomainsConfigPatchResponse",
"DomainsConfigPatchRequest",
"DomainsConfigPatchResponse",
"DomainsConfigDefaultGetResponse",
]:
openapi_spec.components.schemas.setdefault(
name,
"DomainConfig",
TypeSchema(**DOMAIN_CONFIGS_SCHEMA),
)
ref = f"#/components/schemas/{name}"
ref = "#/components/schemas/DomainConfig"
elif name in [
"DomainsConfigGroupGetResponse",
"DomainsConfigGroupPatchRequest",
"DomainsConfigGroupPatchResponse",
"DomainsConfigGroupPatchResponse",
"DomainsConfigGroupPatchResponse",
"DomainsConfigDefaultGroupGetResponse",
"DomainsConfigGroupOptionPatchResponse",
"DomainsConfigGroupOptionGetResponse",
"DomainsConfigGroupOptionPatchRequest",
]:
openapi_spec.components.schemas.setdefault(
name,
"DomainConfigGroup",
TypeSchema(**DOMAIN_CONFIG_SCHEMA),
)
ref = f"#/components/schemas/{name}"
ref = "#/components/schemas/DomainConfigGroup"

else:
return (None, None, False)
Expand Down
10 changes: 5 additions & 5 deletions codegenerator/openapi/keystone_schemas/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,32 @@
}

PROJECT_LIST_PARAMETERS = {
"domain_id": {
"project_domain_id": {
"in": "query",
"name": "domain_id",
"description": "Filters the response by a domain ID.",
"schema": {"type": "string", "format": "uuid"},
},
"enabled": {
"project_enabled": {
"in": "query",
"name": "enabled",
"description": "If set to true, then only enabled projects will be returned. Any value other than 0 (including no value) will be interpreted as true.",
"schema": {"type": "boolean"},
},
"is_domain": {
"project_is_domain": {
"in": "query",
"name": "is_domain",
"description": "If this is specified as true, then only projects acting as a domain are included. Otherwise, only projects that are not acting as a domain are included.",
"schema": {"type": "boolean"},
"x-openstack": {"min-ver": "3.6"},
},
"name": {
"project_name": {
"in": "query",
"name": "name",
"description": "Filters the response by a resource name.",
"schema": {"type": "string"},
},
"parent_id": {
"project_parent_id": {
"in": "query",
"name": "parent_id",
"description": "Filters the response by a parent ID.",
Expand Down
73 changes: 53 additions & 20 deletions codegenerator/openapi/keystone_schemas/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
"format": "uuid",
"description": "The role ID.",
},
"links": {"type": "object"},
"links": {
"type": "object",
"additionalProperties": {
"type": ["string", "null"],
"format": "uri",
},
},
**assignment_schema._role_properties,
},
}
Expand Down Expand Up @@ -65,7 +71,29 @@
"type": "object",
"properties": {
"roles": {"type": "array", "items": ROLE_SCHEMA},
"links": {"type": "object"},
"links": {
"type": "object",
"additionalProperties": {
"type": ["string", "null"],
"format": "uri",
},
},
},
}

# List of role info
ROLES_INFO_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "List of roles assigned to the resource",
"properties": {
"roles": {"type": "array", "items": ROLE_INFO_SCHEMA},
"links": {
"type": "object",
"additionalProperties": {
"type": ["string", "null"],
"format": "uri",
},
},
},
}

Expand Down Expand Up @@ -383,26 +411,31 @@ def _get_schema_ref(
ref = f"#/components/schemas/{name}"

# Project/Domain Roles
elif name == "ProjectsUsersRolesGetResponse":
openapi_spec.components.schemas.setdefault(
name, TypeSchema(**ROLES_SCHEMA)
)
ref = f"#/components/schemas/{name}"
elif name == "ProjectsGroupsRolesGetResponse":
elif name in [
"ProjectsUsersRolesGetResponse",
"DomainsGroupsRolesGetResponse",
"ProjectsGroupsRolesGetResponse",
"DomainsUsersRolesGetResponse",
]:
openapi_spec.components.schemas.setdefault(
name, TypeSchema(**ROLES_SCHEMA)
"RolesInfos", TypeSchema(**ROLES_INFO_SCHEMA)
)
ref = f"#/components/schemas/{name}"
elif name == "DomainsUsersRolesGetResponse":
openapi_spec.components.schemas.setdefault(
name, TypeSchema(**ROLES_SCHEMA)
)
ref = f"#/components/schemas/{name}"
elif name == "DomainsGroupsRolesGetResponse":
openapi_spec.components.schemas.setdefault(
name, TypeSchema(**ROLES_SCHEMA)
)
ref = f"#/components/schemas/{name}"
ref = "#/components/schemas/RolesInfos"
elif name in [
"DomainsUsersRoleGetResponse",
"DomainsUsersRolePutRequest",
"DomainsUsersRolePutResponse",
"DomainsGroupsRoleGetResponse",
"DomainsGroupsRolePutRequest",
"DomainsGroupsRolePutResponse",
"ProjectsUsersRoleGetResponse",
"ProjectsUsersRolePutRequest",
"ProjectsUsersRolePutResponse",
"ProjectsGroupsRoleGetResponse",
"ProjectsGroupsRolePutRequest",
"ProjectsGroupsRolePutResponse",
]:
return (None, None, True)

else:
return (None, None, False)
Expand Down
7 changes: 1 addition & 6 deletions codegenerator/openapi/keystone_schemas/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,12 @@ def _get_schema_ref(
name, TypeSchema(**USER_CREATE_SCHEMA)
)
ref = f"#/components/schemas/{name}"
elif name == "UserPatchResponse":
openapi_spec.components.schemas.setdefault(
name, TypeSchema(**USER_CONTAINER_SCHEMA)
)
ref = f"#/components/schemas/{name}"
elif name == "UsersGetResponse":
openapi_spec.components.schemas.setdefault(
name, TypeSchema(**USERS_SCHEMA)
)
ref = f"#/components/schemas/{name}"
elif name == "UserGetResponse":
elif name in ["UserGetResponse", "UserPostResponse", "UserPatchResponse"]:
openapi_spec.components.schemas.setdefault(
name, TypeSchema(**USER_CONTAINER_SCHEMA)
)
Expand Down

0 comments on commit a46ac99

Please sign in to comment.