From 15127abb8ab299907925c41e89122d50dbe138d5 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 26 May 2026 15:18:29 +0000 Subject: [PATCH 1/2] [fern-generated] Update SDK Generated by Fern CLI Version: unknown Generators: - fernapi/fern-python-sdk: 5.14.3 --- reference.md | 1398 ++++++++++++++++- src/auth0/management/__init__.py | 62 +- src/auth0/management/core/client_wrapper.py | 22 +- .../management/core/pydantic_utilities.py | 16 +- .../management/organizations/__init__.py | 13 +- src/auth0/management/organizations/client.py | 19 + .../organizations/groups/__init__.py | 34 + .../management/organizations/groups/client.py | 176 +++ .../organizations/groups/raw_client.py | 254 +++ .../organizations/groups/roles/__init__.py | 4 + .../organizations/groups/roles/client.py | 366 +++++ .../organizations/groups/roles/raw_client.py | 679 ++++++++ .../organizations/members/__init__.py | 6 +- .../organizations/members/client.py | 19 + .../members/effective_roles/__init__.py | 34 + .../members/effective_roles/client.py | 188 +++ .../members/effective_roles/raw_client.py | 266 ++++ .../effective_roles/sources/__init__.py | 34 + .../members/effective_roles/sources/client.py | 63 + .../sources/groups/__init__.py | 4 + .../effective_roles/sources/groups/client.py | 179 +++ .../sources/groups/raw_client.py | 278 ++++ .../effective_roles/sources/raw_client.py | 13 + src/auth0/management/roles/__init__.py | 6 +- src/auth0/management/roles/client.py | 19 + src/auth0/management/roles/groups/__init__.py | 4 + src/auth0/management/roles/groups/client.py | 314 ++++ .../management/roles/groups/raw_client.py | 637 ++++++++ src/auth0/management/types/__init__.py | 57 + ...ganization_group_roles_response_content.py | 24 + ...st_organization_groups_response_content.py | 24 + ...member_effective_roles_response_content.py | 24 + ...ber_role_source_groups_response_content.py | 24 + .../list_role_groups_response_content.py | 24 + ...ermission_role_sources_response_content.py | 28 + ..._effective_permissions_response_content.py | 28 + ...t_user_effective_roles_response_content.py | 24 + ...ser_role_source_groups_response_content.py | 24 + src/auth0/management/types/oauth_scope.py | 10 + .../organization_member_effective_role.py | 38 + ...ganization_member_effective_role_source.py | 5 + ...r_effective_permission_response_content.py | 43 + ...r_effective_permission_role_source_enum.py | 5 + ...permission_role_source_response_content.py | 38 + .../user_effective_permission_source_enum.py | 5 + .../management/types/user_effective_role.py | 38 + .../types/user_effective_role_source.py | 5 + src/auth0/management/users/__init__.py | 6 + src/auth0/management/users/client.py | 38 + .../users/effective_permissions/__init__.py | 34 + .../users/effective_permissions/client.py | 198 +++ .../users/effective_permissions/raw_client.py | 289 ++++ .../effective_permissions/sources/__init__.py | 34 + .../effective_permissions/sources/client.py | 63 + .../sources/raw_client.py | 13 + .../sources/roles/__init__.py | 4 + .../sources/roles/client.py | 193 +++ .../sources/roles/raw_client.py | 309 ++++ .../users/effective_roles/__init__.py | 34 + .../users/effective_roles/client.py | 176 +++ .../users/effective_roles/raw_client.py | 254 +++ .../users/effective_roles/sources/__init__.py | 34 + .../users/effective_roles/sources/client.py | 63 + .../sources/groups/__init__.py | 4 + .../effective_roles/sources/groups/client.py | 161 ++ .../sources/groups/raw_client.py | 266 ++++ .../effective_roles/sources/raw_client.py | 13 + tests/wire/test_organizations_groups.py | 13 + tests/wire/test_organizations_groups_roles.py | 40 + ...st_organizations_members_effectiveRoles.py | 16 + ...s_members_effectiveRoles_sources_groups.py | 21 + tests/wire/test_roles_groups.py | 35 + tests/wire/test_users_effectivePermissions.py | 20 + ...sers_effectivePermissions_sources_roles.py | 26 + tests/wire/test_users_effectiveRoles.py | 13 + ...est_users_effectiveRoles_sources_groups.py | 20 + wiremock/wiremock-mappings.json | 572 ++++++- 77 files changed, 8428 insertions(+), 109 deletions(-) create mode 100644 src/auth0/management/organizations/groups/__init__.py create mode 100644 src/auth0/management/organizations/groups/client.py create mode 100644 src/auth0/management/organizations/groups/raw_client.py create mode 100644 src/auth0/management/organizations/groups/roles/__init__.py create mode 100644 src/auth0/management/organizations/groups/roles/client.py create mode 100644 src/auth0/management/organizations/groups/roles/raw_client.py create mode 100644 src/auth0/management/organizations/members/effective_roles/__init__.py create mode 100644 src/auth0/management/organizations/members/effective_roles/client.py create mode 100644 src/auth0/management/organizations/members/effective_roles/raw_client.py create mode 100644 src/auth0/management/organizations/members/effective_roles/sources/__init__.py create mode 100644 src/auth0/management/organizations/members/effective_roles/sources/client.py create mode 100644 src/auth0/management/organizations/members/effective_roles/sources/groups/__init__.py create mode 100644 src/auth0/management/organizations/members/effective_roles/sources/groups/client.py create mode 100644 src/auth0/management/organizations/members/effective_roles/sources/groups/raw_client.py create mode 100644 src/auth0/management/organizations/members/effective_roles/sources/raw_client.py create mode 100644 src/auth0/management/roles/groups/__init__.py create mode 100644 src/auth0/management/roles/groups/client.py create mode 100644 src/auth0/management/roles/groups/raw_client.py create mode 100644 src/auth0/management/types/list_organization_group_roles_response_content.py create mode 100644 src/auth0/management/types/list_organization_groups_response_content.py create mode 100644 src/auth0/management/types/list_organization_member_effective_roles_response_content.py create mode 100644 src/auth0/management/types/list_organization_member_role_source_groups_response_content.py create mode 100644 src/auth0/management/types/list_role_groups_response_content.py create mode 100644 src/auth0/management/types/list_user_effective_permission_role_sources_response_content.py create mode 100644 src/auth0/management/types/list_user_effective_permissions_response_content.py create mode 100644 src/auth0/management/types/list_user_effective_roles_response_content.py create mode 100644 src/auth0/management/types/list_user_role_source_groups_response_content.py create mode 100644 src/auth0/management/types/organization_member_effective_role.py create mode 100644 src/auth0/management/types/organization_member_effective_role_source.py create mode 100644 src/auth0/management/types/user_effective_permission_response_content.py create mode 100644 src/auth0/management/types/user_effective_permission_role_source_enum.py create mode 100644 src/auth0/management/types/user_effective_permission_role_source_response_content.py create mode 100644 src/auth0/management/types/user_effective_permission_source_enum.py create mode 100644 src/auth0/management/types/user_effective_role.py create mode 100644 src/auth0/management/types/user_effective_role_source.py create mode 100644 src/auth0/management/users/effective_permissions/__init__.py create mode 100644 src/auth0/management/users/effective_permissions/client.py create mode 100644 src/auth0/management/users/effective_permissions/raw_client.py create mode 100644 src/auth0/management/users/effective_permissions/sources/__init__.py create mode 100644 src/auth0/management/users/effective_permissions/sources/client.py create mode 100644 src/auth0/management/users/effective_permissions/sources/raw_client.py create mode 100644 src/auth0/management/users/effective_permissions/sources/roles/__init__.py create mode 100644 src/auth0/management/users/effective_permissions/sources/roles/client.py create mode 100644 src/auth0/management/users/effective_permissions/sources/roles/raw_client.py create mode 100644 src/auth0/management/users/effective_roles/__init__.py create mode 100644 src/auth0/management/users/effective_roles/client.py create mode 100644 src/auth0/management/users/effective_roles/raw_client.py create mode 100644 src/auth0/management/users/effective_roles/sources/__init__.py create mode 100644 src/auth0/management/users/effective_roles/sources/client.py create mode 100644 src/auth0/management/users/effective_roles/sources/groups/__init__.py create mode 100644 src/auth0/management/users/effective_roles/sources/groups/client.py create mode 100644 src/auth0/management/users/effective_roles/sources/groups/raw_client.py create mode 100644 src/auth0/management/users/effective_roles/sources/raw_client.py create mode 100644 tests/wire/test_organizations_groups.py create mode 100644 tests/wire/test_organizations_groups_roles.py create mode 100644 tests/wire/test_organizations_members_effectiveRoles.py create mode 100644 tests/wire/test_organizations_members_effectiveRoles_sources_groups.py create mode 100644 tests/wire/test_roles_groups.py create mode 100644 tests/wire/test_users_effectivePermissions.py create mode 100644 tests/wire/test_users_effectivePermissions_sources_roles.py create mode 100644 tests/wire/test_users_effectiveRoles.py create mode 100644 tests/wire/test_users_effectiveRoles_sources_groups.py diff --git a/reference.md b/reference.md index cc537eb3..3a1d33a2 100644 --- a/reference.md +++ b/reference.md @@ -32601,6 +32601,486 @@ client.organizations.members.delete( + + + + +## Organizations Groups +
client.organizations.groups.list(...) -> ListOrganizationGroupsResponseContent +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Lists the groups that are assigned to the specified organization. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.organizations.groups.list( + organization_id="organization_id", + from_="from", + take=1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**organization_id:** `str` — ID of the organization + +
+
+ +
+
+ +**from:** `typing.Optional[str]` — Optional Id from which to start selection. + +
+
+ +
+
+ +**take:** `typing.Optional[int]` — Number of results per page. Defaults to 50. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Organizations Groups Roles +
client.organizations.groups.roles.list(...) -> ListOrganizationGroupRolesResponseContent +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Lists the roles assigned to the specified group in the context of an organization. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.organizations.groups.roles.list( + organization_id="organization_id", + group_id="group_id", + from_="from", + take=1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**organization_id:** `str` — ID of the organization + +
+
+ +
+
+ +**group_id:** `str` — ID of the group + +
+
+ +
+
+ +**from:** `typing.Optional[str]` — Optional Id from which to start selection. + +
+
+ +
+
+ +**take:** `typing.Optional[int]` — Number of results per page. Defaults to 50. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.organizations.groups.roles.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Assign one or more roles to a specified group in the context of an organization. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.organizations.groups.roles.create( + organization_id="organization_id", + group_id="group_id", + roles=[ + "roles" + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**organization_id:** `str` — ID of the organization + +
+
+ +
+
+ +**group_id:** `str` — ID of the group + +
+
+ +
+
+ +**roles:** `typing.List[str]` — Array of role IDs to assign to organization group. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.organizations.groups.roles.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Unassign one or more roles from a specified group in the context of an organization. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.organizations.groups.roles.delete( + organization_id="organization_id", + group_id="group_id", + roles=[ + "roles" + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**organization_id:** `str` — ID of the organization + +
+
+ +
+
+ +**group_id:** `str` — ID of the group + +
+
+ +
+
+ +**roles:** `typing.List[str]` — Array of role IDs to delete from organization group. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Organizations Members EffectiveRoles +
client.organizations.members.effective_roles.list(...) -> ListOrganizationMemberEffectiveRolesResponseContent +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Lists the roles assigned to an organization member directly or through group membership. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.organizations.members.effective_roles.list( + id="id", + user_id="user_id", + from_="from", + take=1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — Organization identifier. + +
+
+ +
+
+ +**user_id:** `str` — ID of the user to list effective roles for. + +
+
+ +
+
+ +**from:** `typing.Optional[str]` — Optional Id from which to start selection. + +
+
+ +
+
+ +**take:** `typing.Optional[int]` — Number of results per page. Defaults to 50. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
@@ -32673,15 +33153,110 @@ client.organizations.members.roles.list(
-**user_id:** `str` — ID of the user to associate roles with. - -
-
- +**user_id:** `str` — ID of the user to associate roles with. + + + + +
+
+ +**page:** `typing.Optional[int]` — Page index of the results to return. First page is 0. + +
+
+ +
+
+ +**per_page:** `typing.Optional[int]` — Number of results per page. Defaults to 50. + +
+
+ +
+
+ +**include_totals:** `typing.Optional[bool]` — Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+ + + + + + + + +
client.organizations.members.roles.assign(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Assign one or more roles to a user to determine their access for a specific Organization. + +Users can be members of multiple Organizations with unique roles assigned for each membership. This action assigns roles to a user only for the specified Organization. Roles cannot be assigned to a user across multiple Organizations in the same call. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.organizations.members.roles.assign( + id="id", + user_id="user_id", + roles=[ + "roles" + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+
-**page:** `typing.Optional[int]` — Page index of the results to return. First page is 0. +**id:** `str` — Organization identifier.
@@ -32689,7 +33264,7 @@ client.organizations.members.roles.list(
-**per_page:** `typing.Optional[int]` — Number of results per page. Defaults to 50. +**user_id:** `str` — ID of the user to associate roles with.
@@ -32697,7 +33272,7 @@ client.organizations.members.roles.list(
-**include_totals:** `typing.Optional[bool]` — Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). +**roles:** `typing.List[str]` — List of roles IDs to associated with the user.
@@ -32717,7 +33292,7 @@ client.organizations.members.roles.list(
-
client.organizations.members.roles.assign(...) +
client.organizations.members.roles.delete(...)
@@ -32729,9 +33304,9 @@ client.organizations.members.roles.list(
-Assign one or more roles to a user to determine their access for a specific Organization. +Remove one or more Organization-specific roles from a given user. -Users can be members of multiple Organizations with unique roles assigned for each membership. This action assigns roles to a user only for the specified Organization. Roles cannot be assigned to a user across multiple Organizations in the same call. +Users can be members of multiple Organizations with unique roles assigned for each membership. This action removes roles from a user in relation to the specified Organization. Roles assigned to the user within a different Organization cannot be managed in the same call.
@@ -32754,7 +33329,7 @@ client = Auth0( environment=Auth0Environment.DEFAULT, ) -client.organizations.members.roles.assign( +client.organizations.members.roles.delete( id="id", user_id="user_id", roles=[ @@ -32784,7 +33359,7 @@ client.organizations.members.roles.assign(
-**user_id:** `str` — ID of the user to associate roles with. +**user_id:** `str` — User ID of the organization member to remove roles from.
@@ -32792,7 +33367,7 @@ client.organizations.members.roles.assign(
-**roles:** `typing.List[str]` — List of roles IDs to associated with the user. +**roles:** `typing.List[str]` — List of roles IDs associated with the organization member to remove.
@@ -32812,7 +33387,8 @@ client.organizations.members.roles.assign(
-
client.organizations.members.roles.delete(...) +## Organizations Members EffectiveRoles Sources Groups +
client.organizations.members.effective_roles.sources.groups.list(...) -> ListOrganizationMemberRoleSourceGroupsResponseContent
@@ -32824,9 +33400,7 @@ client.organizations.members.roles.assign(
-Remove one or more Organization-specific roles from a given user. - -Users can be members of multiple Organizations with unique roles assigned for each membership. This action removes roles from a user in relation to the specified Organization. Roles assigned to the user within a different Organization cannot be managed in the same call. +Lists the groups which grant the org member a given role.
@@ -32849,12 +33423,12 @@ client = Auth0( environment=Auth0Environment.DEFAULT, ) -client.organizations.members.roles.delete( +client.organizations.members.effective_roles.sources.groups.list( id="id", user_id="user_id", - roles=[ - "roles" - ], + from_="from", + take=1, + role_id="role_id", ) ``` @@ -32879,7 +33453,7 @@ client.organizations.members.roles.delete(
-**user_id:** `str` — User ID of the organization member to remove roles from. +**user_id:** `str` — ID of the user to list role source groups for.
@@ -32887,7 +33461,23 @@ client.organizations.members.roles.delete(
-**roles:** `typing.List[str]` — List of roles IDs associated with the organization member to remove. +**role_id:** `str` — The role ID to get group sources for. + +
+
+ +
+
+ +**from:** `typing.Optional[str]` — Optional Id from which to start selection. + +
+
+ +
+
+ +**take:** `typing.Optional[int]` — Number of results per page. Defaults to 50.
@@ -33648,11 +34238,212 @@ client.prompts.partials.set(
-**request:** `SetPartialsRequestContent` - -
-
- +**request:** `SetPartialsRequestContent` + + +
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+ + + + + + +
+ +## RiskAssessments Settings +
client.risk_assessments.settings.get() -> GetRiskAssessmentsSettingsResponseContent +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Gets the tenant settings for risk assessments +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.risk_assessments.settings.get() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.risk_assessments.settings.update(...) -> UpdateRiskAssessmentsSettingsResponseContent +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updates the tenant settings for risk assessments +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.risk_assessments.settings.update( + enabled=True, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**enabled:** `bool` — Whether or not risk assessment is enabled. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## RiskAssessments Settings NewDevice +
client.risk_assessments.settings.new_device.get() -> GetRiskAssessmentsSettingsNewDeviceResponseContent +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Gets the risk assessment settings for the new device assessor +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.risk_assessments.settings.new_device.get() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+
@@ -33668,8 +34459,7 @@ client.prompts.partials.set(
-## RiskAssessments Settings -
client.risk_assessments.settings.get() -> GetRiskAssessmentsSettingsResponseContent +
client.risk_assessments.settings.new_device.update(...) -> UpdateRiskAssessmentsSettingsNewDeviceResponseContent
@@ -33681,7 +34471,7 @@ client.prompts.partials.set(
-Gets the tenant settings for risk assessments +Updates the risk assessment settings for the new device assessor
@@ -33704,7 +34494,9 @@ client = Auth0( environment=Auth0Environment.DEFAULT, ) -client.risk_assessments.settings.get() +client.risk_assessments.settings.new_device.update( + remember_for=1, +) ``` @@ -33720,6 +34512,14 @@ client.risk_assessments.settings.get()
+**remember_for:** `int` — Length of time to remember devices for, in days. + +
+
+ +
+
+ **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -33732,7 +34532,8 @@ client.risk_assessments.settings.get()
-
client.risk_assessments.settings.update(...) -> UpdateRiskAssessmentsSettingsResponseContent +## Roles Groups +
client.roles.groups.get(...) -> ListRoleGroupsResponseContent
@@ -33744,7 +34545,7 @@ client.risk_assessments.settings.get()
-Updates the tenant settings for risk assessments +Lists the groups to which the specified role is assigned.
@@ -33767,8 +34568,10 @@ client = Auth0( environment=Auth0Environment.DEFAULT, ) -client.risk_assessments.settings.update( - enabled=True, +client.roles.groups.get( + id="id", + from_="from", + take=1, ) ``` @@ -33785,7 +34588,23 @@ client.risk_assessments.settings.update(
-**enabled:** `bool` — Whether or not risk assessment is enabled. +**id:** `str` — Unique identifier for the role (service-generated). + +
+
+ +
+
+ +**from:** `typing.Optional[str]` — Optional Id from which to start selection. + +
+
+ +
+
+ +**take:** `typing.Optional[int]` — Number of results per page. Defaults to 50.
@@ -33805,8 +34624,7 @@ client.risk_assessments.settings.update(
-## RiskAssessments Settings NewDevice -
client.risk_assessments.settings.new_device.get() -> GetRiskAssessmentsSettingsNewDeviceResponseContent +
client.roles.groups.create(...)
@@ -33818,7 +34636,7 @@ client.risk_assessments.settings.update(
-Gets the risk assessment settings for the new device assessor +Assign one or more groups to a specified role.
@@ -33841,7 +34659,12 @@ client = Auth0( environment=Auth0Environment.DEFAULT, ) -client.risk_assessments.settings.new_device.get() +client.roles.groups.create( + id="id", + groups=[ + "groups" + ], +) ``` @@ -33857,6 +34680,22 @@ client.risk_assessments.settings.new_device.get()
+**id:** `str` — Unique identifier for the role (service-generated). + +
+
+ +
+
+ +**groups:** `typing.List[str]` — Array of group IDs to assign to the role. + +
+
+ +
+
+ **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -33869,7 +34708,7 @@ client.risk_assessments.settings.new_device.get()
-
client.risk_assessments.settings.new_device.update(...) -> UpdateRiskAssessmentsSettingsNewDeviceResponseContent +
client.roles.groups.delete(...)
@@ -33881,7 +34720,7 @@ client.risk_assessments.settings.new_device.get()
-Updates the risk assessment settings for the new device assessor +Unassign one or more groups from a specified role.
@@ -33904,8 +34743,11 @@ client = Auth0( environment=Auth0Environment.DEFAULT, ) -client.risk_assessments.settings.new_device.update( - remember_for=1, +client.roles.groups.delete( + id="id", + groups=[ + "groups" + ], ) ``` @@ -33922,7 +34764,15 @@ client.risk_assessments.settings.new_device.update(
-**remember_for:** `int` — Length of time to remember devices for, in days. +**id:** `str` — Unique identifier for the role (service-generated). + +
+
+ +
+
+ +**groups:** `typing.List[str]` — Array of group IDs to remove from the role.
@@ -35898,7 +36748,180 @@ client.users.authentication_methods.delete(
-Modify the authentication method with the given ID from the specified user. For more information, review Manage Authentication Methods with Management API. +Modify the authentication method with the given ID from the specified user. For more information, review Manage Authentication Methods with Management API. +
+
+ +
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.users.authentication_methods.update( + id="id", + authentication_method_id="authentication_method_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — The ID of the user in question. + +
+
+ +
+
+ +**authentication_method_id:** `str` — The ID of the authentication method to update. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — A human-readable label to identify the authentication method. + +
+
+ +
+
+ +**preferred_authentication_method:** `typing.Optional[PreferredAuthenticationMethodEnum]` — Preferred phone authentication method + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + + + +
+ +## Users Authenticators +
client.users.authenticators.delete_all(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Remove all authenticators registered to a given user ID, such as OTP, email, phone, and push-notification. This action cannot be undone. For more information, review [Manage Authentication Methods with Management API](https://auth0.com/docs/secure/multi-factor-authentication/manage-mfa-auth0-apis/manage-authentication-methods-with-management-api). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.users.authenticators.delete_all( + id="id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — ID of the user to delete. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Users ConnectedAccounts +
client.users.connected_accounts.list(...) -> ListUserConnectedAccountsResponseContent +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve all connected accounts associated with the user.
@@ -35921,9 +36944,10 @@ client = Auth0( environment=Auth0Environment.DEFAULT, ) -client.users.authentication_methods.update( +client.users.connected_accounts.list( id="id", - authentication_method_id="authentication_method_id", + from_="from", + take=1, ) ``` @@ -35940,15 +36964,7 @@ client.users.authentication_methods.update(
-**id:** `str` — The ID of the user in question. - -
-
- -
-
- -**authentication_method_id:** `str` — The ID of the authentication method to update. +**id:** `str` — ID of the user to list connected accounts for.
@@ -35956,7 +36972,7 @@ client.users.authentication_methods.update(
-**name:** `typing.Optional[str]` — A human-readable label to identify the authentication method. +**from:** `typing.Optional[str]` — Optional Id from which to start selection.
@@ -35964,7 +36980,7 @@ client.users.authentication_methods.update(
-**preferred_authentication_method:** `typing.Optional[PreferredAuthenticationMethodEnum]` — Preferred phone authentication method +**take:** `typing.Optional[int]` — Number of results to return. Defaults to 10 with a maximum of 20
@@ -35984,8 +37000,8 @@ client.users.authentication_methods.update(
-## Users Authenticators -
client.users.authenticators.delete_all(...) +## Users EffectivePermissions +
client.users.effective_permissions.list(...) -> ListUserEffectivePermissionsResponseContent
@@ -35997,7 +37013,7 @@ client.users.authentication_methods.update(
-Remove all authenticators registered to a given user ID, such as OTP, email, phone, and push-notification. This action cannot be undone. For more information, review [Manage Authentication Methods with Management API](https://auth0.com/docs/secure/multi-factor-authentication/manage-mfa-auth0-apis/manage-authentication-methods-with-management-api). +Returns the list of effective permissions for a user, taking into account permissions granted directly to the user, as well as those inherited through roles and group memberships.
@@ -36020,8 +37036,11 @@ client = Auth0( environment=Auth0Environment.DEFAULT, ) -client.users.authenticators.delete_all( +client.users.effective_permissions.list( id="id", + from_="from", + take=1, + resource_server_identifier="resource_server_identifier", ) ``` @@ -36038,7 +37057,31 @@ client.users.authenticators.delete_all(
-**id:** `str` — ID of the user to delete. +**id:** `str` — ID of the user to retrieve the permissions for. + +
+
+ +
+
+ +**resource_server_identifier:** `str` — The identifier of the resource server for which to calculate user permissions. + +
+
+ +
+
+ +**from:** `typing.Optional[str]` — Optional Id from which to start selection. + +
+
+ +
+
+ +**take:** `typing.Optional[int]` — Number of results per page. Defaults to 50.
@@ -36058,8 +37101,8 @@ client.users.authenticators.delete_all(
-## Users ConnectedAccounts -
client.users.connected_accounts.list(...) -> ListUserConnectedAccountsResponseContent +## Users EffectiveRoles +
client.users.effective_roles.list(...) -> ListUserEffectiveRolesResponseContent
@@ -36071,7 +37114,7 @@ client.users.authenticators.delete_all(
-Retrieve all connected accounts associated with the user. +Retrieve detailed list of effective roles for a user, including roles assigned directly and through group memberships.
@@ -36094,7 +37137,7 @@ client = Auth0( environment=Auth0Environment.DEFAULT, ) -client.users.connected_accounts.list( +client.users.effective_roles.list( id="id", from_="from", take=1, @@ -36114,7 +37157,7 @@ client.users.connected_accounts.list(
-**id:** `str` — ID of the user to list connected accounts for. +**id:** `str` — ID of the user to list effective roles for.
@@ -36130,7 +37173,7 @@ client.users.connected_accounts.list(
-**take:** `typing.Optional[int]` — Number of results to return. Defaults to 10 with a maximum of 20 +**take:** `typing.Optional[int]` — Number of results per page. Defaults to 50.
@@ -38046,6 +39089,217 @@ client.users.sessions.delete(
+ + +
+ +## Users EffectivePermissions Sources Roles +
client.users.effective_permissions.sources.roles.list(...) -> ListUserEffectivePermissionRoleSourcesResponseContent +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Lists the roles which grant the user a given permission, including roles assigned directly to the user and those inherited through group memberships. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.users.effective_permissions.sources.roles.list( + id="id", + from_="from", + take=1, + resource_server_identifier="resource_server_identifier", + permission_name="permission_name", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — ID of the user to retrieve the permissions for. + +
+
+ +
+
+ +**resource_server_identifier:** `str` — The identifier of the resource server for which to calculate user permissions. + +
+
+ +
+
+ +**permission_name:** `str` — Name of this permission + +
+
+ +
+
+ +**from:** `typing.Optional[str]` — Optional Id from which to start selection. + +
+
+ +
+
+ +**take:** `typing.Optional[int]` — Number of results per page. Defaults to 50. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Users EffectiveRoles Sources Groups +
client.users.effective_roles.sources.groups.list(...) -> ListUserRoleSourceGroupsResponseContent +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Lists the groups that grant a user a specific role. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from auth0.management import Auth0 +from auth0.management.environment import Auth0Environment + +client = Auth0( + token="", + environment=Auth0Environment.DEFAULT, +) + +client.users.effective_roles.sources.groups.list( + id="id", + role_id="role_id", + from_="from", + take=1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — ID of the user to list role source groups for. + +
+
+ +
+
+ +**role_id:** `str` — ID of the role to get source groups for. + +
+
+ +
+
+ +**from:** `typing.Optional[str]` — Optional Id from which to start selection. + +
+
+ +
+
+ +**take:** `typing.Optional[int]` — Number of results per page. Defaults to 50. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
diff --git a/src/auth0/management/__init__.py b/src/auth0/management/__init__.py index ecd00f0b..a48ff10f 100644 --- a/src/auth0/management/__init__.py +++ b/src/auth0/management/__init__.py @@ -2198,7 +2198,11 @@ ListOrganizationClientGrantsOffsetPaginatedResponseContent, ListOrganizationConnectionsOffsetPaginatedResponseContent, ListOrganizationDiscoveryDomainsResponseContent, + ListOrganizationGroupRolesResponseContent, + ListOrganizationGroupsResponseContent, ListOrganizationInvitationsOffsetPaginatedResponseContent, + ListOrganizationMemberEffectiveRolesResponseContent, + ListOrganizationMemberRoleSourceGroupsResponseContent, ListOrganizationMemberRolesOffsetPaginatedResponseContent, ListOrganizationMembersPaginatedResponseContent, ListOrganizationsPaginatedResponseContent, @@ -2206,6 +2210,7 @@ ListRateLimitPoliciesPaginatedResponseContent, ListRefreshTokensPaginatedResponseContent, ListResourceServerOffsetPaginatedResponseContent, + ListRoleGroupsResponseContent, ListRolePermissionsOffsetPaginatedResponseContent, ListRoleUsersPaginatedResponseContent, ListRolesOffsetPaginatedResponseContent, @@ -2221,9 +2226,13 @@ ListUserBlocksByIdentifierResponseContent, ListUserBlocksResponseContent, ListUserConnectedAccountsResponseContent, + ListUserEffectivePermissionRoleSourcesResponseContent, + ListUserEffectivePermissionsResponseContent, + ListUserEffectiveRolesResponseContent, ListUserGrantsOffsetPaginatedResponseContent, ListUserOrganizationsOffsetPaginatedResponseContent, ListUserPermissionsOffsetPaginatedResponseContent, + ListUserRoleSourceGroupsResponseContent, ListUserRolesOffsetPaginatedResponseContent, ListUserSessionsPaginatedResponseContent, ListUsersOffsetPaginatedResponseContent, @@ -2313,6 +2322,8 @@ OrganizationInvitationInvitee, OrganizationInvitationInviter, OrganizationMember, + OrganizationMemberEffectiveRole, + OrganizationMemberEffectiveRoleSource, OrganizationMemberRole, OrganizationMetadata, OrganizationUsageEnum, @@ -2674,6 +2685,12 @@ UserAuthenticationMethodPropertiesEnum, UserBlockIdentifier, UserDateSchema, + UserEffectivePermissionResponseContent, + UserEffectivePermissionRoleSourceEnum, + UserEffectivePermissionRoleSourceResponseContent, + UserEffectivePermissionSourceEnum, + UserEffectiveRole, + UserEffectiveRoleSource, UserEnrollmentAuthMethodEnum, UserEnrollmentStatusEnum, UserGrant, @@ -2766,8 +2783,6 @@ from .environment import Auth0Environment from .event_streams import EventStreamsCreateRequest from .version import __version__ - from .management_client import AsyncManagementClient, CustomDomainHeader, ManagementClient - from .token_provider import AsyncTokenProvider, TokenProvider _dynamic_imports: typing.Dict[str, str] = { "Action": ".types", "ActionBase": ".types", @@ -2828,8 +2843,6 @@ "AssociateOrganizationClientGrantResponseContent": ".types", "AsyncApprovalNotificationsChannelsEnum": ".types", "AsyncAuth0": ".client", - "AsyncManagementClient": ".management_client", - "AsyncTokenProvider": ".token_provider", "AttackProtectionCaptchaArkoseResponseContent": ".types", "AttackProtectionCaptchaAuthChallengeRequest": ".types", "AttackProtectionCaptchaAuthChallengeResponseContent": ".types", @@ -3789,7 +3802,6 @@ "CredentialDeviceTypeEnum": ".types", "CredentialId": ".types", "CustomDomain": ".types", - "CustomDomainHeader": ".management_client", "CustomDomainCustomClientIpHeader": ".types", "CustomDomainCustomClientIpHeaderEnum": ".types", "CustomDomainProvisioningTypeEnum": ".types", @@ -4975,7 +4987,11 @@ "ListOrganizationClientGrantsOffsetPaginatedResponseContent": ".types", "ListOrganizationConnectionsOffsetPaginatedResponseContent": ".types", "ListOrganizationDiscoveryDomainsResponseContent": ".types", + "ListOrganizationGroupRolesResponseContent": ".types", + "ListOrganizationGroupsResponseContent": ".types", "ListOrganizationInvitationsOffsetPaginatedResponseContent": ".types", + "ListOrganizationMemberEffectiveRolesResponseContent": ".types", + "ListOrganizationMemberRoleSourceGroupsResponseContent": ".types", "ListOrganizationMemberRolesOffsetPaginatedResponseContent": ".types", "ListOrganizationMembersPaginatedResponseContent": ".types", "ListOrganizationsPaginatedResponseContent": ".types", @@ -4983,6 +4999,7 @@ "ListRateLimitPoliciesPaginatedResponseContent": ".types", "ListRefreshTokensPaginatedResponseContent": ".types", "ListResourceServerOffsetPaginatedResponseContent": ".types", + "ListRoleGroupsResponseContent": ".types", "ListRolePermissionsOffsetPaginatedResponseContent": ".types", "ListRoleUsersPaginatedResponseContent": ".types", "ListRolesOffsetPaginatedResponseContent": ".types", @@ -4998,9 +5015,13 @@ "ListUserBlocksByIdentifierResponseContent": ".types", "ListUserBlocksResponseContent": ".types", "ListUserConnectedAccountsResponseContent": ".types", + "ListUserEffectivePermissionRoleSourcesResponseContent": ".types", + "ListUserEffectivePermissionsResponseContent": ".types", + "ListUserEffectiveRolesResponseContent": ".types", "ListUserGrantsOffsetPaginatedResponseContent": ".types", "ListUserOrganizationsOffsetPaginatedResponseContent": ".types", "ListUserPermissionsOffsetPaginatedResponseContent": ".types", + "ListUserRoleSourceGroupsResponseContent": ".types", "ListUserRolesOffsetPaginatedResponseContent": ".types", "ListUserSessionsPaginatedResponseContent": ".types", "ListUsersOffsetPaginatedResponseContent": ".types", @@ -5052,7 +5073,6 @@ "LogStreamSumoEnum": ".types", "LogStreamSumoResponseSchema": ".types", "LogStreamSumoSink": ".types", - "ManagementClient": ".management_client", "MdlPresentationProperties": ".types", "MdlPresentationRequest": ".types", "MdlPresentationRequestProperties": ".types", @@ -5092,6 +5112,8 @@ "OrganizationInvitationInvitee": ".types", "OrganizationInvitationInviter": ".types", "OrganizationMember": ".types", + "OrganizationMemberEffectiveRole": ".types", + "OrganizationMemberEffectiveRoleSource": ".types", "OrganizationMemberRole": ".types", "OrganizationMetadata": ".types", "OrganizationUsageEnum": ".types", @@ -5296,7 +5318,6 @@ "TokenQuota": ".types", "TokenQuotaClientCredentials": ".types", "TokenQuotaConfiguration": ".types", - "TokenProvider": ".token_provider", "TooManyRequestsError": ".errors", "TooManyRequestsSchema": ".types", "TooManyRequestsSchemaError": ".types", @@ -5459,6 +5480,12 @@ "UserAuthenticationMethodPropertiesEnum": ".types", "UserBlockIdentifier": ".types", "UserDateSchema": ".types", + "UserEffectivePermissionResponseContent": ".types", + "UserEffectivePermissionRoleSourceEnum": ".types", + "UserEffectivePermissionRoleSourceResponseContent": ".types", + "UserEffectivePermissionSourceEnum": ".types", + "UserEffectiveRole": ".types", + "UserEffectiveRoleSource": ".types", "UserEnrollmentAuthMethodEnum": ".types", "UserEnrollmentStatusEnum": ".types", "UserGrant": ".types", @@ -5614,8 +5641,6 @@ def __dir__(): "AssociateOrganizationClientGrantResponseContent", "AsyncApprovalNotificationsChannelsEnum", "AsyncAuth0", - "AsyncManagementClient", - "AsyncTokenProvider", "AttackProtectionCaptchaArkoseResponseContent", "AttackProtectionCaptchaAuthChallengeRequest", "AttackProtectionCaptchaAuthChallengeResponseContent", @@ -7760,7 +7785,11 @@ def __dir__(): "ListOrganizationClientGrantsOffsetPaginatedResponseContent", "ListOrganizationConnectionsOffsetPaginatedResponseContent", "ListOrganizationDiscoveryDomainsResponseContent", + "ListOrganizationGroupRolesResponseContent", + "ListOrganizationGroupsResponseContent", "ListOrganizationInvitationsOffsetPaginatedResponseContent", + "ListOrganizationMemberEffectiveRolesResponseContent", + "ListOrganizationMemberRoleSourceGroupsResponseContent", "ListOrganizationMemberRolesOffsetPaginatedResponseContent", "ListOrganizationMembersPaginatedResponseContent", "ListOrganizationsPaginatedResponseContent", @@ -7768,6 +7797,7 @@ def __dir__(): "ListRateLimitPoliciesPaginatedResponseContent", "ListRefreshTokensPaginatedResponseContent", "ListResourceServerOffsetPaginatedResponseContent", + "ListRoleGroupsResponseContent", "ListRolePermissionsOffsetPaginatedResponseContent", "ListRoleUsersPaginatedResponseContent", "ListRolesOffsetPaginatedResponseContent", @@ -7783,9 +7813,13 @@ def __dir__(): "ListUserBlocksByIdentifierResponseContent", "ListUserBlocksResponseContent", "ListUserConnectedAccountsResponseContent", + "ListUserEffectivePermissionRoleSourcesResponseContent", + "ListUserEffectivePermissionsResponseContent", + "ListUserEffectiveRolesResponseContent", "ListUserGrantsOffsetPaginatedResponseContent", "ListUserOrganizationsOffsetPaginatedResponseContent", "ListUserPermissionsOffsetPaginatedResponseContent", + "ListUserRoleSourceGroupsResponseContent", "ListUserRolesOffsetPaginatedResponseContent", "ListUserSessionsPaginatedResponseContent", "ListUsersOffsetPaginatedResponseContent", @@ -7837,7 +7871,6 @@ def __dir__(): "LogStreamSumoEnum", "LogStreamSumoResponseSchema", "LogStreamSumoSink", - "ManagementClient", "MdlPresentationProperties", "MdlPresentationRequest", "MdlPresentationRequestProperties", @@ -7877,6 +7910,8 @@ def __dir__(): "OrganizationInvitationInvitee", "OrganizationInvitationInviter", "OrganizationMember", + "OrganizationMemberEffectiveRole", + "OrganizationMemberEffectiveRoleSource", "OrganizationMemberRole", "OrganizationMetadata", "OrganizationUsageEnum", @@ -8078,7 +8113,6 @@ def __dir__(): "TestEventDataContent", "TokenExchangeProfileResponseContent", "TokenExchangeProfileTypeEnum", - "TokenProvider", "TokenQuota", "TokenQuotaClientCredentials", "TokenQuotaConfiguration", @@ -8244,6 +8278,12 @@ def __dir__(): "UserAuthenticationMethodPropertiesEnum", "UserBlockIdentifier", "UserDateSchema", + "UserEffectivePermissionResponseContent", + "UserEffectivePermissionRoleSourceEnum", + "UserEffectivePermissionRoleSourceResponseContent", + "UserEffectivePermissionSourceEnum", + "UserEffectiveRole", + "UserEffectiveRoleSource", "UserEnrollmentAuthMethodEnum", "UserEnrollmentStatusEnum", "UserGrant", diff --git a/src/auth0/management/core/client_wrapper.py b/src/auth0/management/core/client_wrapper.py index 60ebc5a6..cad2e314 100644 --- a/src/auth0/management/core/client_wrapper.py +++ b/src/auth0/management/core/client_wrapper.py @@ -1,11 +1,6 @@ # This file was auto-generated by Fern from our API Definition. -# Modified by Auth0 to use Auth0 telemetry format with dynamic versioning -import base64 -import platform -import sys import typing -from json import dumps import httpx from .http_client import AsyncHttpClient, HttpClient @@ -31,18 +26,15 @@ def __init__( self._logging = logging def get_headers(self) -> typing.Dict[str, str]: - py_version = platform.python_version() - version = sys.modules["auth0"].__version__ - - auth0_client = dumps({ - "name": "auth0-python", - "version": version, - "env": {"python": py_version} - }).encode("utf-8") + import platform headers: typing.Dict[str, str] = { - "User-Agent": f"Python/{py_version}", - "Auth0-Client": base64.b64encode(auth0_client).decode(), + "User-Agent": "auth0-python/5.5.0", + "X-Fern-Language": "Python", + "X-Fern-Runtime": f"python/{platform.python_version()}", + "X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}", + "X-Fern-SDK-Name": "auth0-python", + "X-Fern-SDK-Version": "5.5.0", **(self.get_custom_headers() or {}), } headers["Authorization"] = f"Bearer {self._get_token()}" diff --git a/src/auth0/management/core/pydantic_utilities.py b/src/auth0/management/core/pydantic_utilities.py index fea3a08d..df3e720d 100644 --- a/src/auth0/management/core/pydantic_utilities.py +++ b/src/auth0/management/core/pydantic_utilities.py @@ -310,6 +310,18 @@ def parse_sse_obj(sse: "ServerSentEvent", type_: Type[T]) -> T: return parse_obj_as(type_, sse_event) +_type_adapter_cache: Dict[int, Any] = {} + + +def _get_type_adapter(type_: Type[Any]) -> Any: + key = id(type_) + adapter = _type_adapter_cache.get(key) + if adapter is None: + adapter = pydantic.TypeAdapter(type_) # type: ignore[attr-defined] + _type_adapter_cache[key] = adapter + return adapter + + def parse_obj_as(type_: Type[T], object_: Any) -> T: # convert_and_respect_annotation_metadata is required for TypedDict aliasing. # @@ -342,8 +354,8 @@ def parse_obj_as(type_: Type[T], object_: Any) -> T: else: dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") if IS_PYDANTIC_V2: - adapter = pydantic.TypeAdapter(type_) # type: ignore[attr-defined] - return adapter.validate_python(dealiased_object) + adapter = _get_type_adapter(type_) + return adapter.validate_python(dealiased_object) # type: ignore[no-any-return] return pydantic.parse_obj_as(type_, dealiased_object) diff --git a/src/auth0/management/organizations/__init__.py b/src/auth0/management/organizations/__init__.py index 8f9c49df..ca170602 100644 --- a/src/auth0/management/organizations/__init__.py +++ b/src/auth0/management/organizations/__init__.py @@ -6,12 +6,13 @@ from importlib import import_module if typing.TYPE_CHECKING: - from . import client_grants, connections, discovery_domains, enabled_connections, invitations, members + from . import client_grants, connections, discovery_domains, enabled_connections, groups, invitations, members _dynamic_imports: typing.Dict[str, str] = { "client_grants": ".client_grants", "connections": ".connections", "discovery_domains": ".discovery_domains", "enabled_connections": ".enabled_connections", + "groups": ".groups", "invitations": ".invitations", "members": ".members", } @@ -38,4 +39,12 @@ def __dir__(): return sorted(lazy_attrs) -__all__ = ["client_grants", "connections", "discovery_domains", "enabled_connections", "invitations", "members"] +__all__ = [ + "client_grants", + "connections", + "discovery_domains", + "enabled_connections", + "groups", + "invitations", + "members", +] diff --git a/src/auth0/management/organizations/client.py b/src/auth0/management/organizations/client.py index 5d8136f4..0e867bda 100644 --- a/src/auth0/management/organizations/client.py +++ b/src/auth0/management/organizations/client.py @@ -25,6 +25,7 @@ from .connections.client import AsyncConnectionsClient, ConnectionsClient from .discovery_domains.client import AsyncDiscoveryDomainsClient, DiscoveryDomainsClient from .enabled_connections.client import AsyncEnabledConnectionsClient, EnabledConnectionsClient + from .groups.client import AsyncGroupsClient, GroupsClient from .invitations.client import AsyncInvitationsClient, InvitationsClient from .members.client import AsyncMembersClient, MembersClient # this is used as the default value for optional parameters @@ -41,6 +42,7 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._enabled_connections: typing.Optional[EnabledConnectionsClient] = None self._invitations: typing.Optional[InvitationsClient] = None self._members: typing.Optional[MembersClient] = None + self._groups: typing.Optional[GroupsClient] = None @property def with_raw_response(self) -> RawOrganizationsClient: @@ -389,6 +391,14 @@ def members(self): self._members = MembersClient(client_wrapper=self._client_wrapper) return self._members + @property + def groups(self): + if self._groups is None: + from .groups.client import GroupsClient # noqa: E402 + + self._groups = GroupsClient(client_wrapper=self._client_wrapper) + return self._groups + class AsyncOrganizationsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -400,6 +410,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._enabled_connections: typing.Optional[AsyncEnabledConnectionsClient] = None self._invitations: typing.Optional[AsyncInvitationsClient] = None self._members: typing.Optional[AsyncMembersClient] = None + self._groups: typing.Optional[AsyncGroupsClient] = None @property def with_raw_response(self) -> AsyncRawOrganizationsClient: @@ -796,3 +807,11 @@ def members(self): self._members = AsyncMembersClient(client_wrapper=self._client_wrapper) return self._members + + @property + def groups(self): + if self._groups is None: + from .groups.client import AsyncGroupsClient # noqa: E402 + + self._groups = AsyncGroupsClient(client_wrapper=self._client_wrapper) + return self._groups diff --git a/src/auth0/management/organizations/groups/__init__.py b/src/auth0/management/organizations/groups/__init__.py new file mode 100644 index 00000000..686aa754 --- /dev/null +++ b/src/auth0/management/organizations/groups/__init__.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import roles +_dynamic_imports: typing.Dict[str, str] = {"roles": ".roles"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + + +__all__ = ["roles"] diff --git a/src/auth0/management/organizations/groups/client.py b/src/auth0/management/organizations/groups/client.py new file mode 100644 index 00000000..c267a4ee --- /dev/null +++ b/src/auth0/management/organizations/groups/client.py @@ -0,0 +1,176 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.pagination import AsyncPager, SyncPager +from ...core.request_options import RequestOptions +from ...types.group import Group +from ...types.list_organization_groups_response_content import ListOrganizationGroupsResponseContent +from .raw_client import AsyncRawGroupsClient, RawGroupsClient + +if typing.TYPE_CHECKING: + from .roles.client import AsyncRolesClient, RolesClient + + +class GroupsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawGroupsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._roles: typing.Optional[RolesClient] = None + + @property + def with_raw_response(self) -> RawGroupsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawGroupsClient + """ + return self._raw_client + + def list( + self, + organization_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Group, ListOrganizationGroupsResponseContent]: + """ + Lists the groups that are assigned to the specified organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Group, ListOrganizationGroupsResponseContent] + Organization groups successfully retrieved. + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + response = client.organizations.groups.list( + organization_id="organization_id", + from_="from", + take=1, + ) + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.list(organization_id, from_=from_, take=take, request_options=request_options) + + @property + def roles(self): + if self._roles is None: + from .roles.client import RolesClient # noqa: E402 + + self._roles = RolesClient(client_wrapper=self._client_wrapper) + return self._roles + + +class AsyncGroupsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._roles: typing.Optional[AsyncRolesClient] = None + + @property + def with_raw_response(self) -> AsyncRawGroupsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawGroupsClient + """ + return self._raw_client + + async def list( + self, + organization_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Group, ListOrganizationGroupsResponseContent]: + """ + Lists the groups that are assigned to the specified organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Group, ListOrganizationGroupsResponseContent] + Organization groups successfully retrieved. + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + response = await client.organizations.groups.list( + organization_id="organization_id", + from_="from", + take=1, + ) + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.list(organization_id, from_=from_, take=take, request_options=request_options) + + @property + def roles(self): + if self._roles is None: + from .roles.client import AsyncRolesClient # noqa: E402 + + self._roles = AsyncRolesClient(client_wrapper=self._client_wrapper) + return self._roles diff --git a/src/auth0/management/organizations/groups/raw_client.py b/src/auth0/management/organizations/groups/raw_client.py new file mode 100644 index 00000000..e883ffca --- /dev/null +++ b/src/auth0/management/organizations/groups/raw_client.py @@ -0,0 +1,254 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.jsonable_encoder import encode_path_param +from ...core.pagination import AsyncPager, SyncPager +from ...core.parse_error import ParsingError +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...errors.bad_request_error import BadRequestError +from ...errors.forbidden_error import ForbiddenError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError +from ...types.group import Group +from ...types.list_organization_groups_response_content import ListOrganizationGroupsResponseContent +from pydantic import ValidationError + + +class RawGroupsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + organization_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Group, ListOrganizationGroupsResponseContent]: + """ + Lists the groups that are assigned to the specified organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Group, ListOrganizationGroupsResponseContent] + Organization groups successfully retrieved. + """ + _response = self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(organization_id)}/groups", + method="GET", + params={ + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListOrganizationGroupsResponseContent, + parse_obj_as( + type_=ListOrganizationGroupsResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.groups + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.list( + organization_id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawGroupsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + organization_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Group, ListOrganizationGroupsResponseContent]: + """ + Lists the groups that are assigned to the specified organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Group, ListOrganizationGroupsResponseContent] + Organization groups successfully retrieved. + """ + _response = await self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(organization_id)}/groups", + method="GET", + params={ + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListOrganizationGroupsResponseContent, + parse_obj_as( + type_=ListOrganizationGroupsResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.groups + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.list( + organization_id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + + return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/auth0/management/organizations/groups/roles/__init__.py b/src/auth0/management/organizations/groups/roles/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/auth0/management/organizations/groups/roles/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/auth0/management/organizations/groups/roles/client.py b/src/auth0/management/organizations/groups/roles/client.py new file mode 100644 index 00000000..5464449e --- /dev/null +++ b/src/auth0/management/organizations/groups/roles/client.py @@ -0,0 +1,366 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.pagination import AsyncPager, SyncPager +from ....core.request_options import RequestOptions +from ....types.list_organization_group_roles_response_content import ListOrganizationGroupRolesResponseContent +from ....types.role import Role +from .raw_client import AsyncRawRolesClient, RawRolesClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RolesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawRolesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawRolesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawRolesClient + """ + return self._raw_client + + def list( + self, + organization_id: str, + group_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Role, ListOrganizationGroupRolesResponseContent]: + """ + Lists the roles assigned to the specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Role, ListOrganizationGroupRolesResponseContent] + Organization group roles successfully retrieved. + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + response = client.organizations.groups.roles.list( + organization_id="organization_id", + group_id="group_id", + from_="from", + take=1, + ) + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.list(organization_id, group_id, from_=from_, take=take, request_options=request_options) + + def create( + self, + organization_id: str, + group_id: str, + *, + roles: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> None: + """ + Assign one or more roles to a specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + roles : typing.Sequence[str] + Array of role IDs to assign to organization group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + client.organizations.groups.roles.create( + organization_id="organization_id", + group_id="group_id", + roles=["roles"], + ) + """ + _response = self._raw_client.create(organization_id, group_id, roles=roles, request_options=request_options) + return _response.data + + def delete( + self, + organization_id: str, + group_id: str, + *, + roles: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> None: + """ + Unassign one or more roles from a specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + roles : typing.Sequence[str] + Array of role IDs to delete from organization group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + client.organizations.groups.roles.delete( + organization_id="organization_id", + group_id="group_id", + roles=["roles"], + ) + """ + _response = self._raw_client.delete(organization_id, group_id, roles=roles, request_options=request_options) + return _response.data + + +class AsyncRolesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawRolesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawRolesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawRolesClient + """ + return self._raw_client + + async def list( + self, + organization_id: str, + group_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Role, ListOrganizationGroupRolesResponseContent]: + """ + Lists the roles assigned to the specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Role, ListOrganizationGroupRolesResponseContent] + Organization group roles successfully retrieved. + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + response = await client.organizations.groups.roles.list( + organization_id="organization_id", + group_id="group_id", + from_="from", + take=1, + ) + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.list( + organization_id, group_id, from_=from_, take=take, request_options=request_options + ) + + async def create( + self, + organization_id: str, + group_id: str, + *, + roles: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> None: + """ + Assign one or more roles to a specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + roles : typing.Sequence[str] + Array of role IDs to assign to organization group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.organizations.groups.roles.create( + organization_id="organization_id", + group_id="group_id", + roles=["roles"], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create( + organization_id, group_id, roles=roles, request_options=request_options + ) + return _response.data + + async def delete( + self, + organization_id: str, + group_id: str, + *, + roles: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> None: + """ + Unassign one or more roles from a specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + roles : typing.Sequence[str] + Array of role IDs to delete from organization group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.organizations.groups.roles.delete( + organization_id="organization_id", + group_id="group_id", + roles=["roles"], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete( + organization_id, group_id, roles=roles, request_options=request_options + ) + return _response.data diff --git a/src/auth0/management/organizations/groups/roles/raw_client.py b/src/auth0/management/organizations/groups/roles/raw_client.py new file mode 100644 index 00000000..6e52689e --- /dev/null +++ b/src/auth0/management/organizations/groups/roles/raw_client.py @@ -0,0 +1,679 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import encode_path_param +from ....core.pagination import AsyncPager, SyncPager +from ....core.parse_error import ParsingError +from ....core.pydantic_utilities import parse_obj_as +from ....core.request_options import RequestOptions +from ....errors.bad_request_error import BadRequestError +from ....errors.conflict_error import ConflictError +from ....errors.forbidden_error import ForbiddenError +from ....errors.too_many_requests_error import TooManyRequestsError +from ....errors.unauthorized_error import UnauthorizedError +from ....types.list_organization_group_roles_response_content import ListOrganizationGroupRolesResponseContent +from ....types.role import Role +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawRolesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + organization_id: str, + group_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Role, ListOrganizationGroupRolesResponseContent]: + """ + Lists the roles assigned to the specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Role, ListOrganizationGroupRolesResponseContent] + Organization group roles successfully retrieved. + """ + _response = self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(organization_id)}/groups/{encode_path_param(group_id)}/roles", + method="GET", + params={ + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListOrganizationGroupRolesResponseContent, + parse_obj_as( + type_=ListOrganizationGroupRolesResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.roles + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.list( + organization_id, + group_id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def create( + self, + organization_id: str, + group_id: str, + *, + roles: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[None]: + """ + Assign one or more roles to a specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + roles : typing.Sequence[str] + Array of role IDs to assign to organization group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(organization_id)}/groups/{encode_path_param(group_id)}/roles", + method="POST", + json={ + "roles": roles, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, + organization_id: str, + group_id: str, + *, + roles: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[None]: + """ + Unassign one or more roles from a specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + roles : typing.Sequence[str] + Array of role IDs to delete from organization group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(organization_id)}/groups/{encode_path_param(group_id)}/roles", + method="DELETE", + json={ + "roles": roles, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawRolesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + organization_id: str, + group_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Role, ListOrganizationGroupRolesResponseContent]: + """ + Lists the roles assigned to the specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Role, ListOrganizationGroupRolesResponseContent] + Organization group roles successfully retrieved. + """ + _response = await self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(organization_id)}/groups/{encode_path_param(group_id)}/roles", + method="GET", + params={ + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListOrganizationGroupRolesResponseContent, + parse_obj_as( + type_=ListOrganizationGroupRolesResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.roles + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.list( + organization_id, + group_id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + + return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def create( + self, + organization_id: str, + group_id: str, + *, + roles: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[None]: + """ + Assign one or more roles to a specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + roles : typing.Sequence[str] + Array of role IDs to assign to organization group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(organization_id)}/groups/{encode_path_param(group_id)}/roles", + method="POST", + json={ + "roles": roles, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, + organization_id: str, + group_id: str, + *, + roles: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[None]: + """ + Unassign one or more roles from a specified group in the context of an organization. + + Parameters + ---------- + organization_id : str + ID of the organization + + group_id : str + ID of the group + + roles : typing.Sequence[str] + Array of role IDs to delete from organization group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(organization_id)}/groups/{encode_path_param(group_id)}/roles", + method="DELETE", + json={ + "roles": roles, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/auth0/management/organizations/members/__init__.py b/src/auth0/management/organizations/members/__init__.py index 686aa754..afd3bf71 100644 --- a/src/auth0/management/organizations/members/__init__.py +++ b/src/auth0/management/organizations/members/__init__.py @@ -6,8 +6,8 @@ from importlib import import_module if typing.TYPE_CHECKING: - from . import roles -_dynamic_imports: typing.Dict[str, str] = {"roles": ".roles"} + from . import effective_roles, roles +_dynamic_imports: typing.Dict[str, str] = {"effective_roles": ".effective_roles", "roles": ".roles"} def __getattr__(attr_name: str) -> typing.Any: @@ -31,4 +31,4 @@ def __dir__(): return sorted(lazy_attrs) -__all__ = ["roles"] +__all__ = ["effective_roles", "roles"] diff --git a/src/auth0/management/organizations/members/client.py b/src/auth0/management/organizations/members/client.py index 22dbe6ee..5f7e1bca 100644 --- a/src/auth0/management/organizations/members/client.py +++ b/src/auth0/management/organizations/members/client.py @@ -14,6 +14,7 @@ from .raw_client import AsyncRawMembersClient, RawMembersClient if typing.TYPE_CHECKING: + from .effective_roles.client import AsyncEffectiveRolesClient, EffectiveRolesClient from .roles.client import AsyncRolesClient, RolesClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -23,6 +24,7 @@ class MembersClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawMembersClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper + self._effective_roles: typing.Optional[EffectiveRolesClient] = None self._roles: typing.Optional[RolesClient] = None @property @@ -191,6 +193,14 @@ def delete( _response = self._raw_client.delete(id, members=members, request_options=request_options) return _response.data + @property + def effective_roles(self): + if self._effective_roles is None: + from .effective_roles.client import EffectiveRolesClient # noqa: E402 + + self._effective_roles = EffectiveRolesClient(client_wrapper=self._client_wrapper) + return self._effective_roles + @property def roles(self): if self._roles is None: @@ -204,6 +214,7 @@ class AsyncMembersClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawMembersClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper + self._effective_roles: typing.Optional[AsyncEffectiveRolesClient] = None self._roles: typing.Optional[AsyncRolesClient] = None @property @@ -397,6 +408,14 @@ async def main() -> None: _response = await self._raw_client.delete(id, members=members, request_options=request_options) return _response.data + @property + def effective_roles(self): + if self._effective_roles is None: + from .effective_roles.client import AsyncEffectiveRolesClient # noqa: E402 + + self._effective_roles = AsyncEffectiveRolesClient(client_wrapper=self._client_wrapper) + return self._effective_roles + @property def roles(self): if self._roles is None: diff --git a/src/auth0/management/organizations/members/effective_roles/__init__.py b/src/auth0/management/organizations/members/effective_roles/__init__.py new file mode 100644 index 00000000..504a42f7 --- /dev/null +++ b/src/auth0/management/organizations/members/effective_roles/__init__.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import sources +_dynamic_imports: typing.Dict[str, str] = {"sources": ".sources"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + + +__all__ = ["sources"] diff --git a/src/auth0/management/organizations/members/effective_roles/client.py b/src/auth0/management/organizations/members/effective_roles/client.py new file mode 100644 index 00000000..e9732d31 --- /dev/null +++ b/src/auth0/management/organizations/members/effective_roles/client.py @@ -0,0 +1,188 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.pagination import AsyncPager, SyncPager +from ....core.request_options import RequestOptions +from ....types.list_organization_member_effective_roles_response_content import ( + ListOrganizationMemberEffectiveRolesResponseContent, +) +from ....types.organization_member_effective_role import OrganizationMemberEffectiveRole +from .raw_client import AsyncRawEffectiveRolesClient, RawEffectiveRolesClient + +if typing.TYPE_CHECKING: + from .sources.client import AsyncSourcesClient, SourcesClient + + +class EffectiveRolesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawEffectiveRolesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._sources: typing.Optional[SourcesClient] = None + + @property + def with_raw_response(self) -> RawEffectiveRolesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawEffectiveRolesClient + """ + return self._raw_client + + def list( + self, + id: str, + user_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[OrganizationMemberEffectiveRole, ListOrganizationMemberEffectiveRolesResponseContent]: + """ + Lists the roles assigned to an organization member directly or through group membership. + + Parameters + ---------- + id : str + Organization identifier. + + user_id : str + ID of the user to list effective roles for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[OrganizationMemberEffectiveRole, ListOrganizationMemberEffectiveRolesResponseContent] + Organization member's effective roles successfully retrieved. + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + response = client.organizations.members.effective_roles.list( + id="id", + user_id="user_id", + from_="from", + take=1, + ) + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.list(id, user_id, from_=from_, take=take, request_options=request_options) + + @property + def sources(self): + if self._sources is None: + from .sources.client import SourcesClient # noqa: E402 + + self._sources = SourcesClient(client_wrapper=self._client_wrapper) + return self._sources + + +class AsyncEffectiveRolesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawEffectiveRolesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._sources: typing.Optional[AsyncSourcesClient] = None + + @property + def with_raw_response(self) -> AsyncRawEffectiveRolesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawEffectiveRolesClient + """ + return self._raw_client + + async def list( + self, + id: str, + user_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[OrganizationMemberEffectiveRole, ListOrganizationMemberEffectiveRolesResponseContent]: + """ + Lists the roles assigned to an organization member directly or through group membership. + + Parameters + ---------- + id : str + Organization identifier. + + user_id : str + ID of the user to list effective roles for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[OrganizationMemberEffectiveRole, ListOrganizationMemberEffectiveRolesResponseContent] + Organization member's effective roles successfully retrieved. + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + response = await client.organizations.members.effective_roles.list( + id="id", + user_id="user_id", + from_="from", + take=1, + ) + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.list(id, user_id, from_=from_, take=take, request_options=request_options) + + @property + def sources(self): + if self._sources is None: + from .sources.client import AsyncSourcesClient # noqa: E402 + + self._sources = AsyncSourcesClient(client_wrapper=self._client_wrapper) + return self._sources diff --git a/src/auth0/management/organizations/members/effective_roles/raw_client.py b/src/auth0/management/organizations/members/effective_roles/raw_client.py new file mode 100644 index 00000000..5177f2b1 --- /dev/null +++ b/src/auth0/management/organizations/members/effective_roles/raw_client.py @@ -0,0 +1,266 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.jsonable_encoder import encode_path_param +from ....core.pagination import AsyncPager, SyncPager +from ....core.parse_error import ParsingError +from ....core.pydantic_utilities import parse_obj_as +from ....core.request_options import RequestOptions +from ....errors.bad_request_error import BadRequestError +from ....errors.forbidden_error import ForbiddenError +from ....errors.too_many_requests_error import TooManyRequestsError +from ....errors.unauthorized_error import UnauthorizedError +from ....types.list_organization_member_effective_roles_response_content import ( + ListOrganizationMemberEffectiveRolesResponseContent, +) +from ....types.organization_member_effective_role import OrganizationMemberEffectiveRole +from pydantic import ValidationError + + +class RawEffectiveRolesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + id: str, + user_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[OrganizationMemberEffectiveRole, ListOrganizationMemberEffectiveRolesResponseContent]: + """ + Lists the roles assigned to an organization member directly or through group membership. + + Parameters + ---------- + id : str + Organization identifier. + + user_id : str + ID of the user to list effective roles for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[OrganizationMemberEffectiveRole, ListOrganizationMemberEffectiveRolesResponseContent] + Organization member's effective roles successfully retrieved. + """ + _response = self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(id)}/members/{encode_path_param(user_id)}/effective-roles", + method="GET", + params={ + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListOrganizationMemberEffectiveRolesResponseContent, + parse_obj_as( + type_=ListOrganizationMemberEffectiveRolesResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.roles + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.list( + id, + user_id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawEffectiveRolesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + id: str, + user_id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[OrganizationMemberEffectiveRole, ListOrganizationMemberEffectiveRolesResponseContent]: + """ + Lists the roles assigned to an organization member directly or through group membership. + + Parameters + ---------- + id : str + Organization identifier. + + user_id : str + ID of the user to list effective roles for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[OrganizationMemberEffectiveRole, ListOrganizationMemberEffectiveRolesResponseContent] + Organization member's effective roles successfully retrieved. + """ + _response = await self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(id)}/members/{encode_path_param(user_id)}/effective-roles", + method="GET", + params={ + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListOrganizationMemberEffectiveRolesResponseContent, + parse_obj_as( + type_=ListOrganizationMemberEffectiveRolesResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.roles + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.list( + id, + user_id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + + return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/auth0/management/organizations/members/effective_roles/sources/__init__.py b/src/auth0/management/organizations/members/effective_roles/sources/__init__.py new file mode 100644 index 00000000..345b2fe1 --- /dev/null +++ b/src/auth0/management/organizations/members/effective_roles/sources/__init__.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import groups +_dynamic_imports: typing.Dict[str, str] = {"groups": ".groups"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + + +__all__ = ["groups"] diff --git a/src/auth0/management/organizations/members/effective_roles/sources/client.py b/src/auth0/management/organizations/members/effective_roles/sources/client.py new file mode 100644 index 00000000..72d2517f --- /dev/null +++ b/src/auth0/management/organizations/members/effective_roles/sources/client.py @@ -0,0 +1,63 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations + +import typing + +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .raw_client import AsyncRawSourcesClient, RawSourcesClient + +if typing.TYPE_CHECKING: + from .groups.client import AsyncGroupsClient, GroupsClient + + +class SourcesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSourcesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._groups: typing.Optional[GroupsClient] = None + + @property + def with_raw_response(self) -> RawSourcesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSourcesClient + """ + return self._raw_client + + @property + def groups(self): + if self._groups is None: + from .groups.client import GroupsClient # noqa: E402 + + self._groups = GroupsClient(client_wrapper=self._client_wrapper) + return self._groups + + +class AsyncSourcesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSourcesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._groups: typing.Optional[AsyncGroupsClient] = None + + @property + def with_raw_response(self) -> AsyncRawSourcesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSourcesClient + """ + return self._raw_client + + @property + def groups(self): + if self._groups is None: + from .groups.client import AsyncGroupsClient # noqa: E402 + + self._groups = AsyncGroupsClient(client_wrapper=self._client_wrapper) + return self._groups diff --git a/src/auth0/management/organizations/members/effective_roles/sources/groups/__init__.py b/src/auth0/management/organizations/members/effective_roles/sources/groups/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/auth0/management/organizations/members/effective_roles/sources/groups/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/auth0/management/organizations/members/effective_roles/sources/groups/client.py b/src/auth0/management/organizations/members/effective_roles/sources/groups/client.py new file mode 100644 index 00000000..f90e95a4 --- /dev/null +++ b/src/auth0/management/organizations/members/effective_roles/sources/groups/client.py @@ -0,0 +1,179 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ......core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ......core.pagination import AsyncPager, SyncPager +from ......core.request_options import RequestOptions +from ......types.group import Group +from ......types.list_organization_member_role_source_groups_response_content import ( + ListOrganizationMemberRoleSourceGroupsResponseContent, +) +from .raw_client import AsyncRawGroupsClient, RawGroupsClient + + +class GroupsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawGroupsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawGroupsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawGroupsClient + """ + return self._raw_client + + def list( + self, + id: str, + user_id: str, + *, + role_id: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Group, ListOrganizationMemberRoleSourceGroupsResponseContent]: + """ + Lists the groups which grant the org member a given role. + + Parameters + ---------- + id : str + Organization identifier. + + user_id : str + ID of the user to list role source groups for. + + role_id : str + The role ID to get group sources for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Group, ListOrganizationMemberRoleSourceGroupsResponseContent] + Organization member role source groups successfully retrieved. + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + response = client.organizations.members.effective_roles.sources.groups.list( + id="id", + user_id="user_id", + from_="from", + take=1, + role_id="role_id", + ) + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.list( + id, user_id, role_id=role_id, from_=from_, take=take, request_options=request_options + ) + + +class AsyncGroupsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawGroupsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawGroupsClient + """ + return self._raw_client + + async def list( + self, + id: str, + user_id: str, + *, + role_id: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Group, ListOrganizationMemberRoleSourceGroupsResponseContent]: + """ + Lists the groups which grant the org member a given role. + + Parameters + ---------- + id : str + Organization identifier. + + user_id : str + ID of the user to list role source groups for. + + role_id : str + The role ID to get group sources for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Group, ListOrganizationMemberRoleSourceGroupsResponseContent] + Organization member role source groups successfully retrieved. + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + response = ( + await client.organizations.members.effective_roles.sources.groups.list( + id="id", + user_id="user_id", + from_="from", + take=1, + role_id="role_id", + ) + ) + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.list( + id, user_id, role_id=role_id, from_=from_, take=take, request_options=request_options + ) diff --git a/src/auth0/management/organizations/members/effective_roles/sources/groups/raw_client.py b/src/auth0/management/organizations/members/effective_roles/sources/groups/raw_client.py new file mode 100644 index 00000000..214b49e3 --- /dev/null +++ b/src/auth0/management/organizations/members/effective_roles/sources/groups/raw_client.py @@ -0,0 +1,278 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ......core.api_error import ApiError +from ......core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ......core.jsonable_encoder import encode_path_param +from ......core.pagination import AsyncPager, SyncPager +from ......core.parse_error import ParsingError +from ......core.pydantic_utilities import parse_obj_as +from ......core.request_options import RequestOptions +from ......errors.bad_request_error import BadRequestError +from ......errors.forbidden_error import ForbiddenError +from ......errors.too_many_requests_error import TooManyRequestsError +from ......errors.unauthorized_error import UnauthorizedError +from ......types.group import Group +from ......types.list_organization_member_role_source_groups_response_content import ( + ListOrganizationMemberRoleSourceGroupsResponseContent, +) +from pydantic import ValidationError + + +class RawGroupsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + id: str, + user_id: str, + *, + role_id: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Group, ListOrganizationMemberRoleSourceGroupsResponseContent]: + """ + Lists the groups which grant the org member a given role. + + Parameters + ---------- + id : str + Organization identifier. + + user_id : str + ID of the user to list role source groups for. + + role_id : str + The role ID to get group sources for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Group, ListOrganizationMemberRoleSourceGroupsResponseContent] + Organization member role source groups successfully retrieved. + """ + _response = self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(id)}/members/{encode_path_param(user_id)}/effective-roles/sources/groups", + method="GET", + params={ + "from": from_, + "take": take, + "role_id": role_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListOrganizationMemberRoleSourceGroupsResponseContent, + parse_obj_as( + type_=ListOrganizationMemberRoleSourceGroupsResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.groups + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.list( + id, + user_id, + role_id=role_id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawGroupsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + id: str, + user_id: str, + *, + role_id: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Group, ListOrganizationMemberRoleSourceGroupsResponseContent]: + """ + Lists the groups which grant the org member a given role. + + Parameters + ---------- + id : str + Organization identifier. + + user_id : str + ID of the user to list role source groups for. + + role_id : str + The role ID to get group sources for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Group, ListOrganizationMemberRoleSourceGroupsResponseContent] + Organization member role source groups successfully retrieved. + """ + _response = await self._client_wrapper.httpx_client.request( + f"organizations/{encode_path_param(id)}/members/{encode_path_param(user_id)}/effective-roles/sources/groups", + method="GET", + params={ + "from": from_, + "take": take, + "role_id": role_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListOrganizationMemberRoleSourceGroupsResponseContent, + parse_obj_as( + type_=ListOrganizationMemberRoleSourceGroupsResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.groups + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.list( + id, + user_id, + role_id=role_id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + + return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/auth0/management/organizations/members/effective_roles/sources/raw_client.py b/src/auth0/management/organizations/members/effective_roles/sources/raw_client.py new file mode 100644 index 00000000..ac212ad3 --- /dev/null +++ b/src/auth0/management/organizations/members/effective_roles/sources/raw_client.py @@ -0,0 +1,13 @@ +# This file was auto-generated by Fern from our API Definition. + +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper + + +class RawSourcesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + +class AsyncRawSourcesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper diff --git a/src/auth0/management/roles/__init__.py b/src/auth0/management/roles/__init__.py index 0ec75933..390349e1 100644 --- a/src/auth0/management/roles/__init__.py +++ b/src/auth0/management/roles/__init__.py @@ -6,8 +6,8 @@ from importlib import import_module if typing.TYPE_CHECKING: - from . import permissions, users -_dynamic_imports: typing.Dict[str, str] = {"permissions": ".permissions", "users": ".users"} + from . import groups, permissions, users +_dynamic_imports: typing.Dict[str, str] = {"groups": ".groups", "permissions": ".permissions", "users": ".users"} def __getattr__(attr_name: str) -> typing.Any: @@ -31,4 +31,4 @@ def __dir__(): return sorted(lazy_attrs) -__all__ = ["permissions", "users"] +__all__ = ["groups", "permissions", "users"] diff --git a/src/auth0/management/roles/client.py b/src/auth0/management/roles/client.py index 145f3fd2..c24f805b 100644 --- a/src/auth0/management/roles/client.py +++ b/src/auth0/management/roles/client.py @@ -15,6 +15,7 @@ from .raw_client import AsyncRawRolesClient, RawRolesClient if typing.TYPE_CHECKING: + from .groups.client import AsyncGroupsClient, GroupsClient from .permissions.client import AsyncPermissionsClient, PermissionsClient from .users.client import AsyncUsersClient, UsersClient # this is used as the default value for optional parameters @@ -25,6 +26,7 @@ class RolesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawRolesClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper + self._groups: typing.Optional[GroupsClient] = None self._permissions: typing.Optional[PermissionsClient] = None self._users: typing.Optional[UsersClient] = None @@ -249,6 +251,14 @@ def update( _response = self._raw_client.update(id, name=name, description=description, request_options=request_options) return _response.data + @property + def groups(self): + if self._groups is None: + from .groups.client import GroupsClient # noqa: E402 + + self._groups = GroupsClient(client_wrapper=self._client_wrapper) + return self._groups + @property def permissions(self): if self._permissions is None: @@ -270,6 +280,7 @@ class AsyncRolesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawRolesClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper + self._groups: typing.Optional[AsyncGroupsClient] = None self._permissions: typing.Optional[AsyncPermissionsClient] = None self._users: typing.Optional[AsyncUsersClient] = None @@ -537,6 +548,14 @@ async def main() -> None: ) return _response.data + @property + def groups(self): + if self._groups is None: + from .groups.client import AsyncGroupsClient # noqa: E402 + + self._groups = AsyncGroupsClient(client_wrapper=self._client_wrapper) + return self._groups + @property def permissions(self): if self._permissions is None: diff --git a/src/auth0/management/roles/groups/__init__.py b/src/auth0/management/roles/groups/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/auth0/management/roles/groups/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/auth0/management/roles/groups/client.py b/src/auth0/management/roles/groups/client.py new file mode 100644 index 00000000..00d7b0fb --- /dev/null +++ b/src/auth0/management/roles/groups/client.py @@ -0,0 +1,314 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.pagination import AsyncPager, SyncPager +from ...core.request_options import RequestOptions +from ...types.group import Group +from ...types.list_role_groups_response_content import ListRoleGroupsResponseContent +from .raw_client import AsyncRawGroupsClient, RawGroupsClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class GroupsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawGroupsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawGroupsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawGroupsClient + """ + return self._raw_client + + def get( + self, + id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Group, ListRoleGroupsResponseContent]: + """ + Lists the groups to which the specified role is assigned. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Group, ListRoleGroupsResponseContent] + Role's groups successfully retrieved. + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + response = client.roles.groups.get( + id="id", + from_="from", + take=1, + ) + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.get(id, from_=from_, take=take, request_options=request_options) + + def create( + self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Assign one or more groups to a specified role. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + groups : typing.Sequence[str] + Array of group IDs to assign to the role. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + client.roles.groups.create( + id="id", + groups=["groups"], + ) + """ + _response = self._raw_client.create(id, groups=groups, request_options=request_options) + return _response.data + + def delete( + self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Unassign one or more groups from a specified role. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + groups : typing.Sequence[str] + Array of group IDs to remove from the role. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + client.roles.groups.delete( + id="id", + groups=["groups"], + ) + """ + _response = self._raw_client.delete(id, groups=groups, request_options=request_options) + return _response.data + + +class AsyncGroupsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawGroupsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawGroupsClient + """ + return self._raw_client + + async def get( + self, + id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Group, ListRoleGroupsResponseContent]: + """ + Lists the groups to which the specified role is assigned. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Group, ListRoleGroupsResponseContent] + Role's groups successfully retrieved. + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + response = await client.roles.groups.get( + id="id", + from_="from", + take=1, + ) + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.get(id, from_=from_, take=take, request_options=request_options) + + async def create( + self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Assign one or more groups to a specified role. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + groups : typing.Sequence[str] + Array of group IDs to assign to the role. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.roles.groups.create( + id="id", + groups=["groups"], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create(id, groups=groups, request_options=request_options) + return _response.data + + async def delete( + self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Unassign one or more groups from a specified role. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + groups : typing.Sequence[str] + Array of group IDs to remove from the role. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.roles.groups.delete( + id="id", + groups=["groups"], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(id, groups=groups, request_options=request_options) + return _response.data diff --git a/src/auth0/management/roles/groups/raw_client.py b/src/auth0/management/roles/groups/raw_client.py new file mode 100644 index 00000000..54d1ec33 --- /dev/null +++ b/src/auth0/management/roles/groups/raw_client.py @@ -0,0 +1,637 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import encode_path_param +from ...core.pagination import AsyncPager, SyncPager +from ...core.parse_error import ParsingError +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...errors.bad_request_error import BadRequestError +from ...errors.forbidden_error import ForbiddenError +from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError +from ...types.group import Group +from ...types.list_role_groups_response_content import ListRoleGroupsResponseContent +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawGroupsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, + id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Group, ListRoleGroupsResponseContent]: + """ + Lists the groups to which the specified role is assigned. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Group, ListRoleGroupsResponseContent] + Role's groups successfully retrieved. + """ + _response = self._client_wrapper.httpx_client.request( + f"roles/{encode_path_param(id)}/groups", + method="GET", + params={ + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListRoleGroupsResponseContent, + parse_obj_as( + type_=ListRoleGroupsResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.groups + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.get( + id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def create( + self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[None]: + """ + Assign one or more groups to a specified role. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + groups : typing.Sequence[str] + Array of group IDs to assign to the role. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"roles/{encode_path_param(id)}/groups", + method="POST", + json={ + "groups": groups, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[None]: + """ + Unassign one or more groups from a specified role. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + groups : typing.Sequence[str] + Array of group IDs to remove from the role. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"roles/{encode_path_param(id)}/groups", + method="DELETE", + json={ + "groups": groups, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawGroupsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, + id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Group, ListRoleGroupsResponseContent]: + """ + Lists the groups to which the specified role is assigned. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Group, ListRoleGroupsResponseContent] + Role's groups successfully retrieved. + """ + _response = await self._client_wrapper.httpx_client.request( + f"roles/{encode_path_param(id)}/groups", + method="GET", + params={ + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListRoleGroupsResponseContent, + parse_obj_as( + type_=ListRoleGroupsResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.groups + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.get( + id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + + return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def create( + self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Assign one or more groups to a specified role. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + groups : typing.Sequence[str] + Array of group IDs to assign to the role. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"roles/{encode_path_param(id)}/groups", + method="POST", + json={ + "groups": groups, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, id: str, *, groups: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Unassign one or more groups from a specified role. + + Parameters + ---------- + id : str + Unique identifier for the role (service-generated). + + groups : typing.Sequence[str] + Array of group IDs to remove from the role. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"roles/{encode_path_param(id)}/groups", + method="DELETE", + json={ + "groups": groups, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/auth0/management/types/__init__.py b/src/auth0/management/types/__init__.py index e321ebd3..8c65437e 100644 --- a/src/auth0/management/types/__init__.py +++ b/src/auth0/management/types/__init__.py @@ -2763,9 +2763,17 @@ ListOrganizationConnectionsOffsetPaginatedResponseContent, ) from .list_organization_discovery_domains_response_content import ListOrganizationDiscoveryDomainsResponseContent + from .list_organization_group_roles_response_content import ListOrganizationGroupRolesResponseContent + from .list_organization_groups_response_content import ListOrganizationGroupsResponseContent from .list_organization_invitations_offset_paginated_response_content import ( ListOrganizationInvitationsOffsetPaginatedResponseContent, ) + from .list_organization_member_effective_roles_response_content import ( + ListOrganizationMemberEffectiveRolesResponseContent, + ) + from .list_organization_member_role_source_groups_response_content import ( + ListOrganizationMemberRoleSourceGroupsResponseContent, + ) from .list_organization_member_roles_offset_paginated_response_content import ( ListOrganizationMemberRolesOffsetPaginatedResponseContent, ) @@ -2775,6 +2783,7 @@ from .list_rate_limit_policies_paginated_response_content import ListRateLimitPoliciesPaginatedResponseContent from .list_refresh_tokens_paginated_response_content import ListRefreshTokensPaginatedResponseContent from .list_resource_server_offset_paginated_response_content import ListResourceServerOffsetPaginatedResponseContent + from .list_role_groups_response_content import ListRoleGroupsResponseContent from .list_role_permissions_offset_paginated_response_content import ( ListRolePermissionsOffsetPaginatedResponseContent, ) @@ -2796,6 +2805,11 @@ from .list_user_blocks_by_identifier_response_content import ListUserBlocksByIdentifierResponseContent from .list_user_blocks_response_content import ListUserBlocksResponseContent from .list_user_connected_accounts_response_content import ListUserConnectedAccountsResponseContent + from .list_user_effective_permission_role_sources_response_content import ( + ListUserEffectivePermissionRoleSourcesResponseContent, + ) + from .list_user_effective_permissions_response_content import ListUserEffectivePermissionsResponseContent + from .list_user_effective_roles_response_content import ListUserEffectiveRolesResponseContent from .list_user_grants_offset_paginated_response_content import ListUserGrantsOffsetPaginatedResponseContent from .list_user_organizations_offset_paginated_response_content import ( ListUserOrganizationsOffsetPaginatedResponseContent, @@ -2803,6 +2817,7 @@ from .list_user_permissions_offset_paginated_response_content import ( ListUserPermissionsOffsetPaginatedResponseContent, ) + from .list_user_role_source_groups_response_content import ListUserRoleSourceGroupsResponseContent from .list_user_roles_offset_paginated_response_content import ListUserRolesOffsetPaginatedResponseContent from .list_user_sessions_paginated_response_content import ListUserSessionsPaginatedResponseContent from .list_users_offset_paginated_response_content import ListUsersOffsetPaginatedResponseContent @@ -2894,6 +2909,8 @@ from .organization_invitation_invitee import OrganizationInvitationInvitee from .organization_invitation_inviter import OrganizationInvitationInviter from .organization_member import OrganizationMember + from .organization_member_effective_role import OrganizationMemberEffectiveRole + from .organization_member_effective_role_source import OrganizationMemberEffectiveRoleSource from .organization_member_role import OrganizationMemberRole from .organization_metadata import OrganizationMetadata from .organization_usage_enum import OrganizationUsageEnum @@ -3323,6 +3340,12 @@ from .user_authentication_method_properties_enum import UserAuthenticationMethodPropertiesEnum from .user_block_identifier import UserBlockIdentifier from .user_date_schema import UserDateSchema + from .user_effective_permission_response_content import UserEffectivePermissionResponseContent + from .user_effective_permission_role_source_enum import UserEffectivePermissionRoleSourceEnum + from .user_effective_permission_role_source_response_content import UserEffectivePermissionRoleSourceResponseContent + from .user_effective_permission_source_enum import UserEffectivePermissionSourceEnum + from .user_effective_role import UserEffectiveRole + from .user_effective_role_source import UserEffectiveRoleSource from .user_enrollment_auth_method_enum import UserEnrollmentAuthMethodEnum from .user_enrollment_status_enum import UserEnrollmentStatusEnum from .user_grant import UserGrant @@ -5540,7 +5563,11 @@ "ListOrganizationClientGrantsOffsetPaginatedResponseContent": ".list_organization_client_grants_offset_paginated_response_content", "ListOrganizationConnectionsOffsetPaginatedResponseContent": ".list_organization_connections_offset_paginated_response_content", "ListOrganizationDiscoveryDomainsResponseContent": ".list_organization_discovery_domains_response_content", + "ListOrganizationGroupRolesResponseContent": ".list_organization_group_roles_response_content", + "ListOrganizationGroupsResponseContent": ".list_organization_groups_response_content", "ListOrganizationInvitationsOffsetPaginatedResponseContent": ".list_organization_invitations_offset_paginated_response_content", + "ListOrganizationMemberEffectiveRolesResponseContent": ".list_organization_member_effective_roles_response_content", + "ListOrganizationMemberRoleSourceGroupsResponseContent": ".list_organization_member_role_source_groups_response_content", "ListOrganizationMemberRolesOffsetPaginatedResponseContent": ".list_organization_member_roles_offset_paginated_response_content", "ListOrganizationMembersPaginatedResponseContent": ".list_organization_members_paginated_response_content", "ListOrganizationsPaginatedResponseContent": ".list_organizations_paginated_response_content", @@ -5548,6 +5575,7 @@ "ListRateLimitPoliciesPaginatedResponseContent": ".list_rate_limit_policies_paginated_response_content", "ListRefreshTokensPaginatedResponseContent": ".list_refresh_tokens_paginated_response_content", "ListResourceServerOffsetPaginatedResponseContent": ".list_resource_server_offset_paginated_response_content", + "ListRoleGroupsResponseContent": ".list_role_groups_response_content", "ListRolePermissionsOffsetPaginatedResponseContent": ".list_role_permissions_offset_paginated_response_content", "ListRoleUsersPaginatedResponseContent": ".list_role_users_paginated_response_content", "ListRolesOffsetPaginatedResponseContent": ".list_roles_offset_paginated_response_content", @@ -5563,9 +5591,13 @@ "ListUserBlocksByIdentifierResponseContent": ".list_user_blocks_by_identifier_response_content", "ListUserBlocksResponseContent": ".list_user_blocks_response_content", "ListUserConnectedAccountsResponseContent": ".list_user_connected_accounts_response_content", + "ListUserEffectivePermissionRoleSourcesResponseContent": ".list_user_effective_permission_role_sources_response_content", + "ListUserEffectivePermissionsResponseContent": ".list_user_effective_permissions_response_content", + "ListUserEffectiveRolesResponseContent": ".list_user_effective_roles_response_content", "ListUserGrantsOffsetPaginatedResponseContent": ".list_user_grants_offset_paginated_response_content", "ListUserOrganizationsOffsetPaginatedResponseContent": ".list_user_organizations_offset_paginated_response_content", "ListUserPermissionsOffsetPaginatedResponseContent": ".list_user_permissions_offset_paginated_response_content", + "ListUserRoleSourceGroupsResponseContent": ".list_user_role_source_groups_response_content", "ListUserRolesOffsetPaginatedResponseContent": ".list_user_roles_offset_paginated_response_content", "ListUserSessionsPaginatedResponseContent": ".list_user_sessions_paginated_response_content", "ListUsersOffsetPaginatedResponseContent": ".list_users_offset_paginated_response_content", @@ -5655,6 +5687,8 @@ "OrganizationInvitationInvitee": ".organization_invitation_invitee", "OrganizationInvitationInviter": ".organization_invitation_inviter", "OrganizationMember": ".organization_member", + "OrganizationMemberEffectiveRole": ".organization_member_effective_role", + "OrganizationMemberEffectiveRoleSource": ".organization_member_effective_role_source", "OrganizationMemberRole": ".organization_member_role", "OrganizationMetadata": ".organization_metadata", "OrganizationUsageEnum": ".organization_usage_enum", @@ -6016,6 +6050,12 @@ "UserAuthenticationMethodPropertiesEnum": ".user_authentication_method_properties_enum", "UserBlockIdentifier": ".user_block_identifier", "UserDateSchema": ".user_date_schema", + "UserEffectivePermissionResponseContent": ".user_effective_permission_response_content", + "UserEffectivePermissionRoleSourceEnum": ".user_effective_permission_role_source_enum", + "UserEffectivePermissionRoleSourceResponseContent": ".user_effective_permission_role_source_response_content", + "UserEffectivePermissionSourceEnum": ".user_effective_permission_source_enum", + "UserEffectiveRole": ".user_effective_role", + "UserEffectiveRoleSource": ".user_effective_role_source", "UserEnrollmentAuthMethodEnum": ".user_enrollment_auth_method_enum", "UserEnrollmentStatusEnum": ".user_enrollment_status_enum", "UserGrant": ".user_grant", @@ -8257,7 +8297,11 @@ def __dir__(): "ListOrganizationClientGrantsOffsetPaginatedResponseContent", "ListOrganizationConnectionsOffsetPaginatedResponseContent", "ListOrganizationDiscoveryDomainsResponseContent", + "ListOrganizationGroupRolesResponseContent", + "ListOrganizationGroupsResponseContent", "ListOrganizationInvitationsOffsetPaginatedResponseContent", + "ListOrganizationMemberEffectiveRolesResponseContent", + "ListOrganizationMemberRoleSourceGroupsResponseContent", "ListOrganizationMemberRolesOffsetPaginatedResponseContent", "ListOrganizationMembersPaginatedResponseContent", "ListOrganizationsPaginatedResponseContent", @@ -8265,6 +8309,7 @@ def __dir__(): "ListRateLimitPoliciesPaginatedResponseContent", "ListRefreshTokensPaginatedResponseContent", "ListResourceServerOffsetPaginatedResponseContent", + "ListRoleGroupsResponseContent", "ListRolePermissionsOffsetPaginatedResponseContent", "ListRoleUsersPaginatedResponseContent", "ListRolesOffsetPaginatedResponseContent", @@ -8280,9 +8325,13 @@ def __dir__(): "ListUserBlocksByIdentifierResponseContent", "ListUserBlocksResponseContent", "ListUserConnectedAccountsResponseContent", + "ListUserEffectivePermissionRoleSourcesResponseContent", + "ListUserEffectivePermissionsResponseContent", + "ListUserEffectiveRolesResponseContent", "ListUserGrantsOffsetPaginatedResponseContent", "ListUserOrganizationsOffsetPaginatedResponseContent", "ListUserPermissionsOffsetPaginatedResponseContent", + "ListUserRoleSourceGroupsResponseContent", "ListUserRolesOffsetPaginatedResponseContent", "ListUserSessionsPaginatedResponseContent", "ListUsersOffsetPaginatedResponseContent", @@ -8372,6 +8421,8 @@ def __dir__(): "OrganizationInvitationInvitee", "OrganizationInvitationInviter", "OrganizationMember", + "OrganizationMemberEffectiveRole", + "OrganizationMemberEffectiveRoleSource", "OrganizationMemberRole", "OrganizationMetadata", "OrganizationUsageEnum", @@ -8733,6 +8784,12 @@ def __dir__(): "UserAuthenticationMethodPropertiesEnum", "UserBlockIdentifier", "UserDateSchema", + "UserEffectivePermissionResponseContent", + "UserEffectivePermissionRoleSourceEnum", + "UserEffectivePermissionRoleSourceResponseContent", + "UserEffectivePermissionSourceEnum", + "UserEffectiveRole", + "UserEffectiveRoleSource", "UserEnrollmentAuthMethodEnum", "UserEnrollmentStatusEnum", "UserGrant", diff --git a/src/auth0/management/types/list_organization_group_roles_response_content.py b/src/auth0/management/types/list_organization_group_roles_response_content.py new file mode 100644 index 00000000..5b19a848 --- /dev/null +++ b/src/auth0/management/types/list_organization_group_roles_response_content.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .role import Role + + +class ListOrganizationGroupRolesResponseContent(UniversalBaseModel): + roles: typing.List[Role] + next: typing.Optional[str] = pydantic.Field(default=None) + """ + A cursor to be used as the "from" query parameter for the next page of results. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/list_organization_groups_response_content.py b/src/auth0/management/types/list_organization_groups_response_content.py new file mode 100644 index 00000000..d04d7627 --- /dev/null +++ b/src/auth0/management/types/list_organization_groups_response_content.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .group import Group + + +class ListOrganizationGroupsResponseContent(UniversalBaseModel): + groups: typing.List[Group] + next: typing.Optional[str] = pydantic.Field(default=None) + """ + A cursor to be used as the "from" query parameter for the next page of results. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/list_organization_member_effective_roles_response_content.py b/src/auth0/management/types/list_organization_member_effective_roles_response_content.py new file mode 100644 index 00000000..0ee07d60 --- /dev/null +++ b/src/auth0/management/types/list_organization_member_effective_roles_response_content.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .organization_member_effective_role import OrganizationMemberEffectiveRole + + +class ListOrganizationMemberEffectiveRolesResponseContent(UniversalBaseModel): + roles: typing.List[OrganizationMemberEffectiveRole] + next: typing.Optional[str] = pydantic.Field(default=None) + """ + Cursor for the next page of results + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/list_organization_member_role_source_groups_response_content.py b/src/auth0/management/types/list_organization_member_role_source_groups_response_content.py new file mode 100644 index 00000000..76d2c3b8 --- /dev/null +++ b/src/auth0/management/types/list_organization_member_role_source_groups_response_content.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .group import Group + + +class ListOrganizationMemberRoleSourceGroupsResponseContent(UniversalBaseModel): + groups: typing.List[Group] + next: typing.Optional[str] = pydantic.Field(default=None) + """ + A cursor to be used as the "from" query parameter for the next page of results. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/list_role_groups_response_content.py b/src/auth0/management/types/list_role_groups_response_content.py new file mode 100644 index 00000000..c62969a5 --- /dev/null +++ b/src/auth0/management/types/list_role_groups_response_content.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .group import Group + + +class ListRoleGroupsResponseContent(UniversalBaseModel): + groups: typing.List[Group] + next: typing.Optional[str] = pydantic.Field(default=None) + """ + A cursor to be used as the "from" query parameter for the next page of results. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/list_user_effective_permission_role_sources_response_content.py b/src/auth0/management/types/list_user_effective_permission_role_sources_response_content.py new file mode 100644 index 00000000..008c34ad --- /dev/null +++ b/src/auth0/management/types/list_user_effective_permission_role_sources_response_content.py @@ -0,0 +1,28 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .user_effective_permission_role_source_response_content import UserEffectivePermissionRoleSourceResponseContent + + +class ListUserEffectivePermissionRoleSourcesResponseContent(UniversalBaseModel): + roles: typing.List[UserEffectivePermissionRoleSourceResponseContent] = pydantic.Field() + """ + Roles with the specified permission assigned to the user, both directly and via groups. + """ + + next: typing.Optional[str] = pydantic.Field(default=None) + """ + A cursor to be used as the "from" query parameter for the next page of results. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/list_user_effective_permissions_response_content.py b/src/auth0/management/types/list_user_effective_permissions_response_content.py new file mode 100644 index 00000000..1b8a01c1 --- /dev/null +++ b/src/auth0/management/types/list_user_effective_permissions_response_content.py @@ -0,0 +1,28 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .user_effective_permission_response_content import UserEffectivePermissionResponseContent + + +class ListUserEffectivePermissionsResponseContent(UniversalBaseModel): + permissions: typing.List[UserEffectivePermissionResponseContent] = pydantic.Field() + """ + List of permissions assigned to the user. + """ + + next: typing.Optional[str] = pydantic.Field(default=None) + """ + A cursor to be used as the "from" query parameter for the next page of results. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/list_user_effective_roles_response_content.py b/src/auth0/management/types/list_user_effective_roles_response_content.py new file mode 100644 index 00000000..918cae58 --- /dev/null +++ b/src/auth0/management/types/list_user_effective_roles_response_content.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .user_effective_role import UserEffectiveRole + + +class ListUserEffectiveRolesResponseContent(UniversalBaseModel): + roles: typing.List[UserEffectiveRole] + next: typing.Optional[str] = pydantic.Field(default=None) + """ + Cursor for the next page of results + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/list_user_role_source_groups_response_content.py b/src/auth0/management/types/list_user_role_source_groups_response_content.py new file mode 100644 index 00000000..81798967 --- /dev/null +++ b/src/auth0/management/types/list_user_role_source_groups_response_content.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .group import Group + + +class ListUserRoleSourceGroupsResponseContent(UniversalBaseModel): + groups: typing.List[Group] + next: typing.Optional[str] = pydantic.Field(default=None) + """ + A cursor to be used as the "from" query parameter for the next page of results. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/oauth_scope.py b/src/auth0/management/types/oauth_scope.py index cbf45e39..46f2db01 100644 --- a/src/auth0/management/types/oauth_scope.py +++ b/src/auth0/management/types/oauth_scope.py @@ -140,9 +140,15 @@ "read:organization_discovery_domains", "update:organization_discovery_domains", "delete:organization_discovery_domains", + "create:organization_group_roles", + "read:organization_group_roles", + "delete:organization_group_roles", + "read:organization_groups", "create:organization_invitations", "read:organization_invitations", "delete:organization_invitations", + "read:organization_member_effective_roles", + "read:organization_member_role_source_groups", "create:organization_member_roles", "read:organization_member_roles", "delete:organization_member_roles", @@ -221,7 +227,11 @@ "read:user_attribute_profiles", "update:user_attribute_profiles", "delete:user_attribute_profiles", + "read:user_effective_permissions", + "read:user_effective_roles", "read:user_idp_tokens", + "read:user_permission_source_roles", + "read:user_role_source_groups", "create:user_tickets", "create:users", "read:users", diff --git a/src/auth0/management/types/organization_member_effective_role.py b/src/auth0/management/types/organization_member_effective_role.py new file mode 100644 index 00000000..b512aed4 --- /dev/null +++ b/src/auth0/management/types/organization_member_effective_role.py @@ -0,0 +1,38 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .organization_member_effective_role_source import OrganizationMemberEffectiveRoleSource + + +class OrganizationMemberEffectiveRole(UniversalBaseModel): + id: str = pydantic.Field() + """ + Role ID + """ + + name: str = pydantic.Field() + """ + Role name + """ + + description: str = pydantic.Field() + """ + Role description + """ + + sources: typing.List[OrganizationMemberEffectiveRoleSource] = pydantic.Field() + """ + Sources of the role assignment (direct or through group membership) + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/organization_member_effective_role_source.py b/src/auth0/management/types/organization_member_effective_role_source.py new file mode 100644 index 00000000..5f08b7b7 --- /dev/null +++ b/src/auth0/management/types/organization_member_effective_role_source.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +OrganizationMemberEffectiveRoleSource = typing.Union[typing.Literal["direct", "groups"], typing.Any] diff --git a/src/auth0/management/types/user_effective_permission_response_content.py b/src/auth0/management/types/user_effective_permission_response_content.py new file mode 100644 index 00000000..043d725f --- /dev/null +++ b/src/auth0/management/types/user_effective_permission_response_content.py @@ -0,0 +1,43 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .user_effective_permission_source_enum import UserEffectivePermissionSourceEnum + + +class UserEffectivePermissionResponseContent(UniversalBaseModel): + resource_server_identifier: typing.Optional[str] = pydantic.Field(default=None) + """ + Resource server (API) identifier that this permission is for. + """ + + permission_name: typing.Optional[str] = pydantic.Field(default=None) + """ + Name of this permission. + """ + + resource_server_name: typing.Optional[str] = pydantic.Field(default=None) + """ + Resource server (API) name this permission is for. + """ + + description: typing.Optional[str] = pydantic.Field(default=None) + """ + Description of this permission. + """ + + sources: typing.Optional[typing.List[UserEffectivePermissionSourceEnum]] = pydantic.Field(default=None) + """ + List of sources where this permission is coming from. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/user_effective_permission_role_source_enum.py b/src/auth0/management/types/user_effective_permission_role_source_enum.py new file mode 100644 index 00000000..77739ce1 --- /dev/null +++ b/src/auth0/management/types/user_effective_permission_role_source_enum.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +UserEffectivePermissionRoleSourceEnum = typing.Union[typing.Literal["direct", "groups"], typing.Any] diff --git a/src/auth0/management/types/user_effective_permission_role_source_response_content.py b/src/auth0/management/types/user_effective_permission_role_source_response_content.py new file mode 100644 index 00000000..a24adfb3 --- /dev/null +++ b/src/auth0/management/types/user_effective_permission_role_source_response_content.py @@ -0,0 +1,38 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .user_effective_permission_role_source_enum import UserEffectivePermissionRoleSourceEnum + + +class UserEffectivePermissionRoleSourceResponseContent(UniversalBaseModel): + id: typing.Optional[str] = pydantic.Field(default=None) + """ + ID for this role. + """ + + name: typing.Optional[str] = pydantic.Field(default=None) + """ + Name of this role. + """ + + description: typing.Optional[str] = pydantic.Field(default=None) + """ + Description of this role. + """ + + sources: typing.Optional[typing.List[UserEffectivePermissionRoleSourceEnum]] = pydantic.Field(default=None) + """ + List of sources where this role is coming from. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/user_effective_permission_source_enum.py b/src/auth0/management/types/user_effective_permission_source_enum.py new file mode 100644 index 00000000..e6e2a0ff --- /dev/null +++ b/src/auth0/management/types/user_effective_permission_source_enum.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +UserEffectivePermissionSourceEnum = typing.Union[typing.Literal["direct", "roles"], typing.Any] diff --git a/src/auth0/management/types/user_effective_role.py b/src/auth0/management/types/user_effective_role.py new file mode 100644 index 00000000..200c4834 --- /dev/null +++ b/src/auth0/management/types/user_effective_role.py @@ -0,0 +1,38 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .user_effective_role_source import UserEffectiveRoleSource + + +class UserEffectiveRole(UniversalBaseModel): + id: str = pydantic.Field() + """ + Role ID + """ + + name: str = pydantic.Field() + """ + Role name + """ + + description: str = pydantic.Field() + """ + Role description + """ + + sources: typing.List[UserEffectiveRoleSource] = pydantic.Field() + """ + Sources of the role assignment (direct or through group membership) + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/auth0/management/types/user_effective_role_source.py b/src/auth0/management/types/user_effective_role_source.py new file mode 100644 index 00000000..48dcd602 --- /dev/null +++ b/src/auth0/management/types/user_effective_role_source.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +UserEffectiveRoleSource = typing.Union[typing.Literal["direct", "groups"], typing.Any] diff --git a/src/auth0/management/users/__init__.py b/src/auth0/management/users/__init__.py index e8dfda44..4f606d21 100644 --- a/src/auth0/management/users/__init__.py +++ b/src/auth0/management/users/__init__.py @@ -10,6 +10,8 @@ authentication_methods, authenticators, connected_accounts, + effective_permissions, + effective_roles, enrollments, federated_connections_tokensets, groups, @@ -27,6 +29,8 @@ "authentication_methods": ".authentication_methods", "authenticators": ".authenticators", "connected_accounts": ".connected_accounts", + "effective_permissions": ".effective_permissions", + "effective_roles": ".effective_roles", "enrollments": ".enrollments", "federated_connections_tokensets": ".federated_connections_tokensets", "groups": ".groups", @@ -67,6 +71,8 @@ def __dir__(): "authentication_methods", "authenticators", "connected_accounts", + "effective_permissions", + "effective_roles", "enrollments", "federated_connections_tokensets", "groups", diff --git a/src/auth0/management/users/client.py b/src/auth0/management/users/client.py index 597bf26c..c9d5259a 100644 --- a/src/auth0/management/users/client.py +++ b/src/auth0/management/users/client.py @@ -22,6 +22,8 @@ from .authentication_methods.client import AsyncAuthenticationMethodsClient, AuthenticationMethodsClient from .authenticators.client import AsyncAuthenticatorsClient, AuthenticatorsClient from .connected_accounts.client import AsyncConnectedAccountsClient, ConnectedAccountsClient + from .effective_permissions.client import AsyncEffectivePermissionsClient, EffectivePermissionsClient + from .effective_roles.client import AsyncEffectiveRolesClient, EffectiveRolesClient from .enrollments.client import AsyncEnrollmentsClient, EnrollmentsClient from .federated_connections_tokensets.client import ( AsyncFederatedConnectionsTokensetsClient, @@ -48,6 +50,8 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._authentication_methods: typing.Optional[AuthenticationMethodsClient] = None self._authenticators: typing.Optional[AuthenticatorsClient] = None self._connected_accounts: typing.Optional[ConnectedAccountsClient] = None + self._effective_permissions: typing.Optional[EffectivePermissionsClient] = None + self._effective_roles: typing.Optional[EffectiveRolesClient] = None self._enrollments: typing.Optional[EnrollmentsClient] = None self._federated_connections_tokensets: typing.Optional[FederatedConnectionsTokensetsClient] = None self._groups: typing.Optional[GroupsClient] = None @@ -756,6 +760,22 @@ def connected_accounts(self): self._connected_accounts = ConnectedAccountsClient(client_wrapper=self._client_wrapper) return self._connected_accounts + @property + def effective_permissions(self): + if self._effective_permissions is None: + from .effective_permissions.client import EffectivePermissionsClient # noqa: E402 + + self._effective_permissions = EffectivePermissionsClient(client_wrapper=self._client_wrapper) + return self._effective_permissions + + @property + def effective_roles(self): + if self._effective_roles is None: + from .effective_roles.client import EffectiveRolesClient # noqa: E402 + + self._effective_roles = EffectiveRolesClient(client_wrapper=self._client_wrapper) + return self._effective_roles + @property def enrollments(self): if self._enrollments is None: @@ -862,6 +882,8 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._authentication_methods: typing.Optional[AsyncAuthenticationMethodsClient] = None self._authenticators: typing.Optional[AsyncAuthenticatorsClient] = None self._connected_accounts: typing.Optional[AsyncConnectedAccountsClient] = None + self._effective_permissions: typing.Optional[AsyncEffectivePermissionsClient] = None + self._effective_roles: typing.Optional[AsyncEffectiveRolesClient] = None self._enrollments: typing.Optional[AsyncEnrollmentsClient] = None self._federated_connections_tokensets: typing.Optional[AsyncFederatedConnectionsTokensetsClient] = None self._groups: typing.Optional[AsyncGroupsClient] = None @@ -1635,6 +1657,22 @@ def connected_accounts(self): self._connected_accounts = AsyncConnectedAccountsClient(client_wrapper=self._client_wrapper) return self._connected_accounts + @property + def effective_permissions(self): + if self._effective_permissions is None: + from .effective_permissions.client import AsyncEffectivePermissionsClient # noqa: E402 + + self._effective_permissions = AsyncEffectivePermissionsClient(client_wrapper=self._client_wrapper) + return self._effective_permissions + + @property + def effective_roles(self): + if self._effective_roles is None: + from .effective_roles.client import AsyncEffectiveRolesClient # noqa: E402 + + self._effective_roles = AsyncEffectiveRolesClient(client_wrapper=self._client_wrapper) + return self._effective_roles + @property def enrollments(self): if self._enrollments is None: diff --git a/src/auth0/management/users/effective_permissions/__init__.py b/src/auth0/management/users/effective_permissions/__init__.py new file mode 100644 index 00000000..504a42f7 --- /dev/null +++ b/src/auth0/management/users/effective_permissions/__init__.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import sources +_dynamic_imports: typing.Dict[str, str] = {"sources": ".sources"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + + +__all__ = ["sources"] diff --git a/src/auth0/management/users/effective_permissions/client.py b/src/auth0/management/users/effective_permissions/client.py new file mode 100644 index 00000000..8a1154d2 --- /dev/null +++ b/src/auth0/management/users/effective_permissions/client.py @@ -0,0 +1,198 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.pagination import AsyncPager, SyncPager +from ...core.request_options import RequestOptions +from ...types.list_user_effective_permissions_response_content import ListUserEffectivePermissionsResponseContent +from ...types.user_effective_permission_response_content import UserEffectivePermissionResponseContent +from .raw_client import AsyncRawEffectivePermissionsClient, RawEffectivePermissionsClient + +if typing.TYPE_CHECKING: + from .sources.client import AsyncSourcesClient, SourcesClient + + +class EffectivePermissionsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawEffectivePermissionsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._sources: typing.Optional[SourcesClient] = None + + @property + def with_raw_response(self) -> RawEffectivePermissionsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawEffectivePermissionsClient + """ + return self._raw_client + + def list( + self, + id: str, + *, + resource_server_identifier: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent]: + """ + Returns the list of effective permissions for a user, taking into account permissions granted directly to the user, as well as those inherited through roles and group memberships. + + Parameters + ---------- + id : str + ID of the user to retrieve the permissions for. + + resource_server_identifier : str + The identifier of the resource server for which to calculate user permissions. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent] + User's effective permissions successfully retrieved. + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + response = client.users.effective_permissions.list( + id="id", + from_="from", + take=1, + resource_server_identifier="resource_server_identifier", + ) + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.list( + id, + resource_server_identifier=resource_server_identifier, + from_=from_, + take=take, + request_options=request_options, + ) + + @property + def sources(self): + if self._sources is None: + from .sources.client import SourcesClient # noqa: E402 + + self._sources = SourcesClient(client_wrapper=self._client_wrapper) + return self._sources + + +class AsyncEffectivePermissionsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawEffectivePermissionsClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._sources: typing.Optional[AsyncSourcesClient] = None + + @property + def with_raw_response(self) -> AsyncRawEffectivePermissionsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawEffectivePermissionsClient + """ + return self._raw_client + + async def list( + self, + id: str, + *, + resource_server_identifier: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent]: + """ + Returns the list of effective permissions for a user, taking into account permissions granted directly to the user, as well as those inherited through roles and group memberships. + + Parameters + ---------- + id : str + ID of the user to retrieve the permissions for. + + resource_server_identifier : str + The identifier of the resource server for which to calculate user permissions. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent] + User's effective permissions successfully retrieved. + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + response = await client.users.effective_permissions.list( + id="id", + from_="from", + take=1, + resource_server_identifier="resource_server_identifier", + ) + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.list( + id, + resource_server_identifier=resource_server_identifier, + from_=from_, + take=take, + request_options=request_options, + ) + + @property + def sources(self): + if self._sources is None: + from .sources.client import AsyncSourcesClient # noqa: E402 + + self._sources = AsyncSourcesClient(client_wrapper=self._client_wrapper) + return self._sources diff --git a/src/auth0/management/users/effective_permissions/raw_client.py b/src/auth0/management/users/effective_permissions/raw_client.py new file mode 100644 index 00000000..3fcc8169 --- /dev/null +++ b/src/auth0/management/users/effective_permissions/raw_client.py @@ -0,0 +1,289 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.jsonable_encoder import encode_path_param +from ...core.pagination import AsyncPager, SyncPager +from ...core.parse_error import ParsingError +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...errors.bad_request_error import BadRequestError +from ...errors.forbidden_error import ForbiddenError +from ...errors.not_found_error import NotFoundError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError +from ...types.list_user_effective_permissions_response_content import ListUserEffectivePermissionsResponseContent +from ...types.user_effective_permission_response_content import UserEffectivePermissionResponseContent +from pydantic import ValidationError + + +class RawEffectivePermissionsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + id: str, + *, + resource_server_identifier: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent]: + """ + Returns the list of effective permissions for a user, taking into account permissions granted directly to the user, as well as those inherited through roles and group memberships. + + Parameters + ---------- + id : str + ID of the user to retrieve the permissions for. + + resource_server_identifier : str + The identifier of the resource server for which to calculate user permissions. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent] + User's effective permissions successfully retrieved. + """ + _response = self._client_wrapper.httpx_client.request( + f"users/{encode_path_param(id)}/effective-permissions", + method="GET", + params={ + "from": from_, + "take": take, + "resource_server_identifier": resource_server_identifier, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListUserEffectivePermissionsResponseContent, + parse_obj_as( + type_=ListUserEffectivePermissionsResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.permissions + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.list( + id, + resource_server_identifier=resource_server_identifier, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawEffectivePermissionsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + id: str, + *, + resource_server_identifier: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent]: + """ + Returns the list of effective permissions for a user, taking into account permissions granted directly to the user, as well as those inherited through roles and group memberships. + + Parameters + ---------- + id : str + ID of the user to retrieve the permissions for. + + resource_server_identifier : str + The identifier of the resource server for which to calculate user permissions. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent] + User's effective permissions successfully retrieved. + """ + _response = await self._client_wrapper.httpx_client.request( + f"users/{encode_path_param(id)}/effective-permissions", + method="GET", + params={ + "from": from_, + "take": take, + "resource_server_identifier": resource_server_identifier, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListUserEffectivePermissionsResponseContent, + parse_obj_as( + type_=ListUserEffectivePermissionsResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.permissions + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.list( + id, + resource_server_identifier=resource_server_identifier, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + + return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/auth0/management/users/effective_permissions/sources/__init__.py b/src/auth0/management/users/effective_permissions/sources/__init__.py new file mode 100644 index 00000000..686aa754 --- /dev/null +++ b/src/auth0/management/users/effective_permissions/sources/__init__.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import roles +_dynamic_imports: typing.Dict[str, str] = {"roles": ".roles"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + + +__all__ = ["roles"] diff --git a/src/auth0/management/users/effective_permissions/sources/client.py b/src/auth0/management/users/effective_permissions/sources/client.py new file mode 100644 index 00000000..95383a21 --- /dev/null +++ b/src/auth0/management/users/effective_permissions/sources/client.py @@ -0,0 +1,63 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .raw_client import AsyncRawSourcesClient, RawSourcesClient + +if typing.TYPE_CHECKING: + from .roles.client import AsyncRolesClient, RolesClient + + +class SourcesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSourcesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._roles: typing.Optional[RolesClient] = None + + @property + def with_raw_response(self) -> RawSourcesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSourcesClient + """ + return self._raw_client + + @property + def roles(self): + if self._roles is None: + from .roles.client import RolesClient # noqa: E402 + + self._roles = RolesClient(client_wrapper=self._client_wrapper) + return self._roles + + +class AsyncSourcesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSourcesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._roles: typing.Optional[AsyncRolesClient] = None + + @property + def with_raw_response(self) -> AsyncRawSourcesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSourcesClient + """ + return self._raw_client + + @property + def roles(self): + if self._roles is None: + from .roles.client import AsyncRolesClient # noqa: E402 + + self._roles = AsyncRolesClient(client_wrapper=self._client_wrapper) + return self._roles diff --git a/src/auth0/management/users/effective_permissions/sources/raw_client.py b/src/auth0/management/users/effective_permissions/sources/raw_client.py new file mode 100644 index 00000000..e5f566c6 --- /dev/null +++ b/src/auth0/management/users/effective_permissions/sources/raw_client.py @@ -0,0 +1,13 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper + + +class RawSourcesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + +class AsyncRawSourcesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper diff --git a/src/auth0/management/users/effective_permissions/sources/roles/__init__.py b/src/auth0/management/users/effective_permissions/sources/roles/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/auth0/management/users/effective_permissions/sources/roles/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/auth0/management/users/effective_permissions/sources/roles/client.py b/src/auth0/management/users/effective_permissions/sources/roles/client.py new file mode 100644 index 00000000..6183b9b4 --- /dev/null +++ b/src/auth0/management/users/effective_permissions/sources/roles/client.py @@ -0,0 +1,193 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.pagination import AsyncPager, SyncPager +from .....core.request_options import RequestOptions +from .....types.list_user_effective_permission_role_sources_response_content import ( + ListUserEffectivePermissionRoleSourcesResponseContent, +) +from .....types.user_effective_permission_role_source_response_content import ( + UserEffectivePermissionRoleSourceResponseContent, +) +from .raw_client import AsyncRawRolesClient, RawRolesClient + + +class RolesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawRolesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawRolesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawRolesClient + """ + return self._raw_client + + def list( + self, + id: str, + *, + resource_server_identifier: str, + permission_name: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[ + UserEffectivePermissionRoleSourceResponseContent, ListUserEffectivePermissionRoleSourcesResponseContent + ]: + """ + Lists the roles which grant the user a given permission, including roles assigned directly to the user and those inherited through group memberships. + + Parameters + ---------- + id : str + ID of the user to retrieve the permissions for. + + resource_server_identifier : str + The identifier of the resource server for which to calculate user permissions. + + permission_name : str + Name of this permission + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[UserEffectivePermissionRoleSourceResponseContent, ListUserEffectivePermissionRoleSourcesResponseContent] + User's effective permission role sources successfully retrieved. + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + response = client.users.effective_permissions.sources.roles.list( + id="id", + from_="from", + take=1, + resource_server_identifier="resource_server_identifier", + permission_name="permission_name", + ) + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.list( + id, + resource_server_identifier=resource_server_identifier, + permission_name=permission_name, + from_=from_, + take=take, + request_options=request_options, + ) + + +class AsyncRolesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawRolesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawRolesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawRolesClient + """ + return self._raw_client + + async def list( + self, + id: str, + *, + resource_server_identifier: str, + permission_name: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[ + UserEffectivePermissionRoleSourceResponseContent, ListUserEffectivePermissionRoleSourcesResponseContent + ]: + """ + Lists the roles which grant the user a given permission, including roles assigned directly to the user and those inherited through group memberships. + + Parameters + ---------- + id : str + ID of the user to retrieve the permissions for. + + resource_server_identifier : str + The identifier of the resource server for which to calculate user permissions. + + permission_name : str + Name of this permission + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[UserEffectivePermissionRoleSourceResponseContent, ListUserEffectivePermissionRoleSourcesResponseContent] + User's effective permission role sources successfully retrieved. + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + response = await client.users.effective_permissions.sources.roles.list( + id="id", + from_="from", + take=1, + resource_server_identifier="resource_server_identifier", + permission_name="permission_name", + ) + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.list( + id, + resource_server_identifier=resource_server_identifier, + permission_name=permission_name, + from_=from_, + take=take, + request_options=request_options, + ) diff --git a/src/auth0/management/users/effective_permissions/sources/roles/raw_client.py b/src/auth0/management/users/effective_permissions/sources/roles/raw_client.py new file mode 100644 index 00000000..542c18d0 --- /dev/null +++ b/src/auth0/management/users/effective_permissions/sources/roles/raw_client.py @@ -0,0 +1,309 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .....core.api_error import ApiError +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.jsonable_encoder import encode_path_param +from .....core.pagination import AsyncPager, SyncPager +from .....core.parse_error import ParsingError +from .....core.pydantic_utilities import parse_obj_as +from .....core.request_options import RequestOptions +from .....errors.bad_request_error import BadRequestError +from .....errors.forbidden_error import ForbiddenError +from .....errors.not_found_error import NotFoundError +from .....errors.too_many_requests_error import TooManyRequestsError +from .....errors.unauthorized_error import UnauthorizedError +from .....types.list_user_effective_permission_role_sources_response_content import ( + ListUserEffectivePermissionRoleSourcesResponseContent, +) +from .....types.user_effective_permission_role_source_response_content import ( + UserEffectivePermissionRoleSourceResponseContent, +) +from pydantic import ValidationError + + +class RawRolesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + id: str, + *, + resource_server_identifier: str, + permission_name: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[ + UserEffectivePermissionRoleSourceResponseContent, ListUserEffectivePermissionRoleSourcesResponseContent + ]: + """ + Lists the roles which grant the user a given permission, including roles assigned directly to the user and those inherited through group memberships. + + Parameters + ---------- + id : str + ID of the user to retrieve the permissions for. + + resource_server_identifier : str + The identifier of the resource server for which to calculate user permissions. + + permission_name : str + Name of this permission + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[UserEffectivePermissionRoleSourceResponseContent, ListUserEffectivePermissionRoleSourcesResponseContent] + User's effective permission role sources successfully retrieved. + """ + _response = self._client_wrapper.httpx_client.request( + f"users/{encode_path_param(id)}/effective-permissions/sources/effective-roles", + method="GET", + params={ + "from": from_, + "take": take, + "resource_server_identifier": resource_server_identifier, + "permission_name": permission_name, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListUserEffectivePermissionRoleSourcesResponseContent, + parse_obj_as( + type_=ListUserEffectivePermissionRoleSourcesResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.roles + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.list( + id, + resource_server_identifier=resource_server_identifier, + permission_name=permission_name, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawRolesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + id: str, + *, + resource_server_identifier: str, + permission_name: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[ + UserEffectivePermissionRoleSourceResponseContent, ListUserEffectivePermissionRoleSourcesResponseContent + ]: + """ + Lists the roles which grant the user a given permission, including roles assigned directly to the user and those inherited through group memberships. + + Parameters + ---------- + id : str + ID of the user to retrieve the permissions for. + + resource_server_identifier : str + The identifier of the resource server for which to calculate user permissions. + + permission_name : str + Name of this permission + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[UserEffectivePermissionRoleSourceResponseContent, ListUserEffectivePermissionRoleSourcesResponseContent] + User's effective permission role sources successfully retrieved. + """ + _response = await self._client_wrapper.httpx_client.request( + f"users/{encode_path_param(id)}/effective-permissions/sources/effective-roles", + method="GET", + params={ + "from": from_, + "take": take, + "resource_server_identifier": resource_server_identifier, + "permission_name": permission_name, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListUserEffectivePermissionRoleSourcesResponseContent, + parse_obj_as( + type_=ListUserEffectivePermissionRoleSourcesResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.roles + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.list( + id, + resource_server_identifier=resource_server_identifier, + permission_name=permission_name, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + + return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/auth0/management/users/effective_roles/__init__.py b/src/auth0/management/users/effective_roles/__init__.py new file mode 100644 index 00000000..504a42f7 --- /dev/null +++ b/src/auth0/management/users/effective_roles/__init__.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import sources +_dynamic_imports: typing.Dict[str, str] = {"sources": ".sources"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + + +__all__ = ["sources"] diff --git a/src/auth0/management/users/effective_roles/client.py b/src/auth0/management/users/effective_roles/client.py new file mode 100644 index 00000000..87b46f3f --- /dev/null +++ b/src/auth0/management/users/effective_roles/client.py @@ -0,0 +1,176 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.pagination import AsyncPager, SyncPager +from ...core.request_options import RequestOptions +from ...types.list_user_effective_roles_response_content import ListUserEffectiveRolesResponseContent +from ...types.user_effective_role import UserEffectiveRole +from .raw_client import AsyncRawEffectiveRolesClient, RawEffectiveRolesClient + +if typing.TYPE_CHECKING: + from .sources.client import AsyncSourcesClient, SourcesClient + + +class EffectiveRolesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawEffectiveRolesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._sources: typing.Optional[SourcesClient] = None + + @property + def with_raw_response(self) -> RawEffectiveRolesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawEffectiveRolesClient + """ + return self._raw_client + + def list( + self, + id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent]: + """ + Retrieve detailed list of effective roles for a user, including roles assigned directly and through group memberships. + + Parameters + ---------- + id : str + ID of the user to list effective roles for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent] + User's effective roles successfully retrieved. + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + response = client.users.effective_roles.list( + id="id", + from_="from", + take=1, + ) + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.list(id, from_=from_, take=take, request_options=request_options) + + @property + def sources(self): + if self._sources is None: + from .sources.client import SourcesClient # noqa: E402 + + self._sources = SourcesClient(client_wrapper=self._client_wrapper) + return self._sources + + +class AsyncEffectiveRolesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawEffectiveRolesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._sources: typing.Optional[AsyncSourcesClient] = None + + @property + def with_raw_response(self) -> AsyncRawEffectiveRolesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawEffectiveRolesClient + """ + return self._raw_client + + async def list( + self, + id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent]: + """ + Retrieve detailed list of effective roles for a user, including roles assigned directly and through group memberships. + + Parameters + ---------- + id : str + ID of the user to list effective roles for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent] + User's effective roles successfully retrieved. + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + response = await client.users.effective_roles.list( + id="id", + from_="from", + take=1, + ) + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.list(id, from_=from_, take=take, request_options=request_options) + + @property + def sources(self): + if self._sources is None: + from .sources.client import AsyncSourcesClient # noqa: E402 + + self._sources = AsyncSourcesClient(client_wrapper=self._client_wrapper) + return self._sources diff --git a/src/auth0/management/users/effective_roles/raw_client.py b/src/auth0/management/users/effective_roles/raw_client.py new file mode 100644 index 00000000..2afa42c1 --- /dev/null +++ b/src/auth0/management/users/effective_roles/raw_client.py @@ -0,0 +1,254 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.jsonable_encoder import encode_path_param +from ...core.pagination import AsyncPager, SyncPager +from ...core.parse_error import ParsingError +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...errors.bad_request_error import BadRequestError +from ...errors.forbidden_error import ForbiddenError +from ...errors.too_many_requests_error import TooManyRequestsError +from ...errors.unauthorized_error import UnauthorizedError +from ...types.list_user_effective_roles_response_content import ListUserEffectiveRolesResponseContent +from ...types.user_effective_role import UserEffectiveRole +from pydantic import ValidationError + + +class RawEffectiveRolesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent]: + """ + Retrieve detailed list of effective roles for a user, including roles assigned directly and through group memberships. + + Parameters + ---------- + id : str + ID of the user to list effective roles for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent] + User's effective roles successfully retrieved. + """ + _response = self._client_wrapper.httpx_client.request( + f"users/{encode_path_param(id)}/effective-roles", + method="GET", + params={ + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListUserEffectiveRolesResponseContent, + parse_obj_as( + type_=ListUserEffectiveRolesResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.roles + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.list( + id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawEffectiveRolesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + id: str, + *, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent]: + """ + Retrieve detailed list of effective roles for a user, including roles assigned directly and through group memberships. + + Parameters + ---------- + id : str + ID of the user to list effective roles for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent] + User's effective roles successfully retrieved. + """ + _response = await self._client_wrapper.httpx_client.request( + f"users/{encode_path_param(id)}/effective-roles", + method="GET", + params={ + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListUserEffectiveRolesResponseContent, + parse_obj_as( + type_=ListUserEffectiveRolesResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.roles + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.list( + id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + + return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/auth0/management/users/effective_roles/sources/__init__.py b/src/auth0/management/users/effective_roles/sources/__init__.py new file mode 100644 index 00000000..345b2fe1 --- /dev/null +++ b/src/auth0/management/users/effective_roles/sources/__init__.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import groups +_dynamic_imports: typing.Dict[str, str] = {"groups": ".groups"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + + +__all__ = ["groups"] diff --git a/src/auth0/management/users/effective_roles/sources/client.py b/src/auth0/management/users/effective_roles/sources/client.py new file mode 100644 index 00000000..e50a1e13 --- /dev/null +++ b/src/auth0/management/users/effective_roles/sources/client.py @@ -0,0 +1,63 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .raw_client import AsyncRawSourcesClient, RawSourcesClient + +if typing.TYPE_CHECKING: + from .groups.client import AsyncGroupsClient, GroupsClient + + +class SourcesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSourcesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._groups: typing.Optional[GroupsClient] = None + + @property + def with_raw_response(self) -> RawSourcesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSourcesClient + """ + return self._raw_client + + @property + def groups(self): + if self._groups is None: + from .groups.client import GroupsClient # noqa: E402 + + self._groups = GroupsClient(client_wrapper=self._client_wrapper) + return self._groups + + +class AsyncSourcesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSourcesClient(client_wrapper=client_wrapper) + self._client_wrapper = client_wrapper + self._groups: typing.Optional[AsyncGroupsClient] = None + + @property + def with_raw_response(self) -> AsyncRawSourcesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSourcesClient + """ + return self._raw_client + + @property + def groups(self): + if self._groups is None: + from .groups.client import AsyncGroupsClient # noqa: E402 + + self._groups = AsyncGroupsClient(client_wrapper=self._client_wrapper) + return self._groups diff --git a/src/auth0/management/users/effective_roles/sources/groups/__init__.py b/src/auth0/management/users/effective_roles/sources/groups/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/auth0/management/users/effective_roles/sources/groups/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/auth0/management/users/effective_roles/sources/groups/client.py b/src/auth0/management/users/effective_roles/sources/groups/client.py new file mode 100644 index 00000000..673aa49e --- /dev/null +++ b/src/auth0/management/users/effective_roles/sources/groups/client.py @@ -0,0 +1,161 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.pagination import AsyncPager, SyncPager +from .....core.request_options import RequestOptions +from .....types.group import Group +from .....types.list_user_role_source_groups_response_content import ListUserRoleSourceGroupsResponseContent +from .raw_client import AsyncRawGroupsClient, RawGroupsClient + + +class GroupsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawGroupsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawGroupsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawGroupsClient + """ + return self._raw_client + + def list( + self, + id: str, + *, + role_id: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Group, ListUserRoleSourceGroupsResponseContent]: + """ + Lists the groups that grant a user a specific role. + + Parameters + ---------- + id : str + ID of the user to list role source groups for. + + role_id : str + ID of the role to get source groups for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Group, ListUserRoleSourceGroupsResponseContent] + User's role source groups successfully retrieved. + + Examples + -------- + from auth0 import Auth0 + + client = Auth0( + token="YOUR_TOKEN", + ) + response = client.users.effective_roles.sources.groups.list( + id="id", + role_id="role_id", + from_="from", + take=1, + ) + for item in response: + yield item + # alternatively, you can paginate page-by-page + for page in response.iter_pages(): + yield page + """ + return self._raw_client.list(id, role_id=role_id, from_=from_, take=take, request_options=request_options) + + +class AsyncGroupsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawGroupsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawGroupsClient + """ + return self._raw_client + + async def list( + self, + id: str, + *, + role_id: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Group, ListUserRoleSourceGroupsResponseContent]: + """ + Lists the groups that grant a user a specific role. + + Parameters + ---------- + id : str + ID of the user to list role source groups for. + + role_id : str + ID of the role to get source groups for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Group, ListUserRoleSourceGroupsResponseContent] + User's role source groups successfully retrieved. + + Examples + -------- + import asyncio + + from auth0 import AsyncAuth0 + + client = AsyncAuth0( + token="YOUR_TOKEN", + ) + + + async def main() -> None: + response = await client.users.effective_roles.sources.groups.list( + id="id", + role_id="role_id", + from_="from", + take=1, + ) + async for item in response: + yield item + + # alternatively, you can paginate page-by-page + async for page in response.iter_pages(): + yield page + + + asyncio.run(main()) + """ + return await self._raw_client.list(id, role_id=role_id, from_=from_, take=take, request_options=request_options) diff --git a/src/auth0/management/users/effective_roles/sources/groups/raw_client.py b/src/auth0/management/users/effective_roles/sources/groups/raw_client.py new file mode 100644 index 00000000..9689408e --- /dev/null +++ b/src/auth0/management/users/effective_roles/sources/groups/raw_client.py @@ -0,0 +1,266 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .....core.api_error import ApiError +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.jsonable_encoder import encode_path_param +from .....core.pagination import AsyncPager, SyncPager +from .....core.parse_error import ParsingError +from .....core.pydantic_utilities import parse_obj_as +from .....core.request_options import RequestOptions +from .....errors.bad_request_error import BadRequestError +from .....errors.forbidden_error import ForbiddenError +from .....errors.too_many_requests_error import TooManyRequestsError +from .....errors.unauthorized_error import UnauthorizedError +from .....types.group import Group +from .....types.list_user_role_source_groups_response_content import ListUserRoleSourceGroupsResponseContent +from pydantic import ValidationError + + +class RawGroupsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + id: str, + *, + role_id: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> SyncPager[Group, ListUserRoleSourceGroupsResponseContent]: + """ + Lists the groups that grant a user a specific role. + + Parameters + ---------- + id : str + ID of the user to list role source groups for. + + role_id : str + ID of the role to get source groups for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SyncPager[Group, ListUserRoleSourceGroupsResponseContent] + User's role source groups successfully retrieved. + """ + _response = self._client_wrapper.httpx_client.request( + f"users/{encode_path_param(id)}/effective-roles/sources/groups", + method="GET", + params={ + "role_id": role_id, + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListUserRoleSourceGroupsResponseContent, + parse_obj_as( + type_=ListUserRoleSourceGroupsResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.groups + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + _get_next = lambda: self.list( + id, + role_id=role_id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawGroupsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + id: str, + *, + role_id: str, + from_: typing.Optional[str] = None, + take: typing.Optional[int] = 50, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncPager[Group, ListUserRoleSourceGroupsResponseContent]: + """ + Lists the groups that grant a user a specific role. + + Parameters + ---------- + id : str + ID of the user to list role source groups for. + + role_id : str + ID of the role to get source groups for. + + from_ : typing.Optional[str] + Optional Id from which to start selection. + + take : typing.Optional[int] + Number of results per page. Defaults to 50. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncPager[Group, ListUserRoleSourceGroupsResponseContent] + User's role source groups successfully retrieved. + """ + _response = await self._client_wrapper.httpx_client.request( + f"users/{encode_path_param(id)}/effective-roles/sources/groups", + method="GET", + params={ + "role_id": role_id, + "from": from_, + "take": take, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _parsed_response = typing.cast( + ListUserRoleSourceGroupsResponseContent, + parse_obj_as( + type_=ListUserRoleSourceGroupsResponseContent, # type: ignore + object_=_response.json(), + ), + ) + _items = _parsed_response.groups + _parsed_next = _parsed_response.next + _has_next = _parsed_next is not None and _parsed_next != "" + + async def _get_next(): + return await self.list( + id, + role_id=role_id, + from_=_parsed_next, + take=take, + request_options=request_options, + ) + + return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 429: + raise TooManyRequestsError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/auth0/management/users/effective_roles/sources/raw_client.py b/src/auth0/management/users/effective_roles/sources/raw_client.py new file mode 100644 index 00000000..e5f566c6 --- /dev/null +++ b/src/auth0/management/users/effective_roles/sources/raw_client.py @@ -0,0 +1,13 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper + + +class RawSourcesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + +class AsyncRawSourcesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper diff --git a/tests/wire/test_organizations_groups.py b/tests/wire/test_organizations_groups.py new file mode 100644 index 00000000..2929e974 --- /dev/null +++ b/tests/wire/test_organizations_groups.py @@ -0,0 +1,13 @@ +from .conftest import get_client, verify_request_count + + +def test_organizations_groups_list_() -> None: + """Test list endpoint with WireMock""" + test_id = "organizations.groups.list_.0" + client = get_client(test_id) + client.organizations.groups.list( + organization_id="organization_id", + from_="from", + take=1, + ) + verify_request_count(test_id, "GET", "/organizations/organization_id/groups", {"from": "from", "take": "1"}, 1) diff --git a/tests/wire/test_organizations_groups_roles.py b/tests/wire/test_organizations_groups_roles.py new file mode 100644 index 00000000..e496c80f --- /dev/null +++ b/tests/wire/test_organizations_groups_roles.py @@ -0,0 +1,40 @@ +from .conftest import get_client, verify_request_count + + +def test_organizations_groups_roles_list_() -> None: + """Test list endpoint with WireMock""" + test_id = "organizations.groups.roles.list_.0" + client = get_client(test_id) + client.organizations.groups.roles.list( + organization_id="organization_id", + group_id="group_id", + from_="from", + take=1, + ) + verify_request_count( + test_id, "GET", "/organizations/organization_id/groups/group_id/roles", {"from": "from", "take": "1"}, 1 + ) + + +def test_organizations_groups_roles_create() -> None: + """Test create endpoint with WireMock""" + test_id = "organizations.groups.roles.create.0" + client = get_client(test_id) + client.organizations.groups.roles.create( + organization_id="organization_id", + group_id="group_id", + roles=["roles"], + ) + verify_request_count(test_id, "POST", "/organizations/organization_id/groups/group_id/roles", None, 1) + + +def test_organizations_groups_roles_delete() -> None: + """Test delete endpoint with WireMock""" + test_id = "organizations.groups.roles.delete.0" + client = get_client(test_id) + client.organizations.groups.roles.delete( + organization_id="organization_id", + group_id="group_id", + roles=["roles"], + ) + verify_request_count(test_id, "DELETE", "/organizations/organization_id/groups/group_id/roles", None, 1) diff --git a/tests/wire/test_organizations_members_effectiveRoles.py b/tests/wire/test_organizations_members_effectiveRoles.py new file mode 100644 index 00000000..db9c8871 --- /dev/null +++ b/tests/wire/test_organizations_members_effectiveRoles.py @@ -0,0 +1,16 @@ +from .conftest import get_client, verify_request_count + + +def test_organizations_members_effectiveRoles_list_() -> None: + """Test list endpoint with WireMock""" + test_id = "organizations.members.effective_roles.list_.0" + client = get_client(test_id) + client.organizations.members.effective_roles.list( + id="id", + user_id="user_id", + from_="from", + take=1, + ) + verify_request_count( + test_id, "GET", "/organizations/id/members/user_id/effective-roles", {"from": "from", "take": "1"}, 1 + ) diff --git a/tests/wire/test_organizations_members_effectiveRoles_sources_groups.py b/tests/wire/test_organizations_members_effectiveRoles_sources_groups.py new file mode 100644 index 00000000..92c4fb71 --- /dev/null +++ b/tests/wire/test_organizations_members_effectiveRoles_sources_groups.py @@ -0,0 +1,21 @@ +from .conftest import get_client, verify_request_count + + +def test_organizations_members_effectiveRoles_sources_groups_list_() -> None: + """Test list endpoint with WireMock""" + test_id = "organizations.members.effective_roles.sources.groups.list_.0" + client = get_client(test_id) + client.organizations.members.effective_roles.sources.groups.list( + id="id", + user_id="user_id", + from_="from", + take=1, + role_id="role_id", + ) + verify_request_count( + test_id, + "GET", + "/organizations/id/members/user_id/effective-roles/sources/groups", + {"from": "from", "take": "1", "role_id": "role_id"}, + 1, + ) diff --git a/tests/wire/test_roles_groups.py b/tests/wire/test_roles_groups.py new file mode 100644 index 00000000..bcfcee01 --- /dev/null +++ b/tests/wire/test_roles_groups.py @@ -0,0 +1,35 @@ +from .conftest import get_client, verify_request_count + + +def test_roles_groups_get() -> None: + """Test get endpoint with WireMock""" + test_id = "roles.groups.get.0" + client = get_client(test_id) + client.roles.groups.get( + id="id", + from_="from", + take=1, + ) + verify_request_count(test_id, "GET", "/roles/id/groups", {"from": "from", "take": "1"}, 1) + + +def test_roles_groups_create() -> None: + """Test create endpoint with WireMock""" + test_id = "roles.groups.create.0" + client = get_client(test_id) + client.roles.groups.create( + id="id", + groups=["groups"], + ) + verify_request_count(test_id, "POST", "/roles/id/groups", None, 1) + + +def test_roles_groups_delete() -> None: + """Test delete endpoint with WireMock""" + test_id = "roles.groups.delete.0" + client = get_client(test_id) + client.roles.groups.delete( + id="id", + groups=["groups"], + ) + verify_request_count(test_id, "DELETE", "/roles/id/groups", None, 1) diff --git a/tests/wire/test_users_effectivePermissions.py b/tests/wire/test_users_effectivePermissions.py new file mode 100644 index 00000000..8ef11df5 --- /dev/null +++ b/tests/wire/test_users_effectivePermissions.py @@ -0,0 +1,20 @@ +from .conftest import get_client, verify_request_count + + +def test_users_effectivePermissions_list_() -> None: + """Test list endpoint with WireMock""" + test_id = "users.effective_permissions.list_.0" + client = get_client(test_id) + client.users.effective_permissions.list( + id="id", + from_="from", + take=1, + resource_server_identifier="resource_server_identifier", + ) + verify_request_count( + test_id, + "GET", + "/users/id/effective-permissions", + {"from": "from", "take": "1", "resource_server_identifier": "resource_server_identifier"}, + 1, + ) diff --git a/tests/wire/test_users_effectivePermissions_sources_roles.py b/tests/wire/test_users_effectivePermissions_sources_roles.py new file mode 100644 index 00000000..ac420b37 --- /dev/null +++ b/tests/wire/test_users_effectivePermissions_sources_roles.py @@ -0,0 +1,26 @@ +from .conftest import get_client, verify_request_count + + +def test_users_effectivePermissions_sources_roles_list_() -> None: + """Test list endpoint with WireMock""" + test_id = "users.effective_permissions.sources.roles.list_.0" + client = get_client(test_id) + client.users.effective_permissions.sources.roles.list( + id="id", + from_="from", + take=1, + resource_server_identifier="resource_server_identifier", + permission_name="permission_name", + ) + verify_request_count( + test_id, + "GET", + "/users/id/effective-permissions/sources/effective-roles", + { + "from": "from", + "take": "1", + "resource_server_identifier": "resource_server_identifier", + "permission_name": "permission_name", + }, + 1, + ) diff --git a/tests/wire/test_users_effectiveRoles.py b/tests/wire/test_users_effectiveRoles.py new file mode 100644 index 00000000..e1fb6379 --- /dev/null +++ b/tests/wire/test_users_effectiveRoles.py @@ -0,0 +1,13 @@ +from .conftest import get_client, verify_request_count + + +def test_users_effectiveRoles_list_() -> None: + """Test list endpoint with WireMock""" + test_id = "users.effective_roles.list_.0" + client = get_client(test_id) + client.users.effective_roles.list( + id="id", + from_="from", + take=1, + ) + verify_request_count(test_id, "GET", "/users/id/effective-roles", {"from": "from", "take": "1"}, 1) diff --git a/tests/wire/test_users_effectiveRoles_sources_groups.py b/tests/wire/test_users_effectiveRoles_sources_groups.py new file mode 100644 index 00000000..755599ff --- /dev/null +++ b/tests/wire/test_users_effectiveRoles_sources_groups.py @@ -0,0 +1,20 @@ +from .conftest import get_client, verify_request_count + + +def test_users_effectiveRoles_sources_groups_list_() -> None: + """Test list endpoint with WireMock""" + test_id = "users.effective_roles.sources.groups.list_.0" + client = get_client(test_id) + client.users.effective_roles.sources.groups.list( + id="id", + role_id="role_id", + from_="from", + take=1, + ) + verify_request_count( + test_id, + "GET", + "/users/id/effective-roles/sources/groups", + {"role_id": "role_id", "from": "from", "take": "1"}, + 1, + ) diff --git a/wiremock/wiremock-mappings.json b/wiremock/wiremock-mappings.json index dc52a4eb..e8ce3de0 100644 --- a/wiremock/wiremock-mappings.json +++ b/wiremock/wiremock-mappings.json @@ -13001,6 +13001,222 @@ } } }, + { + "id": "c4da691c-ffe9-48de-9227-f8ce48855cda", + "name": "Lists the groups that are assigned to the organization. - default", + "request": { + "urlPathTemplate": "/organizations/{organization_id}/groups", + "method": "GET", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "organization_id": { + "equalTo": "organization_id" + } + }, + "queryParameters": { + "from": { + "equalTo": "from" + }, + "take": { + "equalTo": "1" + } + } + }, + "response": { + "status": 200, + "body": "{\n \"groups\": [\n {\n \"id\": \"id\",\n \"name\": \"name\",\n \"external_id\": \"external_id\",\n \"connection_id\": \"connection_id\",\n \"tenant_name\": \"tenant_name\",\n \"created_at\": \"2024-01-15T09:30:00Z\",\n \"updated_at\": \"2024-01-15T09:30:00Z\"\n }\n ],\n \"next\": \"next\"\n}", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "c4da691c-ffe9-48de-9227-f8ce48855cda", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, + { + "id": "25999a58-81d7-488c-9a80-5967b5f1e6ae", + "name": "Lists the roles assigned to a group in the context of an organization. - default", + "request": { + "urlPathTemplate": "/organizations/{organization_id}/groups/{group_id}/roles", + "method": "GET", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "organization_id": { + "equalTo": "organization_id" + }, + "group_id": { + "equalTo": "group_id" + } + }, + "queryParameters": { + "from": { + "equalTo": "from" + }, + "take": { + "equalTo": "1" + } + } + }, + "response": { + "status": 200, + "body": "{\n \"roles\": [\n {\n \"id\": \"id\",\n \"name\": \"name\",\n \"description\": \"description\"\n }\n ],\n \"next\": \"next\"\n}", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "25999a58-81d7-488c-9a80-5967b5f1e6ae", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, + { + "id": "5f66622b-f0dc-4cab-8cb9-c5dd4f868ef6", + "name": "Assigns roles to a group in an organization context. - default", + "request": { + "urlPathTemplate": "/organizations/{organization_id}/groups/{group_id}/roles", + "method": "POST", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "organization_id": { + "equalTo": "organization_id" + }, + "group_id": { + "equalTo": "group_id" + } + } + }, + "response": { + "status": 200, + "body": "\"\"", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "5f66622b-f0dc-4cab-8cb9-c5dd4f868ef6", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, + { + "id": "f3a06a3e-a047-4c64-ad21-52cf3943c125", + "name": "Removes roles assigned to a group in an organization context. - default", + "request": { + "urlPathTemplate": "/organizations/{organization_id}/groups/{group_id}/roles", + "method": "DELETE", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "organization_id": { + "equalTo": "organization_id" + }, + "group_id": { + "equalTo": "group_id" + } + } + }, + "response": { + "status": 200, + "body": "\"\"", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "f3a06a3e-a047-4c64-ad21-52cf3943c125", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, + { + "id": "5927f1a7-b918-4d94-b4f5-66e48d50773d", + "name": "List organization member effective roles. - default", + "request": { + "urlPathTemplate": "/organizations/{id}/members/{user_id}/effective-roles", + "method": "GET", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "id": { + "equalTo": "id" + }, + "user_id": { + "equalTo": "user_id" + } + }, + "queryParameters": { + "from": { + "equalTo": "from" + }, + "take": { + "equalTo": "1" + } + } + }, + "response": { + "status": 200, + "body": "{\n \"roles\": [\n {\n \"id\": \"id\",\n \"name\": \"name\",\n \"description\": \"description\",\n \"sources\": [\n \"direct\"\n ]\n }\n ],\n \"next\": \"next\"\n}", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "5927f1a7-b918-4d94-b4f5-66e48d50773d", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, { "id": "2c099b94-dfed-4bf8-b370-25ceade844b1", "name": "Get user roles assigned to an Organization member - default", @@ -13129,6 +13345,56 @@ } } }, + { + "id": "730f9e46-6a5a-455f-94ce-2b274a2c74f9", + "name": "List organization member role group sources. - default", + "request": { + "urlPathTemplate": "/organizations/{id}/members/{user_id}/effective-roles/sources/groups", + "method": "GET", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "id": { + "equalTo": "id" + }, + "user_id": { + "equalTo": "user_id" + } + }, + "queryParameters": { + "from": { + "equalTo": "from" + }, + "take": { + "equalTo": "1" + }, + "role_id": { + "equalTo": "role_id" + } + } + }, + "response": { + "status": 200, + "body": "{\n \"groups\": [\n {\n \"id\": \"id\",\n \"name\": \"name\",\n \"external_id\": \"external_id\",\n \"connection_id\": \"connection_id\",\n \"tenant_name\": \"tenant_name\",\n \"created_at\": \"2024-01-15T09:30:00Z\",\n \"updated_at\": \"2024-01-15T09:30:00Z\"\n }\n ],\n \"next\": \"next\"\n}", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "730f9e46-6a5a-455f-94ce-2b274a2c74f9", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, { "id": "f02cb8dc-cee0-4470-b69b-596e4d0653f9", "name": "Get render setting configurations for all screens - default", @@ -13572,6 +13838,122 @@ } } }, + { + "id": "25c64235-59ca-41e7-a5b7-7431295591d4", + "name": "Get a role's groups - default", + "request": { + "urlPathTemplate": "/roles/{id}/groups", + "method": "GET", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "id": { + "equalTo": "id" + } + }, + "queryParameters": { + "from": { + "equalTo": "from" + }, + "take": { + "equalTo": "1" + } + } + }, + "response": { + "status": 200, + "body": "{\n \"groups\": [\n {\n \"id\": \"id\",\n \"name\": \"name\",\n \"external_id\": \"external_id\",\n \"connection_id\": \"connection_id\",\n \"tenant_name\": \"tenant_name\",\n \"created_at\": \"2024-01-15T09:30:00Z\",\n \"updated_at\": \"2024-01-15T09:30:00Z\"\n }\n ],\n \"next\": \"next\"\n}", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "25c64235-59ca-41e7-a5b7-7431295591d4", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, + { + "id": "1b19f0e9-b733-4cf4-99e5-7536043c1d8b", + "name": "Assign groups to a role - default", + "request": { + "urlPathTemplate": "/roles/{id}/groups", + "method": "POST", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "id": { + "equalTo": "id" + } + } + }, + "response": { + "status": 200, + "body": "\"\"", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "1b19f0e9-b733-4cf4-99e5-7536043c1d8b", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, + { + "id": "e7233c54-c20d-4709-baea-47148eb72066", + "name": "Remove groups from a role - default", + "request": { + "urlPathTemplate": "/roles/{id}/groups", + "method": "DELETE", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "id": { + "equalTo": "id" + } + } + }, + "response": { + "status": 200, + "body": "\"\"", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "e7233c54-c20d-4709-baea-47148eb72066", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, { "id": "bf10686c-2651-4040-8299-93e4bbc9834d", "name": "Get permissions granted by role - default", @@ -14353,6 +14735,97 @@ } } }, + { + "id": "275c2e74-3552-46aa-bd98-e7945f609962", + "name": "Lists the permissions assigned to a user directly or through roles or groups. - default", + "request": { + "urlPathTemplate": "/users/{id}/effective-permissions", + "method": "GET", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "id": { + "equalTo": "id" + } + }, + "queryParameters": { + "from": { + "equalTo": "from" + }, + "take": { + "equalTo": "1" + }, + "resource_server_identifier": { + "equalTo": "resource_server_identifier" + } + } + }, + "response": { + "status": 200, + "body": "{\n \"permissions\": [\n {\n \"resource_server_identifier\": \"resource_server_identifier\",\n \"permission_name\": \"permission_name\",\n \"resource_server_name\": \"resource_server_name\",\n \"description\": \"description\",\n \"sources\": [\n \"direct\"\n ]\n }\n ],\n \"next\": \"next\"\n}", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "275c2e74-3552-46aa-bd98-e7945f609962", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, + { + "id": "0a1118c7-87a0-4e15-a026-c26ae69fc942", + "name": "Lists the roles for a user with sources: directly assigned or through group membership. - default", + "request": { + "urlPathTemplate": "/users/{id}/effective-roles", + "method": "GET", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "id": { + "equalTo": "id" + } + }, + "queryParameters": { + "from": { + "equalTo": "from" + }, + "take": { + "equalTo": "1" + } + } + }, + "response": { + "status": 200, + "body": "{\n \"roles\": [\n {\n \"id\": \"id\",\n \"name\": \"name\",\n \"description\": \"description\",\n \"sources\": [\n \"direct\"\n ]\n }\n ],\n \"next\": \"next\"\n}", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "0a1118c7-87a0-4e15-a026-c26ae69fc942", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, { "id": "b12cc020-548e-4219-bf5f-7896e003fa92", "name": "Get the First Confirmed Multi-factor Authentication (MFA) Enrollment - default", @@ -15198,6 +15671,103 @@ } } }, + { + "id": "bb869da8-6539-45f5-82b2-96dba9672d2b", + "name": "Lists the roles which grant the user a given permission (whether directly or through groups). - default", + "request": { + "urlPathTemplate": "/users/{id}/effective-permissions/sources/effective-roles", + "method": "GET", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "id": { + "equalTo": "id" + } + }, + "queryParameters": { + "from": { + "equalTo": "from" + }, + "take": { + "equalTo": "1" + }, + "resource_server_identifier": { + "equalTo": "resource_server_identifier" + }, + "permission_name": { + "equalTo": "permission_name" + } + } + }, + "response": { + "status": 200, + "body": "{\n \"roles\": [\n {\n \"id\": \"id\",\n \"name\": \"name\",\n \"description\": \"description\",\n \"sources\": [\n \"direct\"\n ]\n }\n ],\n \"next\": \"next\"\n}", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "bb869da8-6539-45f5-82b2-96dba9672d2b", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, + { + "id": "6d4f49b1-9731-4224-af65-0673be60a0c1", + "name": "Get a user's role source groups - default", + "request": { + "urlPathTemplate": "/users/{id}/effective-roles/sources/groups", + "method": "GET", + "headers": { + "Authorization": { + "matches": "Bearer .+" + } + }, + "pathParameters": { + "id": { + "equalTo": "id" + } + }, + "queryParameters": { + "role_id": { + "equalTo": "role_id" + }, + "from": { + "equalTo": "from" + }, + "take": { + "equalTo": "1" + } + } + }, + "response": { + "status": 200, + "body": "{\n \"groups\": [\n {\n \"id\": \"id\",\n \"name\": \"name\",\n \"external_id\": \"external_id\",\n \"connection_id\": \"connection_id\",\n \"tenant_name\": \"tenant_name\",\n \"created_at\": \"2024-01-15T09:30:00Z\",\n \"updated_at\": \"2024-01-15T09:30:00Z\"\n }\n ],\n \"next\": \"next\"\n}", + "headers": { + "Content-Type": "application/json" + } + }, + "uuid": "6d4f49b1-9731-4224-af65-0673be60a0c1", + "persistent": true, + "priority": 3, + "metadata": { + "mocklab": { + "created": { + "at": "2020-01-01T00:00:00.000Z", + "via": "SYSTEM" + } + } + } + }, { "id": "e370a2a2-5b39-4ba1-ac2b-4b5be9ef38f2", "name": "List verifiable credential templates for a tenant. - default", @@ -15379,6 +15949,6 @@ } ], "meta": { - "total": 414 + "total": 427 } } \ No newline at end of file From 82c3190f8671fd68bb49df78cb5f2e0322463772 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 26 May 2026 15:18:36 +0000 Subject: [PATCH 2/2] [fern-replay] Applied customizations Patches applied (2): - patch-4894603d: chore: Restore custom wiring in management/__init__.py - patch-7271f157: Revert wrapper file to preserve Auth0 telemetry customizations --- .fern/replay.lock | 261 +++++++++++++++++++- src/auth0/management/__init__.py | 11 + src/auth0/management/core/client_wrapper.py | 22 +- 3 files changed, 275 insertions(+), 19 deletions(-) diff --git a/.fern/replay.lock b/.fern/replay.lock index 8cba18a2..fe66dab4 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -31,22 +31,28 @@ generations: cli_version: unknown generator_versions: fernapi/fern-python-sdk: 5.12.10 -current_generation: a6b05e768329fac22fd4da6fbe711006e23029f8 + - commit_sha: 15127abb8ab299907925c41e89122d50dbe138d5 + tree_hash: 30ecce30237e3fb542f943c41737d2126c647e77 + timestamp: 2026-05-26T15:18:29.669Z + cli_version: unknown + generator_versions: + fernapi/fern-python-sdk: 5.14.3 +current_generation: 15127abb8ab299907925c41e89122d50dbe138d5 patches: - id: patch-4894603d - content_hash: sha256:09d8cd6f9f5c2aee1d72f67be687d870c9145144262b28f81513c64915494584 + content_hash: sha256:2c5caf4188d616dc6d0a85d59c179069d6a73a541af915ce9b8c3340c97afd31 original_commit: 4894603d03409962bc60a34712de8abffe919e2c original_message: "chore: Restore custom wiring in management/__init__.py" original_author: Kunal Dawar - base_generation: a6b05e768329fac22fd4da6fbe711006e23029f8 + base_generation: 15127abb8ab299907925c41e89122d50dbe138d5 files: - src/auth0/management/__init__.py patch_content: | diff --git a/src/auth0/management/__init__.py b/src/auth0/management/__init__.py - index 71b8e8c..ecd00f0 100644 + index a48ff10..46ef694 100644 --- a/src/auth0/management/__init__.py +++ b/src/auth0/management/__init__.py - @@ -2766,6 +2766,8 @@ if typing.TYPE_CHECKING: + @@ -2783,6 +2783,8 @@ if typing.TYPE_CHECKING: from .environment import Auth0Environment from .event_streams import EventStreamsCreateRequest from .version import __version__ @@ -55,7 +61,7 @@ patches: _dynamic_imports: typing.Dict[str, str] = { "Action": ".types", "ActionBase": ".types", - @@ -2826,6 +2828,8 @@ _dynamic_imports: typing.Dict[str, str] = { + @@ -2843,6 +2845,8 @@ _dynamic_imports: typing.Dict[str, str] = { "AssociateOrganizationClientGrantResponseContent": ".types", "AsyncApprovalNotificationsChannelsEnum": ".types", "AsyncAuth0": ".client", @@ -64,7 +70,7 @@ patches: "AttackProtectionCaptchaArkoseResponseContent": ".types", "AttackProtectionCaptchaAuthChallengeRequest": ".types", "AttackProtectionCaptchaAuthChallengeResponseContent": ".types", - @@ -3785,6 +3789,7 @@ _dynamic_imports: typing.Dict[str, str] = { + @@ -3802,6 +3806,7 @@ _dynamic_imports: typing.Dict[str, str] = { "CredentialDeviceTypeEnum": ".types", "CredentialId": ".types", "CustomDomain": ".types", @@ -72,7 +78,7 @@ patches: "CustomDomainCustomClientIpHeader": ".types", "CustomDomainCustomClientIpHeaderEnum": ".types", "CustomDomainProvisioningTypeEnum": ".types", - @@ -5047,6 +5052,7 @@ _dynamic_imports: typing.Dict[str, str] = { + @@ -5073,6 +5078,7 @@ _dynamic_imports: typing.Dict[str, str] = { "LogStreamSumoEnum": ".types", "LogStreamSumoResponseSchema": ".types", "LogStreamSumoSink": ".types", @@ -80,7 +86,7 @@ patches: "MdlPresentationProperties": ".types", "MdlPresentationRequest": ".types", "MdlPresentationRequestProperties": ".types", - @@ -5290,6 +5296,7 @@ _dynamic_imports: typing.Dict[str, str] = { + @@ -5318,6 +5324,7 @@ _dynamic_imports: typing.Dict[str, str] = { "TokenQuota": ".types", "TokenQuotaClientCredentials": ".types", "TokenQuotaConfiguration": ".types", @@ -88,7 +94,7 @@ patches: "TooManyRequestsError": ".errors", "TooManyRequestsSchema": ".types", "TooManyRequestsSchemaError": ".types", - @@ -5607,6 +5614,8 @@ __all__ = [ + @@ -5641,6 +5648,8 @@ __all__ = [ "AssociateOrganizationClientGrantResponseContent", "AsyncApprovalNotificationsChannelsEnum", "AsyncAuth0", @@ -97,7 +103,7 @@ patches: "AttackProtectionCaptchaArkoseResponseContent", "AttackProtectionCaptchaAuthChallengeRequest", "AttackProtectionCaptchaAuthChallengeResponseContent", - @@ -7828,6 +7837,7 @@ __all__ = [ + @@ -7871,6 +7880,7 @@ __all__ = [ "LogStreamSumoEnum", "LogStreamSumoResponseSchema", "LogStreamSumoSink", @@ -105,7 +111,7 @@ patches: "MdlPresentationProperties", "MdlPresentationRequest", "MdlPresentationRequestProperties", - @@ -8068,6 +8078,7 @@ __all__ = [ + @@ -8113,6 +8123,7 @@ __all__ = [ "TestEventDataContent", "TokenExchangeProfileResponseContent", "TokenExchangeProfileTypeEnum", @@ -2315,7 +2321,11 @@ patches: ListOrganizationClientGrantsOffsetPaginatedResponseContent, ListOrganizationConnectionsOffsetPaginatedResponseContent, ListOrganizationDiscoveryDomainsResponseContent, + ListOrganizationGroupRolesResponseContent, + ListOrganizationGroupsResponseContent, ListOrganizationInvitationsOffsetPaginatedResponseContent, + ListOrganizationMemberEffectiveRolesResponseContent, + ListOrganizationMemberRoleSourceGroupsResponseContent, ListOrganizationMemberRolesOffsetPaginatedResponseContent, ListOrganizationMembersPaginatedResponseContent, ListOrganizationsPaginatedResponseContent, @@ -2323,6 +2333,7 @@ patches: ListRateLimitPoliciesPaginatedResponseContent, ListRefreshTokensPaginatedResponseContent, ListResourceServerOffsetPaginatedResponseContent, + ListRoleGroupsResponseContent, ListRolePermissionsOffsetPaginatedResponseContent, ListRoleUsersPaginatedResponseContent, ListRolesOffsetPaginatedResponseContent, @@ -2338,9 +2349,13 @@ patches: ListUserBlocksByIdentifierResponseContent, ListUserBlocksResponseContent, ListUserConnectedAccountsResponseContent, + ListUserEffectivePermissionRoleSourcesResponseContent, + ListUserEffectivePermissionsResponseContent, + ListUserEffectiveRolesResponseContent, ListUserGrantsOffsetPaginatedResponseContent, ListUserOrganizationsOffsetPaginatedResponseContent, ListUserPermissionsOffsetPaginatedResponseContent, + ListUserRoleSourceGroupsResponseContent, ListUserRolesOffsetPaginatedResponseContent, ListUserSessionsPaginatedResponseContent, ListUsersOffsetPaginatedResponseContent, @@ -2430,6 +2445,8 @@ patches: OrganizationInvitationInvitee, OrganizationInvitationInviter, OrganizationMember, + OrganizationMemberEffectiveRole, + OrganizationMemberEffectiveRoleSource, OrganizationMemberRole, OrganizationMetadata, OrganizationUsageEnum, @@ -2791,6 +2808,12 @@ patches: UserAuthenticationMethodPropertiesEnum, UserBlockIdentifier, UserDateSchema, + UserEffectivePermissionResponseContent, + UserEffectivePermissionRoleSourceEnum, + UserEffectivePermissionRoleSourceResponseContent, + UserEffectivePermissionSourceEnum, + UserEffectiveRole, + UserEffectiveRoleSource, UserEnrollmentAuthMethodEnum, UserEnrollmentStatusEnum, UserGrant, @@ -5092,7 +5115,11 @@ patches: "ListOrganizationClientGrantsOffsetPaginatedResponseContent": ".types", "ListOrganizationConnectionsOffsetPaginatedResponseContent": ".types", "ListOrganizationDiscoveryDomainsResponseContent": ".types", + "ListOrganizationGroupRolesResponseContent": ".types", + "ListOrganizationGroupsResponseContent": ".types", "ListOrganizationInvitationsOffsetPaginatedResponseContent": ".types", + "ListOrganizationMemberEffectiveRolesResponseContent": ".types", + "ListOrganizationMemberRoleSourceGroupsResponseContent": ".types", "ListOrganizationMemberRolesOffsetPaginatedResponseContent": ".types", "ListOrganizationMembersPaginatedResponseContent": ".types", "ListOrganizationsPaginatedResponseContent": ".types", @@ -5100,6 +5127,7 @@ patches: "ListRateLimitPoliciesPaginatedResponseContent": ".types", "ListRefreshTokensPaginatedResponseContent": ".types", "ListResourceServerOffsetPaginatedResponseContent": ".types", + "ListRoleGroupsResponseContent": ".types", "ListRolePermissionsOffsetPaginatedResponseContent": ".types", "ListRoleUsersPaginatedResponseContent": ".types", "ListRolesOffsetPaginatedResponseContent": ".types", @@ -5115,9 +5143,13 @@ patches: "ListUserBlocksByIdentifierResponseContent": ".types", "ListUserBlocksResponseContent": ".types", "ListUserConnectedAccountsResponseContent": ".types", + "ListUserEffectivePermissionRoleSourcesResponseContent": ".types", + "ListUserEffectivePermissionsResponseContent": ".types", + "ListUserEffectiveRolesResponseContent": ".types", "ListUserGrantsOffsetPaginatedResponseContent": ".types", "ListUserOrganizationsOffsetPaginatedResponseContent": ".types", "ListUserPermissionsOffsetPaginatedResponseContent": ".types", + "ListUserRoleSourceGroupsResponseContent": ".types", "ListUserRolesOffsetPaginatedResponseContent": ".types", "ListUserSessionsPaginatedResponseContent": ".types", "ListUsersOffsetPaginatedResponseContent": ".types", @@ -5209,6 +5241,8 @@ patches: "OrganizationInvitationInvitee": ".types", "OrganizationInvitationInviter": ".types", "OrganizationMember": ".types", + "OrganizationMemberEffectiveRole": ".types", + "OrganizationMemberEffectiveRoleSource": ".types", "OrganizationMemberRole": ".types", "OrganizationMetadata": ".types", "OrganizationUsageEnum": ".types", @@ -5576,6 +5610,12 @@ patches: "UserAuthenticationMethodPropertiesEnum": ".types", "UserBlockIdentifier": ".types", "UserDateSchema": ".types", + "UserEffectivePermissionResponseContent": ".types", + "UserEffectivePermissionRoleSourceEnum": ".types", + "UserEffectivePermissionRoleSourceResponseContent": ".types", + "UserEffectivePermissionSourceEnum": ".types", + "UserEffectiveRole": ".types", + "UserEffectiveRoleSource": ".types", "UserEnrollmentAuthMethodEnum": ".types", "UserEnrollmentStatusEnum": ".types", "UserGrant": ".types", @@ -7877,7 +7917,11 @@ patches: "ListOrganizationClientGrantsOffsetPaginatedResponseContent", "ListOrganizationConnectionsOffsetPaginatedResponseContent", "ListOrganizationDiscoveryDomainsResponseContent", + "ListOrganizationGroupRolesResponseContent", + "ListOrganizationGroupsResponseContent", "ListOrganizationInvitationsOffsetPaginatedResponseContent", + "ListOrganizationMemberEffectiveRolesResponseContent", + "ListOrganizationMemberRoleSourceGroupsResponseContent", "ListOrganizationMemberRolesOffsetPaginatedResponseContent", "ListOrganizationMembersPaginatedResponseContent", "ListOrganizationsPaginatedResponseContent", @@ -7885,6 +7929,7 @@ patches: "ListRateLimitPoliciesPaginatedResponseContent", "ListRefreshTokensPaginatedResponseContent", "ListResourceServerOffsetPaginatedResponseContent", + "ListRoleGroupsResponseContent", "ListRolePermissionsOffsetPaginatedResponseContent", "ListRoleUsersPaginatedResponseContent", "ListRolesOffsetPaginatedResponseContent", @@ -7900,9 +7945,13 @@ patches: "ListUserBlocksByIdentifierResponseContent", "ListUserBlocksResponseContent", "ListUserConnectedAccountsResponseContent", + "ListUserEffectivePermissionRoleSourcesResponseContent", + "ListUserEffectivePermissionsResponseContent", + "ListUserEffectiveRolesResponseContent", "ListUserGrantsOffsetPaginatedResponseContent", "ListUserOrganizationsOffsetPaginatedResponseContent", "ListUserPermissionsOffsetPaginatedResponseContent", + "ListUserRoleSourceGroupsResponseContent", "ListUserRolesOffsetPaginatedResponseContent", "ListUserSessionsPaginatedResponseContent", "ListUsersOffsetPaginatedResponseContent", @@ -7994,6 +8043,8 @@ patches: "OrganizationInvitationInvitee", "OrganizationInvitationInviter", "OrganizationMember", + "OrganizationMemberEffectiveRole", + "OrganizationMemberEffectiveRoleSource", "OrganizationMemberRole", "OrganizationMetadata", "OrganizationUsageEnum", @@ -8361,6 +8412,12 @@ patches: "UserAuthenticationMethodPropertiesEnum", "UserBlockIdentifier", "UserDateSchema", + "UserEffectivePermissionResponseContent", + "UserEffectivePermissionRoleSourceEnum", + "UserEffectivePermissionRoleSourceResponseContent", + "UserEffectivePermissionSourceEnum", + "UserEffectiveRole", + "UserEffectiveRoleSource", "UserEnrollmentAuthMethodEnum", "UserEnrollmentStatusEnum", "UserGrant", @@ -8434,3 +8491,183 @@ patches: "verifiable_credentials", ] user_owned: true + - id: patch-7271f157 + content_hash: sha256:e5f014e7f8c379a0b7c3815222df83e115d542c5c9685b2a9d16285e1d18f800 + original_commit: 7271f15759cfb545c9ef82b5a4f519ffe0a89db2 + original_message: Revert wrapper file to preserve Auth0 telemetry customizations + original_author: Kunal Dawar + base_generation: 15127abb8ab299907925c41e89122d50dbe138d5 + files: + - src/auth0/management/core/client_wrapper.py + patch_content: | + diff --git a/src/auth0/management/core/client_wrapper.py b/src/auth0/management/core/client_wrapper.py + index cad2e31..60ebc5a 100644 + --- a/src/auth0/management/core/client_wrapper.py + +++ b/src/auth0/management/core/client_wrapper.py + @@ -1,6 +1,11 @@ + # This file was auto-generated by Fern from our API Definition. + +# Modified by Auth0 to use Auth0 telemetry format with dynamic versioning + + +import base64 + +import platform + +import sys + import typing + +from json import dumps + + import httpx + from .http_client import AsyncHttpClient, HttpClient + @@ -26,15 +31,18 @@ class BaseClientWrapper: + self._logging = logging + + def get_headers(self) -> typing.Dict[str, str]: + - import platform + + py_version = platform.python_version() + + version = sys.modules["auth0"].__version__ + + + + auth0_client = dumps({ + + "name": "auth0-python", + + "version": version, + + "env": {"python": py_version} + + }).encode("utf-8") + + headers: typing.Dict[str, str] = { + - "User-Agent": "auth0-python/5.5.0", + - "X-Fern-Language": "Python", + - "X-Fern-Runtime": f"python/{platform.python_version()}", + - "X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}", + - "X-Fern-SDK-Name": "auth0-python", + - "X-Fern-SDK-Version": "5.5.0", + + "User-Agent": f"Python/{py_version}", + + "Auth0-Client": base64.b64encode(auth0_client).decode(), + **(self.get_custom_headers() or {}), + } + headers["Authorization"] = f"Bearer {self._get_token()}" + theirs_snapshot: + src/auth0/management/core/client_wrapper.py: | + # This file was auto-generated by Fern from our API Definition. + # Modified by Auth0 to use Auth0 telemetry format with dynamic versioning + + import base64 + import platform + import sys + import typing + from json import dumps + + import httpx + from .http_client import AsyncHttpClient, HttpClient + from .logging import LogConfig, Logger + + + class BaseClientWrapper: + def __init__( + self, + *, + token: typing.Union[str, typing.Callable[[], str]], + headers: typing.Optional[typing.Dict[str, str]] = None, + base_url: str, + timeout: typing.Optional[float] = None, + max_retries: int = 2, + logging: typing.Optional[typing.Union[LogConfig, Logger]] = None, + ): + self._token = token + self._headers = headers + self._base_url = base_url + self._timeout = timeout + self._max_retries = max_retries + self._logging = logging + + def get_headers(self) -> typing.Dict[str, str]: + py_version = platform.python_version() + version = sys.modules["auth0"].__version__ + + auth0_client = dumps({ + "name": "auth0-python", + "version": version, + "env": {"python": py_version} + }).encode("utf-8") + + headers: typing.Dict[str, str] = { + "User-Agent": f"Python/{py_version}", + "Auth0-Client": base64.b64encode(auth0_client).decode(), + **(self.get_custom_headers() or {}), + } + headers["Authorization"] = f"Bearer {self._get_token()}" + return headers + + def _get_token(self) -> str: + if isinstance(self._token, str): + return self._token + else: + return self._token() + + def get_custom_headers(self) -> typing.Optional[typing.Dict[str, str]]: + return self._headers + + def get_base_url(self) -> str: + return self._base_url + + def get_timeout(self) -> typing.Optional[float]: + return self._timeout + + def get_max_retries(self) -> int: + return self._max_retries + + + class SyncClientWrapper(BaseClientWrapper): + def __init__( + self, + *, + token: typing.Union[str, typing.Callable[[], str]], + headers: typing.Optional[typing.Dict[str, str]] = None, + base_url: str, + timeout: typing.Optional[float] = None, + max_retries: int = 2, + logging: typing.Optional[typing.Union[LogConfig, Logger]] = None, + httpx_client: httpx.Client, + ): + super().__init__( + token=token, headers=headers, base_url=base_url, timeout=timeout, max_retries=max_retries, logging=logging + ) + self.httpx_client = HttpClient( + httpx_client=httpx_client, + base_headers=self.get_headers, + base_timeout=self.get_timeout, + base_url=self.get_base_url, + base_max_retries=self.get_max_retries(), + logging_config=self._logging, + ) + + + class AsyncClientWrapper(BaseClientWrapper): + def __init__( + self, + *, + token: typing.Union[str, typing.Callable[[], str]], + headers: typing.Optional[typing.Dict[str, str]] = None, + base_url: str, + timeout: typing.Optional[float] = None, + max_retries: int = 2, + logging: typing.Optional[typing.Union[LogConfig, Logger]] = None, + async_token: typing.Optional[typing.Callable[[], typing.Awaitable[str]]] = None, + httpx_client: httpx.AsyncClient, + ): + super().__init__( + token=token, headers=headers, base_url=base_url, timeout=timeout, max_retries=max_retries, logging=logging + ) + self._async_token = async_token + self.httpx_client = AsyncHttpClient( + httpx_client=httpx_client, + base_headers=self.get_headers, + base_timeout=self.get_timeout, + base_url=self.get_base_url, + base_max_retries=self.get_max_retries(), + async_base_headers=self.async_get_headers, + logging_config=self._logging, + ) + + async def async_get_headers(self) -> typing.Dict[str, str]: + headers = self.get_headers() + if self._async_token is not None: + token = await self._async_token() + headers["Authorization"] = f"Bearer {token}" + return headers diff --git a/src/auth0/management/__init__.py b/src/auth0/management/__init__.py index a48ff10f..46ef6942 100644 --- a/src/auth0/management/__init__.py +++ b/src/auth0/management/__init__.py @@ -2783,6 +2783,8 @@ from .environment import Auth0Environment from .event_streams import EventStreamsCreateRequest from .version import __version__ + from .management_client import AsyncManagementClient, CustomDomainHeader, ManagementClient + from .token_provider import AsyncTokenProvider, TokenProvider _dynamic_imports: typing.Dict[str, str] = { "Action": ".types", "ActionBase": ".types", @@ -2843,6 +2845,8 @@ "AssociateOrganizationClientGrantResponseContent": ".types", "AsyncApprovalNotificationsChannelsEnum": ".types", "AsyncAuth0": ".client", + "AsyncManagementClient": ".management_client", + "AsyncTokenProvider": ".token_provider", "AttackProtectionCaptchaArkoseResponseContent": ".types", "AttackProtectionCaptchaAuthChallengeRequest": ".types", "AttackProtectionCaptchaAuthChallengeResponseContent": ".types", @@ -3802,6 +3806,7 @@ "CredentialDeviceTypeEnum": ".types", "CredentialId": ".types", "CustomDomain": ".types", + "CustomDomainHeader": ".management_client", "CustomDomainCustomClientIpHeader": ".types", "CustomDomainCustomClientIpHeaderEnum": ".types", "CustomDomainProvisioningTypeEnum": ".types", @@ -5073,6 +5078,7 @@ "LogStreamSumoEnum": ".types", "LogStreamSumoResponseSchema": ".types", "LogStreamSumoSink": ".types", + "ManagementClient": ".management_client", "MdlPresentationProperties": ".types", "MdlPresentationRequest": ".types", "MdlPresentationRequestProperties": ".types", @@ -5318,6 +5324,7 @@ "TokenQuota": ".types", "TokenQuotaClientCredentials": ".types", "TokenQuotaConfiguration": ".types", + "TokenProvider": ".token_provider", "TooManyRequestsError": ".errors", "TooManyRequestsSchema": ".types", "TooManyRequestsSchemaError": ".types", @@ -5641,6 +5648,8 @@ def __dir__(): "AssociateOrganizationClientGrantResponseContent", "AsyncApprovalNotificationsChannelsEnum", "AsyncAuth0", + "AsyncManagementClient", + "AsyncTokenProvider", "AttackProtectionCaptchaArkoseResponseContent", "AttackProtectionCaptchaAuthChallengeRequest", "AttackProtectionCaptchaAuthChallengeResponseContent", @@ -7871,6 +7880,7 @@ def __dir__(): "LogStreamSumoEnum", "LogStreamSumoResponseSchema", "LogStreamSumoSink", + "ManagementClient", "MdlPresentationProperties", "MdlPresentationRequest", "MdlPresentationRequestProperties", @@ -8113,6 +8123,7 @@ def __dir__(): "TestEventDataContent", "TokenExchangeProfileResponseContent", "TokenExchangeProfileTypeEnum", + "TokenProvider", "TokenQuota", "TokenQuotaClientCredentials", "TokenQuotaConfiguration", diff --git a/src/auth0/management/core/client_wrapper.py b/src/auth0/management/core/client_wrapper.py index cad2e314..60ebc5a6 100644 --- a/src/auth0/management/core/client_wrapper.py +++ b/src/auth0/management/core/client_wrapper.py @@ -1,6 +1,11 @@ # This file was auto-generated by Fern from our API Definition. +# Modified by Auth0 to use Auth0 telemetry format with dynamic versioning +import base64 +import platform +import sys import typing +from json import dumps import httpx from .http_client import AsyncHttpClient, HttpClient @@ -26,15 +31,18 @@ def __init__( self._logging = logging def get_headers(self) -> typing.Dict[str, str]: - import platform + py_version = platform.python_version() + version = sys.modules["auth0"].__version__ + + auth0_client = dumps({ + "name": "auth0-python", + "version": version, + "env": {"python": py_version} + }).encode("utf-8") headers: typing.Dict[str, str] = { - "User-Agent": "auth0-python/5.5.0", - "X-Fern-Language": "Python", - "X-Fern-Runtime": f"python/{platform.python_version()}", - "X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}", - "X-Fern-SDK-Name": "auth0-python", - "X-Fern-SDK-Version": "5.5.0", + "User-Agent": f"Python/{py_version}", + "Auth0-Client": base64.b64encode(auth0_client).decode(), **(self.get_custom_headers() or {}), } headers["Authorization"] = f"Bearer {self._get_token()}"