diff --git a/README.md b/README.md index 6c3ba9ce..23177907 100644 --- a/README.md +++ b/README.md @@ -830,6 +830,7 @@ Namespace | Resource | Operation | HTTP request | - [PrincipalType](docs/v2/models/PrincipalType.md) - [Realm](docs/v2/models/Realm.md) - [ReleaseStatus](docs/v2/models/ReleaseStatus.md) +- [RoleId](docs/v2/models/RoleId.md) - [ShortType](docs/v2/models/ShortType.md) - [ShortTypeDict](docs/v2/models/ShortTypeDict.md) - [SizeBytes](docs/v2/models/SizeBytes.md) @@ -877,6 +878,8 @@ Namespace | Resource | Operation | HTTP request | - [TransactionType](docs/v2/models/TransactionType.md) - [AccessRequirements](docs/v2/models/AccessRequirements.md) - [AccessRequirementsDict](docs/v2/models/AccessRequirementsDict.md) +- [Everyone](docs/v2/models/Everyone.md) +- [EveryoneDict](docs/v2/models/EveryoneDict.md) - [Folder](docs/v2/models/Folder.md) - [FolderDict](docs/v2/models/FolderDict.md) - [FolderRid](docs/v2/models/FolderRid.md) @@ -888,10 +891,14 @@ Namespace | Resource | Operation | HTTP request | - [ListMarkingsOfResourceResponseDict](docs/v2/models/ListMarkingsOfResourceResponseDict.md) - [ListOrganizationsOfProjectResponse](docs/v2/models/ListOrganizationsOfProjectResponse.md) - [ListOrganizationsOfProjectResponseDict](docs/v2/models/ListOrganizationsOfProjectResponseDict.md) +- [ListResourceRolesResponse](docs/v2/models/ListResourceRolesResponse.md) +- [ListResourceRolesResponseDict](docs/v2/models/ListResourceRolesResponseDict.md) - [Marking](docs/v2/models/Marking.md) - [MarkingDict](docs/v2/models/MarkingDict.md) - [Organization](docs/v2/models/Organization.md) - [OrganizationDict](docs/v2/models/OrganizationDict.md) +- [PrincipalWithId](docs/v2/models/PrincipalWithId.md) +- [PrincipalWithIdDict](docs/v2/models/PrincipalWithIdDict.md) - [Project](docs/v2/models/Project.md) - [ProjectDict](docs/v2/models/ProjectDict.md) - [ProjectRid](docs/v2/models/ProjectRid.md) @@ -900,6 +907,10 @@ Namespace | Resource | Operation | HTTP request | - [ResourceDisplayName](docs/v2/models/ResourceDisplayName.md) - [ResourcePath](docs/v2/models/ResourcePath.md) - [ResourceRid](docs/v2/models/ResourceRid.md) +- [ResourceRole](docs/v2/models/ResourceRole.md) +- [ResourceRoleDict](docs/v2/models/ResourceRoleDict.md) +- [ResourceRolePrincipal](docs/v2/models/ResourceRolePrincipal.md) +- [ResourceRolePrincipalDict](docs/v2/models/ResourceRolePrincipalDict.md) - [ResourceType](docs/v2/models/ResourceType.md) - [SpaceRid](docs/v2/models/SpaceRid.md) - [TrashStatus](docs/v2/models/TrashStatus.md) diff --git a/docs/v2/Filesystem/ResourceRole.md b/docs/v2/Filesystem/ResourceRole.md new file mode 100644 index 00000000..874a48b2 --- /dev/null +++ b/docs/v2/Filesystem/ResourceRole.md @@ -0,0 +1,254 @@ +# ResourceRole + +Method | HTTP request | +------------- | ------------- | + + + +### Parameters + +Name | Type | Description | Notes | +------------- | ------------- | ------------- | ------------- | +**resource_rid** | ResourceRid | resourceRid | | +**roles** | List[ResourceRoleDict] | | | +**preview** | Optional[PreviewMode] | preview | [optional] | + +### Return type +**None** + +### Example + +```python +from foundry.v2 import FoundryClient +import foundry +from pprint import pprint + +foundry_client = FoundryClient( + auth=foundry.UserTokenAuth(...), hostname="example.palantirfoundry.com" +) + +# ResourceRid | resourceRid +resource_rid = "ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da" +# List[ResourceRoleDict] | +roles = [{"roleId": "8bf49052-dc37-4528-8bf0-b551cfb71268"}] +# Optional[PreviewMode] | preview +preview = None + + +try: + api_response = foundry_client.filesystem.Resource.ResourceRole.add( + resource_rid, + roles=roles, + preview=preview, + ) + print("The add response:\n") + pprint(api_response) +except foundry.PalantirRPCException as e: + print("HTTP error when calling ResourceRole.add: %s\n" % e) + +``` + + + +### Authorization + +See [README](../../../README.md#authorization) + +### HTTP response details +| Status Code | Type | Description | Content Type | +|-------------|-------------|-------------|------------------| +**204** | None | | None | + +[[Back to top]](#) [[Back to API list]](../../../README.md#apis-v2-link) [[Back to Model list]](../../../README.md#models-v2-link) [[Back to README]](../../../README.md) + +List the roles on a resource. + + +### Parameters + +Name | Type | Description | Notes | +------------- | ------------- | ------------- | ------------- | +**resource_rid** | ResourceRid | resourceRid | | +**include_inherited** | Optional[bool] | includeInherited | [optional] | +**page_size** | Optional[PageSize] | pageSize | [optional] | +**page_token** | Optional[PageToken] | pageToken | [optional] | +**preview** | Optional[PreviewMode] | preview | [optional] | + +### Return type +**ResourceIterator[ResourceRole]** + +### Example + +```python +from foundry.v2 import FoundryClient +import foundry +from pprint import pprint + +foundry_client = FoundryClient( + auth=foundry.UserTokenAuth(...), hostname="example.palantirfoundry.com" +) + +# ResourceRid | resourceRid +resource_rid = "ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da" +# Optional[bool] | includeInherited +include_inherited = None +# Optional[PageSize] | pageSize +page_size = None +# Optional[PageToken] | pageToken +page_token = None +# Optional[PreviewMode] | preview +preview = None + + +try: + for resource_role in foundry_client.filesystem.Resource.ResourceRole.list( + resource_rid, + include_inherited=include_inherited, + page_size=page_size, + page_token=page_token, + preview=preview, + ): + pprint(resource_role) +except foundry.PalantirRPCException as e: + print("HTTP error when calling ResourceRole.list: %s\n" % e) + +``` + + + +### Authorization + +See [README](../../../README.md#authorization) + +### HTTP response details +| Status Code | Type | Description | Content Type | +|-------------|-------------|-------------|------------------| +**200** | ListResourceRolesResponse | | application/json | + +[[Back to top]](#) [[Back to API list]](../../../README.md#apis-v2-link) [[Back to Model list]](../../../README.md#models-v2-link) [[Back to README]](../../../README.md) + +List the roles on a resource. + + +### Parameters + +Name | Type | Description | Notes | +------------- | ------------- | ------------- | ------------- | +**resource_rid** | ResourceRid | resourceRid | | +**include_inherited** | Optional[bool] | includeInherited | [optional] | +**page_size** | Optional[PageSize] | pageSize | [optional] | +**page_token** | Optional[PageToken] | pageToken | [optional] | +**preview** | Optional[PreviewMode] | preview | [optional] | + +### Return type +**ListResourceRolesResponse** + +### Example + +```python +from foundry.v2 import FoundryClient +import foundry +from pprint import pprint + +foundry_client = FoundryClient( + auth=foundry.UserTokenAuth(...), hostname="example.palantirfoundry.com" +) + +# ResourceRid | resourceRid +resource_rid = "ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da" +# Optional[bool] | includeInherited +include_inherited = None +# Optional[PageSize] | pageSize +page_size = None +# Optional[PageToken] | pageToken +page_token = None +# Optional[PreviewMode] | preview +preview = None + + +try: + api_response = foundry_client.filesystem.Resource.ResourceRole.page( + resource_rid, + include_inherited=include_inherited, + page_size=page_size, + page_token=page_token, + preview=preview, + ) + print("The page response:\n") + pprint(api_response) +except foundry.PalantirRPCException as e: + print("HTTP error when calling ResourceRole.page: %s\n" % e) + +``` + + + +### Authorization + +See [README](../../../README.md#authorization) + +### HTTP response details +| Status Code | Type | Description | Content Type | +|-------------|-------------|-------------|------------------| +**200** | ListResourceRolesResponse | | application/json | + +[[Back to top]](#) [[Back to API list]](../../../README.md#apis-v2-link) [[Back to Model list]](../../../README.md#models-v2-link) [[Back to README]](../../../README.md) + + + +### Parameters + +Name | Type | Description | Notes | +------------- | ------------- | ------------- | ------------- | +**resource_rid** | ResourceRid | resourceRid | | +**roles** | List[ResourceRoleDict] | | | +**preview** | Optional[PreviewMode] | preview | [optional] | + +### Return type +**None** + +### Example + +```python +from foundry.v2 import FoundryClient +import foundry +from pprint import pprint + +foundry_client = FoundryClient( + auth=foundry.UserTokenAuth(...), hostname="example.palantirfoundry.com" +) + +# ResourceRid | resourceRid +resource_rid = "ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da" +# List[ResourceRoleDict] | +roles = [{"roleId": "8bf49052-dc37-4528-8bf0-b551cfb71268"}] +# Optional[PreviewMode] | preview +preview = None + + +try: + api_response = foundry_client.filesystem.Resource.ResourceRole.remove( + resource_rid, + roles=roles, + preview=preview, + ) + print("The remove response:\n") + pprint(api_response) +except foundry.PalantirRPCException as e: + print("HTTP error when calling ResourceRole.remove: %s\n" % e) + +``` + + + +### Authorization + +See [README](../../../README.md#authorization) + +### HTTP response details +| Status Code | Type | Description | Content Type | +|-------------|-------------|-------------|------------------| +**204** | None | | None | + +[[Back to top]](#) [[Back to API list]](../../../README.md#apis-v2-link) [[Back to Model list]](../../../README.md#models-v2-link) [[Back to README]](../../../README.md) + diff --git a/docs/v2/core/models/RoleId.md b/docs/v2/core/models/RoleId.md new file mode 100644 index 00000000..f3a43826 --- /dev/null +++ b/docs/v2/core/models/RoleId.md @@ -0,0 +1,14 @@ +# RoleId + +The unique ID for a Role. Roles are sets of permissions that grant different levels of access to resources. +The default roles in Foundry are: Owner, Editor, Viewer, and Discoverer. See more about +[roles](/docs/foundry/security/projects-and-roles#roles) in the user documentation. + + +## Type +```python +str +``` + + +[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md) diff --git a/docs/v2/filesystem/models/Everyone.md b/docs/v2/filesystem/models/Everyone.md new file mode 100644 index 00000000..1ffd40c8 --- /dev/null +++ b/docs/v2/filesystem/models/Everyone.md @@ -0,0 +1,11 @@ +# Everyone + +A principal representing all users of the platform. + +## Properties +| Name | Type | Required | Description | +| ------------ | ------------- | ------------- | ------------- | +**type** | Literal["everyone"] | Yes | None | + + +[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md) diff --git a/docs/v2/filesystem/models/EveryoneDict.md b/docs/v2/filesystem/models/EveryoneDict.md new file mode 100644 index 00000000..2b51e32b --- /dev/null +++ b/docs/v2/filesystem/models/EveryoneDict.md @@ -0,0 +1,11 @@ +# EveryoneDict + +A principal representing all users of the platform. + +## Properties +| Name | Type | Required | Description | +| ------------ | ------------- | ------------- | ------------- | +**type** | Literal["everyone"] | Yes | None | + + +[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md) diff --git a/docs/v2/filesystem/models/ListResourceRolesResponse.md b/docs/v2/filesystem/models/ListResourceRolesResponse.md new file mode 100644 index 00000000..d7191253 --- /dev/null +++ b/docs/v2/filesystem/models/ListResourceRolesResponse.md @@ -0,0 +1,12 @@ +# ListResourceRolesResponse + +ListResourceRolesResponse + +## Properties +| Name | Type | Required | Description | +| ------------ | ------------- | ------------- | ------------- | +**data** | List[ResourceRole] | Yes | | +**next_page_token** | Optional[PageToken] | No | | + + +[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md) diff --git a/docs/v2/filesystem/models/ListResourceRolesResponseDict.md b/docs/v2/filesystem/models/ListResourceRolesResponseDict.md new file mode 100644 index 00000000..b5c36066 --- /dev/null +++ b/docs/v2/filesystem/models/ListResourceRolesResponseDict.md @@ -0,0 +1,12 @@ +# ListResourceRolesResponseDict + +ListResourceRolesResponse + +## Properties +| Name | Type | Required | Description | +| ------------ | ------------- | ------------- | ------------- | +**data** | List[ResourceRoleDict] | Yes | | +**nextPageToken** | NotRequired[PageToken] | No | | + + +[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md) diff --git a/docs/v2/filesystem/models/PrincipalWithId.md b/docs/v2/filesystem/models/PrincipalWithId.md new file mode 100644 index 00000000..b57f9671 --- /dev/null +++ b/docs/v2/filesystem/models/PrincipalWithId.md @@ -0,0 +1,13 @@ +# PrincipalWithId + +Represents a user principal or group principal with an ID. + +## Properties +| Name | Type | Required | Description | +| ------------ | ------------- | ------------- | ------------- | +**principal_id** | PrincipalId | Yes | | +**principal_type** | PrincipalType | Yes | | +**type** | Literal["principalWithId"] | Yes | None | + + +[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md) diff --git a/docs/v2/filesystem/models/PrincipalWithIdDict.md b/docs/v2/filesystem/models/PrincipalWithIdDict.md new file mode 100644 index 00000000..8b9ac914 --- /dev/null +++ b/docs/v2/filesystem/models/PrincipalWithIdDict.md @@ -0,0 +1,13 @@ +# PrincipalWithIdDict + +Represents a user principal or group principal with an ID. + +## Properties +| Name | Type | Required | Description | +| ------------ | ------------- | ------------- | ------------- | +**principalId** | PrincipalId | Yes | | +**principalType** | PrincipalType | Yes | | +**type** | Literal["principalWithId"] | Yes | None | + + +[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md) diff --git a/docs/v2/filesystem/models/ResourceRole.md b/docs/v2/filesystem/models/ResourceRole.md new file mode 100644 index 00000000..74d1c340 --- /dev/null +++ b/docs/v2/filesystem/models/ResourceRole.md @@ -0,0 +1,12 @@ +# ResourceRole + +ResourceRole + +## Properties +| Name | Type | Required | Description | +| ------------ | ------------- | ------------- | ------------- | +**resource_role_principal** | ResourceRolePrincipal | Yes | | +**role_id** | RoleId | Yes | | + + +[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md) diff --git a/docs/v2/filesystem/models/ResourceRoleDict.md b/docs/v2/filesystem/models/ResourceRoleDict.md new file mode 100644 index 00000000..3c744022 --- /dev/null +++ b/docs/v2/filesystem/models/ResourceRoleDict.md @@ -0,0 +1,12 @@ +# ResourceRoleDict + +ResourceRole + +## Properties +| Name | Type | Required | Description | +| ------------ | ------------- | ------------- | ------------- | +**resourceRolePrincipal** | ResourceRolePrincipalDict | Yes | | +**roleId** | RoleId | Yes | | + + +[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md) diff --git a/docs/v2/filesystem/models/ResourceRolePrincipal.md b/docs/v2/filesystem/models/ResourceRolePrincipal.md new file mode 100644 index 00000000..df24a7d4 --- /dev/null +++ b/docs/v2/filesystem/models/ResourceRolePrincipal.md @@ -0,0 +1,16 @@ +# ResourceRolePrincipal + +ResourceRolePrincipal + +This is a discriminator type and does not contain any fields. Instead, it is a union +of of the models listed below. + +This discriminator class uses the `type` field to differentiate between classes. + +| Class | Value +| ------------ | ------------- +PrincipalWithId | principalWithId +Everyone | everyone + + +[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md) diff --git a/docs/v2/filesystem/models/ResourceRolePrincipalDict.md b/docs/v2/filesystem/models/ResourceRolePrincipalDict.md new file mode 100644 index 00000000..9b8f6a7a --- /dev/null +++ b/docs/v2/filesystem/models/ResourceRolePrincipalDict.md @@ -0,0 +1,16 @@ +# ResourceRolePrincipalDict + +ResourceRolePrincipal + +This is a discriminator type and does not contain any fields. Instead, it is a union +of of the models listed below. + +This discriminator class uses the `type` field to differentiate between classes. + +| Class | Value +| ------------ | ------------- +PrincipalWithIdDict | principalWithId +EveryoneDict | everyone + + +[[Back to Model list]](../../../../README.md#models-v2-link) [[Back to API list]](../../../../README.md#apis-v2-link) [[Back to README]](../../../../README.md) diff --git a/foundry/_versions.py b/foundry/_versions.py index f1455611..ebd21d47 100644 --- a/foundry/_versions.py +++ b/foundry/_versions.py @@ -17,4 +17,4 @@ # using the autorelease bot __version__ = "0.0.0" -__openapi_document_version__ = "1.1026.0" +__openapi_document_version__ = "1.1027.0" diff --git a/foundry/v2/cli.py b/foundry/v2/cli.py index 42edcb14..e0c63899 100644 --- a/foundry/v2/cli.py +++ b/foundry/v2/cli.py @@ -2723,6 +2723,109 @@ def filesystem_resource_restore( click.echo(repr(result)) +@filesystem_resource.group("resource_role") +def filesystem_resource_resource_role(): + pass + + +@filesystem_resource_resource_role.command("add") +@click.argument("resource_rid", type=str, required=True) +@click.option("--roles", type=str, required=True, help="""""") +@click.option("--preview", type=bool, required=False, help="""preview""") +@click.pass_obj +def filesystem_resource_resource_role_add( + client: foundry.v2.FoundryClient, + resource_rid: str, + roles: str, + preview: Optional[bool], +): + """ """ + result = client.filesystem.Resource.ResourceRole.add( + resource_rid=resource_rid, + roles=json.loads(roles), + preview=preview, + ) + click.echo(repr(result)) + + +@filesystem_resource_resource_role.command("list") +@click.argument("resource_rid", type=str, required=True) +@click.option("--include_inherited", type=bool, required=False, help="""includeInherited""") +@click.option("--page_size", type=int, required=False, help="""pageSize""") +@click.option("--page_token", type=str, required=False, help="""pageToken""") +@click.option("--preview", type=bool, required=False, help="""preview""") +@click.pass_obj +def filesystem_resource_resource_role_list( + client: foundry.v2.FoundryClient, + resource_rid: str, + include_inherited: Optional[bool], + page_size: Optional[int], + page_token: Optional[str], + preview: Optional[bool], +): + """ + List the roles on a resource. + + """ + result = client.filesystem.Resource.ResourceRole.list( + resource_rid=resource_rid, + include_inherited=include_inherited, + page_size=page_size, + page_token=page_token, + preview=preview, + ) + click.echo(repr(result)) + + +@filesystem_resource_resource_role.command("page") +@click.argument("resource_rid", type=str, required=True) +@click.option("--include_inherited", type=bool, required=False, help="""includeInherited""") +@click.option("--page_size", type=int, required=False, help="""pageSize""") +@click.option("--page_token", type=str, required=False, help="""pageToken""") +@click.option("--preview", type=bool, required=False, help="""preview""") +@click.pass_obj +def filesystem_resource_resource_role_page( + client: foundry.v2.FoundryClient, + resource_rid: str, + include_inherited: Optional[bool], + page_size: Optional[int], + page_token: Optional[str], + preview: Optional[bool], +): + """ + List the roles on a resource. + + """ + result = client.filesystem.Resource.ResourceRole.page( + resource_rid=resource_rid, + include_inherited=include_inherited, + page_size=page_size, + page_token=page_token, + preview=preview, + ) + click.echo(repr(result)) + + +@filesystem_resource_resource_role.command("remove") +@click.argument("resource_rid", type=str, required=True) +@click.option("--roles", type=str, required=True, help="""""") +@click.option("--preview", type=bool, required=False, help="""preview""") +@click.pass_obj +def filesystem_resource_resource_role_remove( + client: foundry.v2.FoundryClient, + resource_rid: str, + roles: str, + preview: Optional[bool], +): + """ """ + result = client.filesystem.Resource.ResourceRole.remove( + resource_rid=resource_rid, + roles=json.loads(roles), + preview=preview, + ) + click.echo(repr(result)) + + @filesystem_resource.group("access_requirements") def filesystem_resource_access_requirements(): pass diff --git a/foundry/v2/core/models/__init__.py b/foundry/v2/core/models/__init__.py index 5ee68b96..d90e9138 100644 --- a/foundry/v2/core/models/__init__.py +++ b/foundry/v2/core/models/__init__.py @@ -112,6 +112,7 @@ from foundry.v2.core.models._principal_type import PrincipalType from foundry.v2.core.models._realm import Realm from foundry.v2.core.models._release_status import ReleaseStatus +from foundry.v2.core.models._role_id import RoleId from foundry.v2.core.models._short_type import ShortType from foundry.v2.core.models._short_type_dict import ShortTypeDict from foundry.v2.core.models._size_bytes import SizeBytes @@ -227,6 +228,7 @@ "PrincipalType", "Realm", "ReleaseStatus", + "RoleId", "ShortType", "ShortTypeDict", "SizeBytes", diff --git a/foundry/v2/core/models/_role_id.py b/foundry/v2/core/models/_role_id.py new file mode 100644 index 00000000..58a162b4 --- /dev/null +++ b/foundry/v2/core/models/_role_id.py @@ -0,0 +1,23 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +RoleId = str +""" +The unique ID for a Role. Roles are sets of permissions that grant different levels of access to resources. +The default roles in Foundry are: Owner, Editor, Viewer, and Discoverer. See more about +[roles](/docs/foundry/security/projects-and-roles#roles) in the user documentation. +""" diff --git a/foundry/v2/filesystem/errors/__init__.py b/foundry/v2/filesystem/errors/__init__.py index a27da481..863a8bde 100644 --- a/foundry/v2/filesystem/errors/__init__.py +++ b/foundry/v2/filesystem/errors/__init__.py @@ -22,6 +22,9 @@ from foundry.v2.filesystem.errors._add_organizations_permission_denied import ( AddOrganizationsPermissionDenied, ) # NOQA +from foundry.v2.filesystem.errors._add_resource_roles_permission_denied import ( + AddResourceRolesPermissionDenied, +) # NOQA from foundry.v2.filesystem.errors._create_folder_outside_project_not_supported import ( CreateFolderOutsideProjectNotSupported, ) # NOQA @@ -61,6 +64,9 @@ from foundry.v2.filesystem.errors._remove_organizations_permission_denied import ( RemoveOrganizationsPermissionDenied, ) # NOQA +from foundry.v2.filesystem.errors._remove_resource_roles_permission_denied import ( + RemoveResourceRolesPermissionDenied, +) # NOQA from foundry.v2.filesystem.errors._resource_not_directly_trashed import ( ResourceNotDirectlyTrashed, ) # NOQA @@ -83,6 +89,7 @@ "AccessRequirementsNotFound", "AddMarkingsPermissionDenied", "AddOrganizationsPermissionDenied", + "AddResourceRolesPermissionDenied", "CreateFolderOutsideProjectNotSupported", "CreateFolderPermissionDenied", "DeleteResourcePermissionDenied", @@ -102,6 +109,7 @@ "ProjectNotFound", "RemoveMarkingsPermissionDenied", "RemoveOrganizationsPermissionDenied", + "RemoveResourceRolesPermissionDenied", "ResourceNotDirectlyTrashed", "ResourceNotFound", "ResourceNotTrashed", diff --git a/foundry/v2/filesystem/errors/_add_resource_roles_permission_denied.py b/foundry/v2/filesystem/errors/_add_resource_roles_permission_denied.py new file mode 100644 index 00000000..33d00d38 --- /dev/null +++ b/foundry/v2/filesystem/errors/_add_resource_roles_permission_denied.py @@ -0,0 +1,43 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from dataclasses import dataclass +from typing import Literal + +import pydantic +from typing_extensions import TypedDict + +from foundry._errors import PalantirRPCException +from foundry.v2.filesystem.models._resource_rid import ResourceRid + + +class AddResourceRolesPermissionDeniedParameters(TypedDict): + """Could not add the ResourceRole.""" + + __pydantic_config__ = {"extra": "allow"} # type: ignore + + resourceRid: ResourceRid + + +@dataclass +class AddResourceRolesPermissionDenied(PalantirRPCException): + name: Literal["AddResourceRolesPermissionDenied"] + parameters: AddResourceRolesPermissionDeniedParameters + error_instance_id: str + + +__all__ = ["AddResourceRolesPermissionDenied"] diff --git a/foundry/v2/filesystem/errors/_remove_resource_roles_permission_denied.py b/foundry/v2/filesystem/errors/_remove_resource_roles_permission_denied.py new file mode 100644 index 00000000..1341eab4 --- /dev/null +++ b/foundry/v2/filesystem/errors/_remove_resource_roles_permission_denied.py @@ -0,0 +1,43 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from dataclasses import dataclass +from typing import Literal + +import pydantic +from typing_extensions import TypedDict + +from foundry._errors import PalantirRPCException +from foundry.v2.filesystem.models._resource_rid import ResourceRid + + +class RemoveResourceRolesPermissionDeniedParameters(TypedDict): + """Could not remove the ResourceRole.""" + + __pydantic_config__ = {"extra": "allow"} # type: ignore + + resourceRid: ResourceRid + + +@dataclass +class RemoveResourceRolesPermissionDenied(PalantirRPCException): + name: Literal["RemoveResourceRolesPermissionDenied"] + parameters: RemoveResourceRolesPermissionDeniedParameters + error_instance_id: str + + +__all__ = ["RemoveResourceRolesPermissionDenied"] diff --git a/foundry/v2/filesystem/models/__init__.py b/foundry/v2/filesystem/models/__init__.py index f702b687..67aa033f 100644 --- a/foundry/v2/filesystem/models/__init__.py +++ b/foundry/v2/filesystem/models/__init__.py @@ -15,6 +15,8 @@ from foundry.v2.filesystem.models._access_requirements import AccessRequirements from foundry.v2.filesystem.models._access_requirements_dict import AccessRequirementsDict # NOQA +from foundry.v2.filesystem.models._everyone import Everyone +from foundry.v2.filesystem.models._everyone_dict import EveryoneDict from foundry.v2.filesystem.models._folder import Folder from foundry.v2.filesystem.models._folder_dict import FolderDict from foundry.v2.filesystem.models._folder_rid import FolderRid @@ -38,10 +40,18 @@ from foundry.v2.filesystem.models._list_organizations_of_project_response_dict import ( ListOrganizationsOfProjectResponseDict, ) # NOQA +from foundry.v2.filesystem.models._list_resource_roles_response import ( + ListResourceRolesResponse, +) # NOQA +from foundry.v2.filesystem.models._list_resource_roles_response_dict import ( + ListResourceRolesResponseDict, +) # NOQA from foundry.v2.filesystem.models._marking import Marking from foundry.v2.filesystem.models._marking_dict import MarkingDict from foundry.v2.filesystem.models._organization import Organization from foundry.v2.filesystem.models._organization_dict import OrganizationDict +from foundry.v2.filesystem.models._principal_with_id import PrincipalWithId +from foundry.v2.filesystem.models._principal_with_id_dict import PrincipalWithIdDict from foundry.v2.filesystem.models._project import Project from foundry.v2.filesystem.models._project_dict import ProjectDict from foundry.v2.filesystem.models._project_rid import ProjectRid @@ -50,6 +60,12 @@ from foundry.v2.filesystem.models._resource_display_name import ResourceDisplayName from foundry.v2.filesystem.models._resource_path import ResourcePath from foundry.v2.filesystem.models._resource_rid import ResourceRid +from foundry.v2.filesystem.models._resource_role import ResourceRole +from foundry.v2.filesystem.models._resource_role_dict import ResourceRoleDict +from foundry.v2.filesystem.models._resource_role_principal import ResourceRolePrincipal +from foundry.v2.filesystem.models._resource_role_principal_dict import ( + ResourceRolePrincipalDict, +) # NOQA from foundry.v2.filesystem.models._resource_type import ResourceType from foundry.v2.filesystem.models._space_rid import SpaceRid from foundry.v2.filesystem.models._trash_status import TrashStatus @@ -57,6 +73,8 @@ __all__ = [ "AccessRequirements", "AccessRequirementsDict", + "Everyone", + "EveryoneDict", "Folder", "FolderDict", "FolderRid", @@ -68,10 +86,14 @@ "ListMarkingsOfResourceResponseDict", "ListOrganizationsOfProjectResponse", "ListOrganizationsOfProjectResponseDict", + "ListResourceRolesResponse", + "ListResourceRolesResponseDict", "Marking", "MarkingDict", "Organization", "OrganizationDict", + "PrincipalWithId", + "PrincipalWithIdDict", "Project", "ProjectDict", "ProjectRid", @@ -80,6 +102,10 @@ "ResourceDisplayName", "ResourcePath", "ResourceRid", + "ResourceRole", + "ResourceRoleDict", + "ResourceRolePrincipal", + "ResourceRolePrincipalDict", "ResourceType", "SpaceRid", "TrashStatus", diff --git a/foundry/v2/filesystem/models/_everyone.py b/foundry/v2/filesystem/models/_everyone.py new file mode 100644 index 00000000..e9d448ef --- /dev/null +++ b/foundry/v2/filesystem/models/_everyone.py @@ -0,0 +1,35 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from typing import Literal +from typing import cast + +import pydantic + +from foundry.v2.filesystem.models._everyone_dict import EveryoneDict + + +class Everyone(pydantic.BaseModel): + """A principal representing all users of the platform.""" + + type: Literal["everyone"] = "everyone" + + model_config = {"extra": "allow"} + + def to_dict(self) -> EveryoneDict: + """Return the dictionary representation of the model using the field aliases.""" + return cast(EveryoneDict, self.model_dump(by_alias=True, exclude_unset=True)) diff --git a/foundry/v2/filesystem/models/_everyone_dict.py b/foundry/v2/filesystem/models/_everyone_dict.py new file mode 100644 index 00000000..bfe9a3f8 --- /dev/null +++ b/foundry/v2/filesystem/models/_everyone_dict.py @@ -0,0 +1,28 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from typing import Literal + +from typing_extensions import TypedDict + + +class EveryoneDict(TypedDict): + """A principal representing all users of the platform.""" + + __pydantic_config__ = {"extra": "allow"} # type: ignore + + type: Literal["everyone"] diff --git a/foundry/v2/filesystem/models/_list_resource_roles_response.py b/foundry/v2/filesystem/models/_list_resource_roles_response.py new file mode 100644 index 00000000..3041f90d --- /dev/null +++ b/foundry/v2/filesystem/models/_list_resource_roles_response.py @@ -0,0 +1,44 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from typing import List +from typing import Optional +from typing import cast + +import pydantic + +from foundry.v2.core.models._page_token import PageToken +from foundry.v2.filesystem.models._list_resource_roles_response_dict import ( + ListResourceRolesResponseDict, +) # NOQA +from foundry.v2.filesystem.models._resource_role import ResourceRole + + +class ListResourceRolesResponse(pydantic.BaseModel): + """ListResourceRolesResponse""" + + data: List[ResourceRole] + + next_page_token: Optional[PageToken] = pydantic.Field(alias="nextPageToken", default=None) + + model_config = {"extra": "allow"} + + def to_dict(self) -> ListResourceRolesResponseDict: + """Return the dictionary representation of the model using the field aliases.""" + return cast( + ListResourceRolesResponseDict, self.model_dump(by_alias=True, exclude_unset=True) + ) diff --git a/foundry/v2/filesystem/models/_list_resource_roles_response_dict.py b/foundry/v2/filesystem/models/_list_resource_roles_response_dict.py new file mode 100644 index 00000000..d9052b17 --- /dev/null +++ b/foundry/v2/filesystem/models/_list_resource_roles_response_dict.py @@ -0,0 +1,34 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from typing import List + +from typing_extensions import NotRequired +from typing_extensions import TypedDict + +from foundry.v2.core.models._page_token import PageToken +from foundry.v2.filesystem.models._resource_role_dict import ResourceRoleDict + + +class ListResourceRolesResponseDict(TypedDict): + """ListResourceRolesResponse""" + + __pydantic_config__ = {"extra": "allow"} # type: ignore + + data: List[ResourceRoleDict] + + nextPageToken: NotRequired[PageToken] diff --git a/foundry/v2/filesystem/models/_principal_with_id.py b/foundry/v2/filesystem/models/_principal_with_id.py new file mode 100644 index 00000000..0d096d47 --- /dev/null +++ b/foundry/v2/filesystem/models/_principal_with_id.py @@ -0,0 +1,41 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from typing import Literal +from typing import cast + +import pydantic + +from foundry.v2.core.models._principal_id import PrincipalId +from foundry.v2.core.models._principal_type import PrincipalType +from foundry.v2.filesystem.models._principal_with_id_dict import PrincipalWithIdDict + + +class PrincipalWithId(pydantic.BaseModel): + """Represents a user principal or group principal with an ID.""" + + principal_id: PrincipalId = pydantic.Field(alias="principalId") + + principal_type: PrincipalType = pydantic.Field(alias="principalType") + + type: Literal["principalWithId"] = "principalWithId" + + model_config = {"extra": "allow"} + + def to_dict(self) -> PrincipalWithIdDict: + """Return the dictionary representation of the model using the field aliases.""" + return cast(PrincipalWithIdDict, self.model_dump(by_alias=True, exclude_unset=True)) diff --git a/foundry/v2/filesystem/models/_principal_with_id_dict.py b/foundry/v2/filesystem/models/_principal_with_id_dict.py new file mode 100644 index 00000000..d34a9965 --- /dev/null +++ b/foundry/v2/filesystem/models/_principal_with_id_dict.py @@ -0,0 +1,35 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from typing import Literal + +from typing_extensions import TypedDict + +from foundry.v2.core.models._principal_id import PrincipalId +from foundry.v2.core.models._principal_type import PrincipalType + + +class PrincipalWithIdDict(TypedDict): + """Represents a user principal or group principal with an ID.""" + + __pydantic_config__ = {"extra": "allow"} # type: ignore + + principalId: PrincipalId + + principalType: PrincipalType + + type: Literal["principalWithId"] diff --git a/foundry/v2/filesystem/models/_resource_role.py b/foundry/v2/filesystem/models/_resource_role.py new file mode 100644 index 00000000..6ef3b382 --- /dev/null +++ b/foundry/v2/filesystem/models/_resource_role.py @@ -0,0 +1,38 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from typing import cast + +import pydantic + +from foundry.v2.core.models._role_id import RoleId +from foundry.v2.filesystem.models._resource_role_dict import ResourceRoleDict +from foundry.v2.filesystem.models._resource_role_principal import ResourceRolePrincipal + + +class ResourceRole(pydantic.BaseModel): + """ResourceRole""" + + resource_role_principal: ResourceRolePrincipal = pydantic.Field(alias="resourceRolePrincipal") + + role_id: RoleId = pydantic.Field(alias="roleId") + + model_config = {"extra": "allow"} + + def to_dict(self) -> ResourceRoleDict: + """Return the dictionary representation of the model using the field aliases.""" + return cast(ResourceRoleDict, self.model_dump(by_alias=True, exclude_unset=True)) diff --git a/foundry/v2/filesystem/models/_resource_role_dict.py b/foundry/v2/filesystem/models/_resource_role_dict.py new file mode 100644 index 00000000..f749e797 --- /dev/null +++ b/foundry/v2/filesystem/models/_resource_role_dict.py @@ -0,0 +1,33 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from typing_extensions import TypedDict + +from foundry.v2.core.models._role_id import RoleId +from foundry.v2.filesystem.models._resource_role_principal_dict import ( + ResourceRolePrincipalDict, +) # NOQA + + +class ResourceRoleDict(TypedDict): + """ResourceRole""" + + __pydantic_config__ = {"extra": "allow"} # type: ignore + + resourceRolePrincipal: ResourceRolePrincipalDict + + roleId: RoleId diff --git a/foundry/v2/filesystem/models/_resource_role_principal.py b/foundry/v2/filesystem/models/_resource_role_principal.py new file mode 100644 index 00000000..1f18f190 --- /dev/null +++ b/foundry/v2/filesystem/models/_resource_role_principal.py @@ -0,0 +1,29 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from typing import Union + +import pydantic +from typing_extensions import Annotated + +from foundry.v2.filesystem.models._everyone import Everyone +from foundry.v2.filesystem.models._principal_with_id import PrincipalWithId + +ResourceRolePrincipal = Annotated[ + Union[PrincipalWithId, Everyone], pydantic.Field(discriminator="type") +] +"""ResourceRolePrincipal""" diff --git a/foundry/v2/filesystem/models/_resource_role_principal_dict.py b/foundry/v2/filesystem/models/_resource_role_principal_dict.py new file mode 100644 index 00000000..bbcd3613 --- /dev/null +++ b/foundry/v2/filesystem/models/_resource_role_principal_dict.py @@ -0,0 +1,29 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +from typing import Union + +import pydantic +from typing_extensions import Annotated + +from foundry.v2.filesystem.models._everyone_dict import EveryoneDict +from foundry.v2.filesystem.models._principal_with_id_dict import PrincipalWithIdDict + +ResourceRolePrincipalDict = Annotated[ + Union[PrincipalWithIdDict, EveryoneDict], pydantic.Field(discriminator="type") +] +"""ResourceRolePrincipal""" diff --git a/foundry/v2/filesystem/resource.py b/foundry/v2/filesystem/resource.py index 901e6262..763ad0aa 100644 --- a/foundry/v2/filesystem/resource.py +++ b/foundry/v2/filesystem/resource.py @@ -42,6 +42,7 @@ from foundry.v2.filesystem.models._resource import Resource from foundry.v2.filesystem.models._resource_path import ResourcePath from foundry.v2.filesystem.models._resource_rid import ResourceRid +from foundry.v2.filesystem.resource_role import ResourceRoleClient class ResourceClient: @@ -49,6 +50,7 @@ def __init__(self, auth: Auth, hostname: str) -> None: self._api_client = ApiClient(auth=auth, hostname=hostname) self.AccessRequirements = AccessRequirementsClient(auth=auth, hostname=hostname) + self.ResourceRole = ResourceRoleClient(auth=auth, hostname=hostname) @maybe_ignore_preview @pydantic.validate_call diff --git a/foundry/v2/filesystem/resource_role.py b/foundry/v2/filesystem/resource_role.py new file mode 100644 index 00000000..9d9252cd --- /dev/null +++ b/foundry/v2/filesystem/resource_role.py @@ -0,0 +1,266 @@ +# Copyright 2024 Palantir Technologies, 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. + + +from __future__ import annotations + +import warnings +from typing import Any +from typing import Dict +from typing import List +from typing import Optional + +import pydantic +from typing_extensions import Annotated +from typing_extensions import TypedDict + +from foundry._core import ApiClient +from foundry._core import Auth +from foundry._core import RequestInfo +from foundry._core import ResourceIterator +from foundry._core.utils import maybe_ignore_preview +from foundry._errors import handle_unexpected +from foundry.v2.core.models._page_size import PageSize +from foundry.v2.core.models._page_token import PageToken +from foundry.v2.core.models._preview_mode import PreviewMode +from foundry.v2.filesystem.models._list_resource_roles_response import ( + ListResourceRolesResponse, +) # NOQA +from foundry.v2.filesystem.models._resource_rid import ResourceRid +from foundry.v2.filesystem.models._resource_role import ResourceRole +from foundry.v2.filesystem.models._resource_role_dict import ResourceRoleDict + + +class ResourceRoleClient: + def __init__(self, auth: Auth, hostname: str) -> None: + self._api_client = ApiClient(auth=auth, hostname=hostname) + + @maybe_ignore_preview + @pydantic.validate_call + @handle_unexpected + def add( + self, + resource_rid: ResourceRid, + *, + roles: List[ResourceRoleDict], + preview: Optional[PreviewMode] = None, + request_timeout: Optional[Annotated[pydantic.StrictInt, pydantic.Field(gt=0)]] = None, + ) -> None: + """ + + :param resource_rid: resourceRid + :type resource_rid: ResourceRid + :param roles: + :type roles: List[ResourceRoleDict] + :param preview: preview + :type preview: Optional[PreviewMode] + :param request_timeout: timeout setting for this request in seconds. + :type request_timeout: Optional[int] + :return: Returns the result object. + :rtype: None + """ + + return self._api_client.call_api( + RequestInfo( + method="POST", + resource_path="/v2/filesystem/resources/{resourceRid}/roles/add", + query_params={ + "preview": preview, + }, + path_params={ + "resourceRid": resource_rid, + }, + header_params={ + "Content-Type": "application/json", + }, + body={ + "roles": roles, + }, + body_type=TypedDict( + "Body", + { # type: ignore + "roles": List[ResourceRoleDict], + }, + ), + response_type=None, + request_timeout=request_timeout, + ), + ) + + @maybe_ignore_preview + @pydantic.validate_call + @handle_unexpected + def list( + self, + resource_rid: ResourceRid, + *, + include_inherited: Optional[bool] = None, + page_size: Optional[PageSize] = None, + page_token: Optional[PageToken] = None, + preview: Optional[PreviewMode] = None, + request_timeout: Optional[Annotated[pydantic.StrictInt, pydantic.Field(gt=0)]] = None, + ) -> ResourceIterator[ResourceRole]: + """ + List the roles on a resource. + + :param resource_rid: resourceRid + :type resource_rid: ResourceRid + :param include_inherited: includeInherited + :type include_inherited: Optional[bool] + :param page_size: pageSize + :type page_size: Optional[PageSize] + :param page_token: pageToken + :type page_token: Optional[PageToken] + :param preview: preview + :type preview: Optional[PreviewMode] + :param request_timeout: timeout setting for this request in seconds. + :type request_timeout: Optional[int] + :return: Returns the result object. + :rtype: ResourceIterator[ResourceRole] + """ + + return self._api_client.iterate_api( + RequestInfo( + method="GET", + resource_path="/v2/filesystem/resources/{resourceRid}/roles", + query_params={ + "includeInherited": include_inherited, + "pageSize": page_size, + "pageToken": page_token, + "preview": preview, + }, + path_params={ + "resourceRid": resource_rid, + }, + header_params={ + "Accept": "application/json", + }, + body=None, + body_type=None, + response_type=ListResourceRolesResponse, + request_timeout=request_timeout, + ), + ) + + @maybe_ignore_preview + @pydantic.validate_call + @handle_unexpected + def page( + self, + resource_rid: ResourceRid, + *, + include_inherited: Optional[bool] = None, + page_size: Optional[PageSize] = None, + page_token: Optional[PageToken] = None, + preview: Optional[PreviewMode] = None, + request_timeout: Optional[Annotated[pydantic.StrictInt, pydantic.Field(gt=0)]] = None, + ) -> ListResourceRolesResponse: + """ + List the roles on a resource. + + :param resource_rid: resourceRid + :type resource_rid: ResourceRid + :param include_inherited: includeInherited + :type include_inherited: Optional[bool] + :param page_size: pageSize + :type page_size: Optional[PageSize] + :param page_token: pageToken + :type page_token: Optional[PageToken] + :param preview: preview + :type preview: Optional[PreviewMode] + :param request_timeout: timeout setting for this request in seconds. + :type request_timeout: Optional[int] + :return: Returns the result object. + :rtype: ListResourceRolesResponse + """ + + warnings.warn( + "The ResourceRoleClient.page(...) method has been deprecated. Please use ResourceRoleClient.list(...) instead.", + DeprecationWarning, + ) + + return self._api_client.call_api( + RequestInfo( + method="GET", + resource_path="/v2/filesystem/resources/{resourceRid}/roles", + query_params={ + "includeInherited": include_inherited, + "pageSize": page_size, + "pageToken": page_token, + "preview": preview, + }, + path_params={ + "resourceRid": resource_rid, + }, + header_params={ + "Accept": "application/json", + }, + body=None, + body_type=None, + response_type=ListResourceRolesResponse, + request_timeout=request_timeout, + ), + ) + + @maybe_ignore_preview + @pydantic.validate_call + @handle_unexpected + def remove( + self, + resource_rid: ResourceRid, + *, + roles: List[ResourceRoleDict], + preview: Optional[PreviewMode] = None, + request_timeout: Optional[Annotated[pydantic.StrictInt, pydantic.Field(gt=0)]] = None, + ) -> None: + """ + + :param resource_rid: resourceRid + :type resource_rid: ResourceRid + :param roles: + :type roles: List[ResourceRoleDict] + :param preview: preview + :type preview: Optional[PreviewMode] + :param request_timeout: timeout setting for this request in seconds. + :type request_timeout: Optional[int] + :return: Returns the result object. + :rtype: None + """ + + return self._api_client.call_api( + RequestInfo( + method="POST", + resource_path="/v2/filesystem/resources/{resourceRid}/roles/remove", + query_params={ + "preview": preview, + }, + path_params={ + "resourceRid": resource_rid, + }, + header_params={ + "Content-Type": "application/json", + }, + body={ + "roles": roles, + }, + body_type=TypedDict( + "Body", + { # type: ignore + "roles": List[ResourceRoleDict], + }, + ), + response_type=None, + request_timeout=request_timeout, + ), + )