From 0ea9fd8205d4d9162391dd9e01eb7588f19744a5 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2026 14:50:42 +0000 Subject: [PATCH 1/3] [fern-generated] Update SDK Generated by Fern CLI Version: unknown Generators: - fernapi/fern-csharp-sdk: 2.72.1 --- reference.md | 285 ++++-- .../Actions/ActionsClient.cs | 633 ++++++++++--- .../Actions/Executions/ExecutionsClient.cs | 82 +- .../Actions/IActionsClient.cs | 2 +- .../Actions/Modules/IModulesClient.cs | 2 +- .../Actions/Modules/ModulesClient.cs | 698 +++++++++++--- .../Modules/Versions/VersionsClient.cs | 252 ++++- .../Triggers/Bindings/BindingsClient.cs | 136 ++- .../Actions/Triggers/TriggersClient.cs | 70 +- .../Actions/Versions/VersionsClient.cs | 218 ++++- .../Anomaly/Blocks/BlocksClient.cs | 192 +++- .../Anomaly/Blocks/IBlocksClient.cs | 4 +- .../BotDetection/BotDetectionClient.cs | 152 ++- .../BreachedPasswordDetectionClient.cs | 128 ++- .../BruteForceProtectionClient.cs | 128 ++- .../AttackProtection/Captcha/CaptchaClient.cs | 140 ++- .../PhoneProviderProtectionClient.cs | 128 ++- .../SuspiciousIpThrottlingClient.cs | 128 ++- .../Auth0.ManagementApi.csproj | 2 +- .../Branding/BrandingClient.cs | 128 ++- .../Phone/Providers/IProvidersClient.cs | 2 +- .../Phone/Providers/ProvidersClient.cs | 590 ++++++++++-- .../Phone/Templates/ITemplatesClient.cs | 2 +- .../Phone/Templates/TemplatesClient.cs | 650 +++++++++++-- .../Branding/Templates/ITemplatesClient.cs | 4 +- .../Branding/Templates/TemplatesClient.cs | 353 +++++-- .../Branding/Themes/IThemesClient.cs | 2 +- .../Branding/Themes/ThemesClient.cs | 476 ++++++++-- .../ClientGrants/ClientGrantsClient.cs | 472 ++++++++-- .../ClientGrants/IClientGrantsClient.cs | 2 +- .../Organizations/OrganizationsClient.cs | 78 +- .../Clients/ClientsClient.cs | 732 ++++++++++++--- .../Clients/Connections/ConnectionsClient.cs | 78 +- .../Clients/Credentials/CredentialsClient.cs | 481 ++++++++-- .../Clients/Credentials/ICredentialsClient.cs | 2 +- .../Clients/IClientsClient.cs | 2 +- .../ConnectionProfilesClient.cs | 586 ++++++++++-- .../IConnectionProfilesClient.cs | 2 +- .../Connections/Clients/ClientsClient.cs | 267 ++++-- .../Connections/Clients/IClientsClient.cs | 2 +- .../Connections/ConnectionsClient.cs | 672 +++++++++++--- .../DirectoryProvisioningClient.cs | 875 ++++++++++++++---- .../IDirectoryProvisioningClient.cs | 4 +- .../SynchronizationsClient.cs | 94 +- .../Connections/IConnectionsClient.cs | 4 +- .../Connections/Keys/KeysClient.cs | 258 +++++- .../IScimConfigurationClient.cs | 2 +- .../ScimConfigurationClient.cs | 394 ++++++-- .../ScimConfiguration/Tokens/ITokensClient.cs | 2 +- .../ScimConfiguration/Tokens/TokensClient.cs | 247 +++-- .../Connections/Users/IUsersClient.cs | 2 +- .../Connections/Users/UsersClient.cs | 107 ++- .../Core/IRequestOptions.cs | 24 + .../Core/JsonConfiguration.cs | 1 - src/Auth0.ManagementApi/Core/Page.cs | 9 +- src/Auth0.ManagementApi/Core/Pager.cs | 6 +- .../Core/Public/ClientOptions.cs | 2 +- .../Core/Public/ManagementApiException.cs | 8 +- .../Core/Public/RequestOptions.cs | 24 + .../Core/Public/WithRawResponseStream.cs | 66 ++ .../Core/Public/WithRawResponseTask.cs | 43 + src/Auth0.ManagementApi/Core/RawClient.cs | 51 +- .../Core/SseReconnectHelper.cs | 210 +++++ .../CustomDomains/CustomDomainsClient.cs | 742 ++++++++++++--- .../CustomDomains/ICustomDomainsClient.cs | 2 +- .../DeviceCredentialsClient.cs | 320 +++++-- .../IDeviceCredentialsClient.cs | 2 +- .../EmailTemplates/EmailTemplatesClient.cs | 316 ++++++- .../Emails/Provider/IProviderClient.cs | 5 +- .../Emails/Provider/ProviderClient.cs | 433 +++++++-- .../Deliveries/DeliveriesClient.cs | 148 ++- .../EventStreams/EventStreamsClient.cs | 520 +++++++++-- .../EventStreams/IEventStreamsClient.cs | 2 +- .../Redeliveries/IRedeliveriesClient.cs | 2 +- .../Redeliveries/RedeliveriesClient.cs | 217 ++++- .../Events/EventsClient.cs | 234 +++-- .../Events/IEventsClient.cs | 2 +- .../Exceptions/BadRequestError.cs | 3 +- .../Exceptions/ConflictError.cs | 3 +- .../Exceptions/ContentTooLargeError.cs | 4 +- .../Exceptions/ForbiddenError.cs | 3 +- .../Exceptions/GoneError.cs | 3 +- .../Exceptions/InternalServerError.cs | 4 +- .../Exceptions/NotFoundError.cs | 3 +- .../Exceptions/PaymentRequiredError.cs | 4 +- .../Exceptions/PreconditionFailedError.cs | 6 +- .../Exceptions/ServiceUnavailableError.cs | 6 +- .../Exceptions/TooManyRequestsError.cs | 4 +- .../Exceptions/UnauthorizedError.cs | 4 +- .../Flows/Executions/ExecutionsClient.cs | 309 +++++-- .../Flows/Executions/IExecutionsClient.cs | 2 +- src/Auth0.ManagementApi/Flows/FlowsClient.cs | 464 ++++++++-- src/Auth0.ManagementApi/Flows/IFlowsClient.cs | 2 +- .../Vault/Connections/ConnectionsClient.cs | 472 ++++++++-- .../Vault/Connections/IConnectionsClient.cs | 2 +- src/Auth0.ManagementApi/Forms/FormsClient.cs | 438 +++++++-- src/Auth0.ManagementApi/Forms/IFormsClient.cs | 2 +- .../Groups/GroupsClient.cs | 314 +++++-- .../Groups/IGroupsClient.cs | 2 +- .../Groups/Members/MembersClient.cs | 78 +- .../Groups/Roles/IRolesClient.cs | 4 +- .../Groups/Roles/RolesClient.cs | 386 ++++++-- .../Guardian/Enrollments/EnrollmentsClient.cs | 278 ++++-- .../Enrollments/IEnrollmentsClient.cs | 2 +- .../Factors/Duo/Settings/SettingsClient.cs | 174 +++- .../Guardian/Factors/FactorsClient.cs | 116 ++- .../Guardian/Factors/Phone/PhoneClient.cs | 476 +++++++++- .../PushNotificationClient.cs | 696 ++++++++++++-- .../Guardian/Factors/Sms/ISmsClient.cs | 2 +- .../Guardian/Factors/Sms/SmsClient.cs | 358 ++++++- .../Guardian/Policies/PoliciesClient.cs | 116 ++- src/Auth0.ManagementApi/Hooks/HooksClient.cs | 498 ++++++++-- src/Auth0.ManagementApi/Hooks/IHooksClient.cs | 2 +- .../Hooks/Secrets/ISecretsClient.cs | 6 +- .../Hooks/Secrets/SecretsClient.cs | 437 +++++++-- .../Jobs/Errors/ErrorsClient.cs | 92 +- .../Jobs/Errors/IErrorsClient.cs | 2 +- src/Auth0.ManagementApi/Jobs/JobsClient.cs | 82 +- .../Jobs/UsersExports/UsersExportsClient.cs | 70 +- .../Jobs/UsersImports/UsersImportsClient.cs | 94 +- .../VerificationEmailClient.cs | 70 +- .../Keys/CustomSigning/CustomSigningClient.cs | 291 ++++-- .../CustomSigning/ICustomSigningClient.cs | 5 +- .../Keys/Encryption/EncryptionClient.cs | 717 +++++++++++--- .../Keys/Encryption/IEncryptionClient.cs | 7 +- .../Keys/Signing/SigningClient.cs | 280 +++++- .../LogStreams/ILogStreamsClient.cs | 2 +- .../LogStreams/LogStreamsClient.cs | 472 ++++++++-- src/Auth0.ManagementApi/Logs/LogsClient.cs | 148 ++- .../NetworkAcls/INetworkAclsClient.cs | 4 +- .../NetworkAcls/NetworkAclsClient.cs | 684 +++++++++++--- .../ClientGrants/ClientGrantsClient.cs | 349 +++++-- .../ClientGrants/IClientGrantsClient.cs | 2 +- .../Connections/ConnectionsClient.cs | 463 +++++++-- .../Connections/IConnectionsClient.cs | 2 +- .../DiscoveryDomainsClient.cs | 559 +++++++++-- .../IDiscoveryDomainsClient.cs | 2 +- .../EnabledConnectionsClient.cs | 503 ++++++++-- .../IEnabledConnectionsClient.cs | 2 +- .../Organizations/Groups/GroupsClient.cs | 78 +- .../Groups/Roles/IRolesClient.cs | 4 +- .../Organizations/Groups/Roles/RolesClient.cs | 424 +++++++-- .../Organizations/IOrganizationsClient.cs | 3 +- .../Invitations/IInvitationsClient.cs | 2 +- .../Invitations/InvitationsClient.cs | 415 +++++++-- .../EffectiveRoles/EffectiveRolesClient.cs | 78 +- .../Sources/Groups/GroupsClient.cs | 78 +- .../Organizations/Members/IMembersClient.cs | 4 +- .../Organizations/Members/MembersClient.cs | 402 +++++--- .../Members/Roles/IRolesClient.cs | 4 +- .../Members/Roles/RolesClient.cs | 410 ++++++-- .../Organizations/OrganizationsClient.cs | 571 ++++++++++-- .../CreateOrganizationRequestContent.cs | 4 + .../UpdateOrganizationRequestContent.cs | 4 + .../Organizations/Roles/IRolesClient.cs | 6 + .../Roles/Members/IMembersClient.cs | 18 + .../Roles/Members/MembersClient.cs | 253 +++++ ...rganizationRoleMembersRequestParameters.cs | 38 + .../Organizations/Roles/RolesClient.cs | 16 + .../Prompts/CustomText/CustomTextClient.cs | 220 ++++- .../Prompts/CustomText/ICustomTextClient.cs | 2 +- .../Prompts/Partials/IPartialsClient.cs | 2 +- .../Prompts/Partials/PartialsClient.cs | 213 ++++- .../Prompts/PromptsClient.cs | 128 ++- .../Prompts/Rendering/RenderingClient.cs | 336 ++++++- .../IRateLimitPoliciesClient.cs | 2 +- .../RateLimitPoliciesClient.cs | 472 ++++++++-- .../RefreshTokens/IRefreshTokensClient.cs | 4 +- .../RefreshTokens/RefreshTokensClient.cs | 584 +++++++++--- .../ResourceServers/IResourceServersClient.cs | 2 +- .../ResourceServers/ResourceServersClient.cs | 480 ++++++++-- .../Settings/NewDevice/NewDeviceClient.cs | 152 ++- .../Settings/SettingsClient.cs | 152 ++- .../Roles/Groups/GroupsClient.cs | 380 ++++++-- .../Roles/Groups/IGroupsClient.cs | 4 +- src/Auth0.ManagementApi/Roles/IRolesClient.cs | 2 +- .../Roles/Permissions/IPermissionsClient.cs | 4 +- .../Roles/Permissions/PermissionsClient.cs | 424 ++++++--- src/Auth0.ManagementApi/Roles/RolesClient.cs | 480 ++++++++-- .../Roles/Users/IUsersClient.cs | 2 +- .../Roles/Users/UsersClient.cs | 263 ++++-- src/Auth0.ManagementApi/Rules/IRulesClient.cs | 2 +- src/Auth0.ManagementApi/Rules/RulesClient.cs | 498 ++++++++-- .../RulesConfigs/IRulesConfigsClient.cs | 2 +- .../RulesConfigs/RulesConfigsClient.cs | 266 ++++-- .../CustomText/CustomTextClient.cs | 140 ++- .../ISelfServiceProfilesClient.cs | 2 +- .../SelfServiceProfilesClient.cs | 534 +++++++++-- .../SsoTicket/ISsoTicketClient.cs | 2 +- .../SsoTicket/SsoTicketClient.cs | 205 +++- .../Sessions/ISessionsClient.cs | 4 +- .../Sessions/SessionsClient.cs | 466 +++++++--- src/Auth0.ManagementApi/Stats/StatsClient.cs | 124 ++- .../SupplementalSignalsClient.cs | 140 ++- .../Tenants/Settings/SettingsClient.cs | 136 ++- .../Tickets/TicketsClient.cs | 164 +++- .../ITokenExchangeProfilesClient.cs | 4 +- .../TokenExchangeProfilesClient.cs | 593 +++++++++--- ...enVaultPrivilegedAccessWithCredentialId.cs | 4 + ...TokenVaultPrivilegedAccessWithPublicKey.cs | 4 + .../Types/ConnectionPropertiesOptions.cs | 8 + .../Types/ConnectionsOidcMetadata.cs | 289 ++++++ .../CreateOrganizationResponseContent.cs | 4 + .../DefaultMethodPhoneNumberIdentifierEnum.cs | 120 +++ .../Types/EmailAttribute.cs | 2 +- ...ntifier.cs => EmailAttributeIdentifier.cs} | 2 +- .../EventStreamCloudEventConnectionCreated.cs | 37 + ...amCloudEventConnectionCreatedCloudEvent.cs | 71 ++ ...ventConnectionCreatedCloudEventTypeEnum.cs | 123 +++ ...ntStreamCloudEventConnectionCreatedData.cs | 35 + ...StreamCloudEventConnectionCreatedObject.cs | 675 ++++++++++++++ ...treamCloudEventConnectionCreatedObject0.cs | 91 ++ ...tConnectionCreatedObject0Authentication.cs | 31 + ...nnectionCreatedObject0ConnectedAccounts.cs | 35 + ...udEventConnectionCreatedObject0Metadata.cs | 28 + ...oudEventConnectionCreatedObject0Options.cs | 180 ++++ ...ectionCreatedObject0OptionsAttributeMap.cs | 43 + ...ject0OptionsAttributeMapMappingModeEnum.cs | 139 +++ ...CreatedObject0OptionsConnectionSettings.cs | 33 + ...bject0OptionsConnectionSettingsPkceEnum.cs | 149 +++ ...CreatedObject0OptionsDpopSigningAlgEnum.cs | 145 +++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...ptionsIdTokenSignedResponseAlgsItemEnum.cs | 164 ++++ ...ectionCreatedObject0OptionsOidcMetadata.cs | 283 ++++++ ...nCreatedObject0OptionsSchemaVersionEnum.cs | 135 +++ ...Object0OptionsSetUserRootAttributesEnum.cs | 144 +++ ...ject0OptionsTokenEndpointAuthMethodEnum.cs | 139 +++ ...0OptionsTokenEndpointAuthSigningAlgEnum.cs | 164 ++++ ...0OptionsTokenEndpointJwtcaAudFormatEnum.cs | 139 +++ ...ConnectionCreatedObject0OptionsTypeEnum.cs | 131 +++ ...entConnectionCreatedObject0StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionCreatedObject1.cs | 91 ++ ...tConnectionCreatedObject1Authentication.cs | 31 + ...nnectionCreatedObject1ConnectedAccounts.cs | 31 + ...udEventConnectionCreatedObject1Metadata.cs | 28 + ...oudEventConnectionCreatedObject1Options.cs | 180 ++++ ...ectionCreatedObject1OptionsAttributeMap.cs | 43 + ...ject1OptionsAttributeMapMappingModeEnum.cs | 139 +++ ...CreatedObject1OptionsConnectionSettings.cs | 33 + ...bject1OptionsConnectionSettingsPkceEnum.cs | 149 +++ ...CreatedObject1OptionsDpopSigningAlgEnum.cs | 145 +++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...ptionsIdTokenSignedResponseAlgsItemEnum.cs | 164 ++++ ...ectionCreatedObject1OptionsOidcMetadata.cs | 283 ++++++ ...nCreatedObject1OptionsSchemaVersionEnum.cs | 135 +++ ...Object1OptionsSetUserRootAttributesEnum.cs | 144 +++ ...ject1OptionsTokenEndpointAuthMethodEnum.cs | 139 +++ ...1OptionsTokenEndpointAuthSigningAlgEnum.cs | 164 ++++ ...1OptionsTokenEndpointJwtcaAudFormatEnum.cs | 139 +++ ...ConnectionCreatedObject1OptionsTypeEnum.cs | 126 +++ ...entConnectionCreatedObject1StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionCreatedObject2.cs | 91 ++ ...tConnectionCreatedObject2Authentication.cs | 31 + ...nnectionCreatedObject2ConnectedAccounts.cs | 31 + ...udEventConnectionCreatedObject2Metadata.cs | 28 + ...oudEventConnectionCreatedObject2Options.cs | 225 +++++ ...ject2OptionsAssertionDecryptionSettings.cs | 39 + ...nDecryptionSettingsAlgorithmProfileEnum.cs | 134 +++ ...reatedObject2OptionsDigestAlgorithmEnum.cs | 135 +++ ...ectionCreatedObject2OptionsIdpinitiated.cs | 53 ++ ...t2OptionsIdpinitiatedClientProtocolEnum.cs | 144 +++ ...reatedObject2OptionsProtocolBindingEnum.cs | 137 +++ ...Object2OptionsSetUserRootAttributesEnum.cs | 144 +++ ...tedObject2OptionsSignatureAlgorithmEnum.cs | 137 +++ ...tConnectionCreatedObject2OptionsSubject.cs | 28 + ...entConnectionCreatedObject2StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionCreatedObject3.cs | 91 ++ ...tConnectionCreatedObject3Authentication.cs | 31 + ...nnectionCreatedObject3ConnectedAccounts.cs | 31 + ...udEventConnectionCreatedObject3Metadata.cs | 28 + ...oudEventConnectionCreatedObject3Options.cs | 150 +++ ...ject3OptionsAssertionDecryptionSettings.cs | 39 + ...nDecryptionSettingsAlgorithmProfileEnum.cs | 134 +++ ...reatedObject3OptionsDigestAlgorithmEnum.cs | 135 +++ ...ectionCreatedObject3OptionsIdpinitiated.cs | 53 ++ ...t3OptionsIdpinitiatedClientProtocolEnum.cs | 144 +++ ...reatedObject3OptionsProtocolBindingEnum.cs | 137 +++ ...Object3OptionsSetUserRootAttributesEnum.cs | 144 +++ ...tedObject3OptionsSignatureAlgorithmEnum.cs | 137 +++ ...tConnectionCreatedObject3OptionsSubject.cs | 28 + ...entConnectionCreatedObject3StrategyEnum.cs | 124 +++ ...treamCloudEventConnectionCreatedObject4.cs | 91 ++ ...tConnectionCreatedObject4Authentication.cs | 31 + ...nnectionCreatedObject4ConnectedAccounts.cs | 31 + ...udEventConnectionCreatedObject4Metadata.cs | 28 + ...oudEventConnectionCreatedObject4Options.cs | 124 +++ ...Object4OptionsSetUserRootAttributesEnum.cs | 144 +++ ...sShouldTrustEmailVerifiedConnectionEnum.cs | 139 +++ ...entConnectionCreatedObject4StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionCreatedObject5.cs | 84 ++ ...tConnectionCreatedObject5Authentication.cs | 31 + ...nnectionCreatedObject5ConnectedAccounts.cs | 31 + ...udEventConnectionCreatedObject5Metadata.cs | 28 + ...oudEventConnectionCreatedObject5Options.cs | 148 +++ ...Object5OptionsSetUserRootAttributesEnum.cs | 144 +++ ...entConnectionCreatedObject5StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionCreatedObject6.cs | 91 ++ ...tConnectionCreatedObject6Authentication.cs | 31 + ...nnectionCreatedObject6ConnectedAccounts.cs | 31 + ...udEventConnectionCreatedObject6Metadata.cs | 28 + ...oudEventConnectionCreatedObject6Options.cs | 179 ++++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...Object6OptionsSetUserRootAttributesEnum.cs | 144 +++ ...entConnectionCreatedObject6StrategyEnum.cs | 124 +++ ...treamCloudEventConnectionCreatedObject7.cs | 91 ++ ...tConnectionCreatedObject7Authentication.cs | 31 + ...nnectionCreatedObject7ConnectedAccounts.cs | 31 + ...udEventConnectionCreatedObject7Metadata.cs | 28 + ...oudEventConnectionCreatedObject7Options.cs | 199 ++++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...ionCreatedObject7OptionsIdentityApiEnum.cs | 135 +++ ...Object7OptionsSetUserRootAttributesEnum.cs | 144 +++ ...sShouldTrustEmailVerifiedConnectionEnum.cs | 139 +++ ...reatedObject7OptionsUseridAttributeEnum.cs | 135 +++ ...onCreatedObject7OptionsWaadProtocolEnum.cs | 135 +++ ...entConnectionCreatedObject7StrategyEnum.cs | 125 +++ ...reamCloudEventConnectionCreatedTypeEnum.cs | 122 +++ .../EventStreamCloudEventConnectionDeleted.cs | 37 + ...amCloudEventConnectionDeletedCloudEvent.cs | 71 ++ ...ventConnectionDeletedCloudEventTypeEnum.cs | 123 +++ ...ntStreamCloudEventConnectionDeletedData.cs | 35 + ...StreamCloudEventConnectionDeletedObject.cs | 675 ++++++++++++++ ...treamCloudEventConnectionDeletedObject0.cs | 91 ++ ...tConnectionDeletedObject0Authentication.cs | 31 + ...nnectionDeletedObject0ConnectedAccounts.cs | 35 + ...udEventConnectionDeletedObject0Metadata.cs | 28 + ...oudEventConnectionDeletedObject0Options.cs | 180 ++++ ...ectionDeletedObject0OptionsAttributeMap.cs | 43 + ...ject0OptionsAttributeMapMappingModeEnum.cs | 139 +++ ...DeletedObject0OptionsConnectionSettings.cs | 33 + ...bject0OptionsConnectionSettingsPkceEnum.cs | 149 +++ ...DeletedObject0OptionsDpopSigningAlgEnum.cs | 145 +++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...ptionsIdTokenSignedResponseAlgsItemEnum.cs | 164 ++++ ...ectionDeletedObject0OptionsOidcMetadata.cs | 283 ++++++ ...nDeletedObject0OptionsSchemaVersionEnum.cs | 135 +++ ...Object0OptionsSetUserRootAttributesEnum.cs | 144 +++ ...ject0OptionsTokenEndpointAuthMethodEnum.cs | 139 +++ ...0OptionsTokenEndpointAuthSigningAlgEnum.cs | 164 ++++ ...0OptionsTokenEndpointJwtcaAudFormatEnum.cs | 139 +++ ...ConnectionDeletedObject0OptionsTypeEnum.cs | 131 +++ ...entConnectionDeletedObject0StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionDeletedObject1.cs | 91 ++ ...tConnectionDeletedObject1Authentication.cs | 31 + ...nnectionDeletedObject1ConnectedAccounts.cs | 31 + ...udEventConnectionDeletedObject1Metadata.cs | 28 + ...oudEventConnectionDeletedObject1Options.cs | 180 ++++ ...ectionDeletedObject1OptionsAttributeMap.cs | 43 + ...ject1OptionsAttributeMapMappingModeEnum.cs | 139 +++ ...DeletedObject1OptionsConnectionSettings.cs | 33 + ...bject1OptionsConnectionSettingsPkceEnum.cs | 149 +++ ...DeletedObject1OptionsDpopSigningAlgEnum.cs | 145 +++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...ptionsIdTokenSignedResponseAlgsItemEnum.cs | 164 ++++ ...ectionDeletedObject1OptionsOidcMetadata.cs | 283 ++++++ ...nDeletedObject1OptionsSchemaVersionEnum.cs | 135 +++ ...Object1OptionsSetUserRootAttributesEnum.cs | 144 +++ ...ject1OptionsTokenEndpointAuthMethodEnum.cs | 139 +++ ...1OptionsTokenEndpointAuthSigningAlgEnum.cs | 164 ++++ ...1OptionsTokenEndpointJwtcaAudFormatEnum.cs | 139 +++ ...ConnectionDeletedObject1OptionsTypeEnum.cs | 126 +++ ...entConnectionDeletedObject1StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionDeletedObject2.cs | 91 ++ ...tConnectionDeletedObject2Authentication.cs | 31 + ...nnectionDeletedObject2ConnectedAccounts.cs | 31 + ...udEventConnectionDeletedObject2Metadata.cs | 28 + ...oudEventConnectionDeletedObject2Options.cs | 225 +++++ ...ject2OptionsAssertionDecryptionSettings.cs | 39 + ...nDecryptionSettingsAlgorithmProfileEnum.cs | 134 +++ ...eletedObject2OptionsDigestAlgorithmEnum.cs | 135 +++ ...ectionDeletedObject2OptionsIdpinitiated.cs | 53 ++ ...t2OptionsIdpinitiatedClientProtocolEnum.cs | 144 +++ ...eletedObject2OptionsProtocolBindingEnum.cs | 137 +++ ...Object2OptionsSetUserRootAttributesEnum.cs | 144 +++ ...tedObject2OptionsSignatureAlgorithmEnum.cs | 137 +++ ...tConnectionDeletedObject2OptionsSubject.cs | 28 + ...entConnectionDeletedObject2StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionDeletedObject3.cs | 91 ++ ...tConnectionDeletedObject3Authentication.cs | 31 + ...nnectionDeletedObject3ConnectedAccounts.cs | 31 + ...udEventConnectionDeletedObject3Metadata.cs | 28 + ...oudEventConnectionDeletedObject3Options.cs | 150 +++ ...ject3OptionsAssertionDecryptionSettings.cs | 39 + ...nDecryptionSettingsAlgorithmProfileEnum.cs | 134 +++ ...eletedObject3OptionsDigestAlgorithmEnum.cs | 135 +++ ...ectionDeletedObject3OptionsIdpinitiated.cs | 53 ++ ...t3OptionsIdpinitiatedClientProtocolEnum.cs | 144 +++ ...eletedObject3OptionsProtocolBindingEnum.cs | 137 +++ ...Object3OptionsSetUserRootAttributesEnum.cs | 144 +++ ...tedObject3OptionsSignatureAlgorithmEnum.cs | 137 +++ ...tConnectionDeletedObject3OptionsSubject.cs | 28 + ...entConnectionDeletedObject3StrategyEnum.cs | 124 +++ ...treamCloudEventConnectionDeletedObject4.cs | 91 ++ ...tConnectionDeletedObject4Authentication.cs | 31 + ...nnectionDeletedObject4ConnectedAccounts.cs | 31 + ...udEventConnectionDeletedObject4Metadata.cs | 28 + ...oudEventConnectionDeletedObject4Options.cs | 124 +++ ...Object4OptionsSetUserRootAttributesEnum.cs | 144 +++ ...sShouldTrustEmailVerifiedConnectionEnum.cs | 139 +++ ...entConnectionDeletedObject4StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionDeletedObject5.cs | 84 ++ ...tConnectionDeletedObject5Authentication.cs | 31 + ...nnectionDeletedObject5ConnectedAccounts.cs | 31 + ...udEventConnectionDeletedObject5Metadata.cs | 28 + ...oudEventConnectionDeletedObject5Options.cs | 148 +++ ...Object5OptionsSetUserRootAttributesEnum.cs | 144 +++ ...entConnectionDeletedObject5StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionDeletedObject6.cs | 91 ++ ...tConnectionDeletedObject6Authentication.cs | 31 + ...nnectionDeletedObject6ConnectedAccounts.cs | 31 + ...udEventConnectionDeletedObject6Metadata.cs | 28 + ...oudEventConnectionDeletedObject6Options.cs | 179 ++++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...Object6OptionsSetUserRootAttributesEnum.cs | 144 +++ ...entConnectionDeletedObject6StrategyEnum.cs | 124 +++ ...treamCloudEventConnectionDeletedObject7.cs | 91 ++ ...tConnectionDeletedObject7Authentication.cs | 31 + ...nnectionDeletedObject7ConnectedAccounts.cs | 31 + ...udEventConnectionDeletedObject7Metadata.cs | 28 + ...oudEventConnectionDeletedObject7Options.cs | 199 ++++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...ionDeletedObject7OptionsIdentityApiEnum.cs | 135 +++ ...Object7OptionsSetUserRootAttributesEnum.cs | 144 +++ ...sShouldTrustEmailVerifiedConnectionEnum.cs | 139 +++ ...eletedObject7OptionsUseridAttributeEnum.cs | 135 +++ ...onDeletedObject7OptionsWaadProtocolEnum.cs | 135 +++ ...entConnectionDeletedObject7StrategyEnum.cs | 125 +++ ...reamCloudEventConnectionDeletedTypeEnum.cs | 122 +++ .../EventStreamCloudEventConnectionUpdated.cs | 37 + ...amCloudEventConnectionUpdatedCloudEvent.cs | 71 ++ ...ventConnectionUpdatedCloudEventTypeEnum.cs | 123 +++ ...ntStreamCloudEventConnectionUpdatedData.cs | 35 + ...StreamCloudEventConnectionUpdatedObject.cs | 675 ++++++++++++++ ...treamCloudEventConnectionUpdatedObject0.cs | 91 ++ ...tConnectionUpdatedObject0Authentication.cs | 31 + ...nnectionUpdatedObject0ConnectedAccounts.cs | 35 + ...udEventConnectionUpdatedObject0Metadata.cs | 28 + ...oudEventConnectionUpdatedObject0Options.cs | 180 ++++ ...ectionUpdatedObject0OptionsAttributeMap.cs | 43 + ...ject0OptionsAttributeMapMappingModeEnum.cs | 139 +++ ...UpdatedObject0OptionsConnectionSettings.cs | 33 + ...bject0OptionsConnectionSettingsPkceEnum.cs | 149 +++ ...UpdatedObject0OptionsDpopSigningAlgEnum.cs | 145 +++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...ptionsIdTokenSignedResponseAlgsItemEnum.cs | 164 ++++ ...ectionUpdatedObject0OptionsOidcMetadata.cs | 283 ++++++ ...nUpdatedObject0OptionsSchemaVersionEnum.cs | 135 +++ ...Object0OptionsSetUserRootAttributesEnum.cs | 144 +++ ...ject0OptionsTokenEndpointAuthMethodEnum.cs | 139 +++ ...0OptionsTokenEndpointAuthSigningAlgEnum.cs | 164 ++++ ...0OptionsTokenEndpointJwtcaAudFormatEnum.cs | 139 +++ ...ConnectionUpdatedObject0OptionsTypeEnum.cs | 131 +++ ...entConnectionUpdatedObject0StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionUpdatedObject1.cs | 91 ++ ...tConnectionUpdatedObject1Authentication.cs | 31 + ...nnectionUpdatedObject1ConnectedAccounts.cs | 31 + ...udEventConnectionUpdatedObject1Metadata.cs | 28 + ...oudEventConnectionUpdatedObject1Options.cs | 180 ++++ ...ectionUpdatedObject1OptionsAttributeMap.cs | 43 + ...ject1OptionsAttributeMapMappingModeEnum.cs | 139 +++ ...UpdatedObject1OptionsConnectionSettings.cs | 33 + ...bject1OptionsConnectionSettingsPkceEnum.cs | 149 +++ ...UpdatedObject1OptionsDpopSigningAlgEnum.cs | 145 +++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...ptionsIdTokenSignedResponseAlgsItemEnum.cs | 164 ++++ ...ectionUpdatedObject1OptionsOidcMetadata.cs | 283 ++++++ ...nUpdatedObject1OptionsSchemaVersionEnum.cs | 135 +++ ...Object1OptionsSetUserRootAttributesEnum.cs | 144 +++ ...ject1OptionsTokenEndpointAuthMethodEnum.cs | 139 +++ ...1OptionsTokenEndpointAuthSigningAlgEnum.cs | 164 ++++ ...1OptionsTokenEndpointJwtcaAudFormatEnum.cs | 139 +++ ...ConnectionUpdatedObject1OptionsTypeEnum.cs | 126 +++ ...entConnectionUpdatedObject1StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionUpdatedObject2.cs | 91 ++ ...tConnectionUpdatedObject2Authentication.cs | 31 + ...nnectionUpdatedObject2ConnectedAccounts.cs | 31 + ...udEventConnectionUpdatedObject2Metadata.cs | 28 + ...oudEventConnectionUpdatedObject2Options.cs | 225 +++++ ...ject2OptionsAssertionDecryptionSettings.cs | 39 + ...nDecryptionSettingsAlgorithmProfileEnum.cs | 134 +++ ...pdatedObject2OptionsDigestAlgorithmEnum.cs | 135 +++ ...ectionUpdatedObject2OptionsIdpinitiated.cs | 53 ++ ...t2OptionsIdpinitiatedClientProtocolEnum.cs | 144 +++ ...pdatedObject2OptionsProtocolBindingEnum.cs | 137 +++ ...Object2OptionsSetUserRootAttributesEnum.cs | 144 +++ ...tedObject2OptionsSignatureAlgorithmEnum.cs | 137 +++ ...tConnectionUpdatedObject2OptionsSubject.cs | 28 + ...entConnectionUpdatedObject2StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionUpdatedObject3.cs | 91 ++ ...tConnectionUpdatedObject3Authentication.cs | 31 + ...nnectionUpdatedObject3ConnectedAccounts.cs | 31 + ...udEventConnectionUpdatedObject3Metadata.cs | 28 + ...oudEventConnectionUpdatedObject3Options.cs | 150 +++ ...ject3OptionsAssertionDecryptionSettings.cs | 39 + ...nDecryptionSettingsAlgorithmProfileEnum.cs | 134 +++ ...pdatedObject3OptionsDigestAlgorithmEnum.cs | 135 +++ ...ectionUpdatedObject3OptionsIdpinitiated.cs | 53 ++ ...t3OptionsIdpinitiatedClientProtocolEnum.cs | 144 +++ ...pdatedObject3OptionsProtocolBindingEnum.cs | 137 +++ ...Object3OptionsSetUserRootAttributesEnum.cs | 144 +++ ...tedObject3OptionsSignatureAlgorithmEnum.cs | 137 +++ ...tConnectionUpdatedObject3OptionsSubject.cs | 28 + ...entConnectionUpdatedObject3StrategyEnum.cs | 124 +++ ...treamCloudEventConnectionUpdatedObject4.cs | 91 ++ ...tConnectionUpdatedObject4Authentication.cs | 31 + ...nnectionUpdatedObject4ConnectedAccounts.cs | 31 + ...udEventConnectionUpdatedObject4Metadata.cs | 28 + ...oudEventConnectionUpdatedObject4Options.cs | 124 +++ ...Object4OptionsSetUserRootAttributesEnum.cs | 144 +++ ...sShouldTrustEmailVerifiedConnectionEnum.cs | 139 +++ ...entConnectionUpdatedObject4StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionUpdatedObject5.cs | 84 ++ ...tConnectionUpdatedObject5Authentication.cs | 31 + ...nnectionUpdatedObject5ConnectedAccounts.cs | 31 + ...udEventConnectionUpdatedObject5Metadata.cs | 28 + ...oudEventConnectionUpdatedObject5Options.cs | 148 +++ ...Object5OptionsSetUserRootAttributesEnum.cs | 144 +++ ...entConnectionUpdatedObject5StrategyEnum.cs | 125 +++ ...treamCloudEventConnectionUpdatedObject6.cs | 91 ++ ...tConnectionUpdatedObject6Authentication.cs | 31 + ...nnectionUpdatedObject6ConnectedAccounts.cs | 31 + ...udEventConnectionUpdatedObject6Metadata.cs | 28 + ...oudEventConnectionUpdatedObject6Options.cs | 179 ++++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...Object6OptionsSetUserRootAttributesEnum.cs | 144 +++ ...entConnectionUpdatedObject6StrategyEnum.cs | 124 +++ ...treamCloudEventConnectionUpdatedObject7.cs | 91 ++ ...tConnectionUpdatedObject7Authentication.cs | 31 + ...nnectionUpdatedObject7ConnectedAccounts.cs | 31 + ...udEventConnectionUpdatedObject7Metadata.cs | 28 + ...oudEventConnectionUpdatedObject7Options.cs | 199 ++++ ...OptionsFederatedConnectionsAccessTokens.cs | 35 + ...ionUpdatedObject7OptionsIdentityApiEnum.cs | 135 +++ ...Object7OptionsSetUserRootAttributesEnum.cs | 144 +++ ...sShouldTrustEmailVerifiedConnectionEnum.cs | 139 +++ ...pdatedObject7OptionsUseridAttributeEnum.cs | 135 +++ ...onUpdatedObject7OptionsWaadProtocolEnum.cs | 135 +++ ...entConnectionUpdatedObject7StrategyEnum.cs | 125 +++ ...reamCloudEventConnectionUpdatedTypeEnum.cs | 122 +++ ...tStreamCloudEventGroupCreatedCloudEvent.cs | 5 +- ...tStreamCloudEventGroupDeletedCloudEvent.cs | 5 +- ...eamCloudEventGroupMemberAddedCloudEvent.cs | 5 +- ...mCloudEventGroupMemberDeletedCloudEvent.cs | 5 +- ...amCloudEventGroupRoleAssignedCloudEvent.cs | 5 +- ...eamCloudEventGroupRoleDeletedCloudEvent.cs | 5 +- ...tStreamCloudEventGroupUpdatedCloudEvent.cs | 5 +- ...mCloudEventOrgConnectionAddedCloudEvent.cs | 5 +- ...loudEventOrgConnectionRemovedCloudEvent.cs | 5 +- ...loudEventOrgConnectionUpdatedCloudEvent.cs | 5 +- ...entStreamCloudEventOrgCreatedCloudEvent.cs | 5 +- ...entStreamCloudEventOrgDeletedCloudEvent.cs | 5 +- ...loudEventOrgGroupRoleAssignedCloudEvent.cs | 5 +- ...CloudEventOrgGroupRoleDeletedCloudEvent.cs | 5 +- ...treamCloudEventOrgMemberAddedCloudEvent.cs | 5 +- ...eamCloudEventOrgMemberDeletedCloudEvent.cs | 5 +- ...oudEventOrgMemberRoleAssignedCloudEvent.cs | 5 +- ...loudEventOrgMemberRoleDeletedCloudEvent.cs | 5 +- ...entStreamCloudEventOrgUpdatedCloudEvent.cs | 5 +- .../EventStreamCloudEventSpecVersionEnum.cs | 116 +++ ...ntStreamCloudEventUserCreatedCloudEvent.cs | 5 +- ...ntStreamCloudEventUserDeletedCloudEvent.cs | 5 +- ...ntStreamCloudEventUserUpdatedCloudEvent.cs | 5 +- .../Types/EventStreamDeliveryEventTypeEnum.cs | 18 + .../Types/EventStreamEventTypeEnum.cs | 18 + ...EventStreamSubscribeEventsEventTypeEnum.cs | 18 + ...entStreamSubscribeEventsResponseContent.cs | 243 +++++ .../Types/EventStreamTestEventTypeEnum.cs | 18 + .../GetOrganizationByNameResponseContent.cs | 4 + .../Types/GetOrganizationResponseContent.cs | 4 + ...tOrganizationRoleMembersResponseContent.cs | 38 + ...ListRolesOffsetPaginatedResponseContent.cs | 9 +- .../Types/NotFoundErrorBody.cs | 34 + .../Types/NotFoundErrorBodyError.cs | 111 +++ src/Auth0.ManagementApi/Types/Organization.cs | 4 + .../OrganizationThirdPartyClientAccessEnum.cs | 120 +++ .../Types/PartialGroupsEnum.cs | 4 + .../Types/PhoneAttribute.cs | 2 +- .../Types/PhoneAttributeIdentifier.cs | 36 + ...neProviderProtectionBackoffStrategyEnum.cs | 4 +- src/Auth0.ManagementApi/Types/RoleMember.cs | 53 ++ .../Types/TokenVaultPrivilegedAccessGrant.cs | 31 + .../Types/TooManyRequestsErrorBody.cs | 34 + .../Types/TooManyRequestsErrorBodyError.cs | 114 +++ .../Types/UpdateConnectionOptions.cs | 8 + .../UpdateOrganizationResponseContent.cs | 4 + src/Auth0.ManagementApi/Types/UserGrant.cs | 7 + .../Types/UsernameAttribute.cs | 2 +- .../Types/UsernameAttributeIdentifier.cs | 32 + .../IUserAttributeProfilesClient.cs | 2 +- .../UserAttributeProfilesClient.cs | 586 ++++++++++-- .../UserBlocks/IUserBlocksClient.cs | 4 +- .../UserBlocks/UserBlocksClient.cs | 474 +++++++--- .../UserGrants/IUserGrantsClient.cs | 4 +- .../UserGrants/UserGrantsClient.cs | 312 +++++-- .../AuthenticationMethodsClient.cs | 781 +++++++++++++--- .../IAuthenticationMethodsClient.cs | 4 +- .../Authenticators/AuthenticatorsClient.cs | 90 +- .../Authenticators/IAuthenticatorsClient.cs | 2 +- .../ConnectedAccountsClient.cs | 78 +- .../EffectivePermissionsClient.cs | 78 +- .../Sources/Roles/RolesClient.cs | 78 +- .../EffectiveRoles/EffectiveRolesClient.cs | 78 +- .../Sources/Groups/GroupsClient.cs | 78 +- .../Users/Enrollments/EnrollmentsClient.cs | 82 +- .../FederatedConnectionsTokensetsClient.cs | 189 +++- .../IFederatedConnectionsTokensetsClient.cs | 2 +- .../Users/Groups/GroupsClient.cs | 78 +- src/Auth0.ManagementApi/Users/IUsersClient.cs | 4 +- .../Users/Identities/IdentitiesClient.cs | 152 ++- .../Users/Logs/LogsClient.cs | 66 +- .../Users/Multifactor/IMultifactorClient.cs | 4 +- .../Users/Multifactor/MultifactorClient.cs | 185 +++- .../Organizations/OrganizationsClient.cs | 66 +- .../Users/Permissions/IPermissionsClient.cs | 4 +- .../Users/Permissions/PermissionsClient.cs | 436 ++++++--- .../Users/RefreshToken/IRefreshTokenClient.cs | 2 +- .../Users/RefreshToken/RefreshTokenClient.cs | 252 +++-- .../RiskAssessments/IRiskAssessmentsClient.cs | 2 +- .../RiskAssessments/RiskAssessmentsClient.cs | 105 ++- .../Users/Roles/IRolesClient.cs | 4 +- .../Users/Roles/RolesClient.cs | 396 ++++++-- .../Users/Sessions/ISessionsClient.cs | 2 +- .../Users/Sessions/SessionsClient.cs | 252 +++-- src/Auth0.ManagementApi/Users/UsersClient.cs | 799 +++++++++++++--- .../Templates/ITemplatesClient.cs | 2 +- .../Verification/Templates/TemplatesClient.cs | 484 ++++++++-- .../Auth0.ManagementApi.Test.csproj | 2 +- .../Core/RawClientTests/RetriesTests.cs | 148 ++- .../Core/Sse/SseReconnectHelperTests.cs | 539 +++++++++++ .../ClientGrants/Organizations/ListTest.cs | 3 +- .../Unit/MockServer/Clients/CreateTest.cs | 8 + .../Unit/MockServer/Clients/GetTest.cs | 8 + .../MockServer/Clients/RotateSecretTest.cs | 8 + .../Unit/MockServer/Clients/UpdateTest.cs | 8 + .../EventStreams/Deliveries/GetHistoryTest.cs | 2 +- .../EventStreams/Deliveries/ListTest.cs | 2 +- .../EventStreams/Redeliveries/CreateTest.cs | 2 +- .../Unit/MockServer/EventStreams/TestTest.cs | 6 +- .../MockServer/Organizations/CreateTest.cs | 1 + .../MockServer/Organizations/GetByNameTest.cs | 3 +- .../Unit/MockServer/Organizations/GetTest.cs | 3 +- .../Unit/MockServer/Organizations/ListTest.cs | 3 +- .../Organizations/Roles/Members/ListTest.cs | 62 ++ .../MockServer/Organizations/UpdateTest.cs | 3 +- .../Unit/MockServer/UserGrants/ListTest.cs | 3 +- .../Users/Organizations/ListTest.cs | 3 +- 646 files changed, 72011 insertions(+), 7389 deletions(-) create mode 100644 src/Auth0.ManagementApi/Core/Public/WithRawResponseStream.cs create mode 100644 src/Auth0.ManagementApi/Core/SseReconnectHelper.cs create mode 100644 src/Auth0.ManagementApi/Organizations/Roles/IRolesClient.cs create mode 100644 src/Auth0.ManagementApi/Organizations/Roles/Members/IMembersClient.cs create mode 100644 src/Auth0.ManagementApi/Organizations/Roles/Members/MembersClient.cs create mode 100644 src/Auth0.ManagementApi/Organizations/Roles/Members/Requests/ListOrganizationRoleMembersRequestParameters.cs create mode 100644 src/Auth0.ManagementApi/Organizations/Roles/RolesClient.cs create mode 100644 src/Auth0.ManagementApi/Types/ConnectionsOidcMetadata.cs create mode 100644 src/Auth0.ManagementApi/Types/DefaultMethodPhoneNumberIdentifierEnum.cs rename src/Auth0.ManagementApi/Types/{ConnectionAttributeIdentifier.cs => EmailAttributeIdentifier.cs} (93%) create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreated.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedCloudEvent.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedCloudEventTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedData.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMap.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsOidcMetadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMap.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsOidcMetadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiated.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSubject.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiated.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSubject.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeleted.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedCloudEvent.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedCloudEventTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedData.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMap.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsOidcMetadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMap.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsOidcMetadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiated.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSubject.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiated.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSubject.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdated.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedCloudEvent.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedData.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMap.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsOidcMetadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMap.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsOidcMetadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiated.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSubject.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettings.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiated.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSubject.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Authentication.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7ConnectedAccounts.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Metadata.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Options.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsFederatedConnectionsAccessTokens.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7StrategyEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedTypeEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/EventStreamCloudEventSpecVersionEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/ListOrganizationRoleMembersResponseContent.cs create mode 100644 src/Auth0.ManagementApi/Types/NotFoundErrorBody.cs create mode 100644 src/Auth0.ManagementApi/Types/NotFoundErrorBodyError.cs create mode 100644 src/Auth0.ManagementApi/Types/OrganizationThirdPartyClientAccessEnum.cs create mode 100644 src/Auth0.ManagementApi/Types/PhoneAttributeIdentifier.cs create mode 100644 src/Auth0.ManagementApi/Types/RoleMember.cs create mode 100644 src/Auth0.ManagementApi/Types/TokenVaultPrivilegedAccessGrant.cs create mode 100644 src/Auth0.ManagementApi/Types/TooManyRequestsErrorBody.cs create mode 100644 src/Auth0.ManagementApi/Types/TooManyRequestsErrorBodyError.cs create mode 100644 src/Auth0.ManagementApi/Types/UsernameAttributeIdentifier.cs create mode 100644 tests/Auth0.ManagementApi.Test/Core/Sse/SseReconnectHelperTests.cs create mode 100644 tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Roles/Members/ListTest.cs diff --git a/reference.md b/reference.md index 885d126e1..17c3252fc 100644 --- a/reference.md +++ b/reference.md @@ -181,7 +181,7 @@ await client.Actions.GetAsync("id"); -
client.Actions.DeleteAsync(id, DeleteActionRequestParameters { ... }) +
client.Actions.DeleteAsync(id, DeleteActionRequestParameters { ... }) -> WithRawResponseTask
@@ -698,7 +698,7 @@ await client.ClientGrants.GetAsync("id");
-
client.ClientGrants.DeleteAsync(id) +
client.ClientGrants.DeleteAsync(id) -> WithRawResponseTask
@@ -1188,7 +1188,7 @@ await client.Clients.GetAsync(
-
client.Clients.DeleteAsync(id) +
client.Clients.DeleteAsync(id) -> WithRawResponseTask
@@ -1630,7 +1630,7 @@ await client.ConnectionProfiles.GetAsync("id");
-
client.ConnectionProfiles.DeleteAsync(id) +
client.ConnectionProfiles.DeleteAsync(id) -> WithRawResponseTask
@@ -1954,7 +1954,7 @@ await client.Connections.GetAsync(
-
client.Connections.DeleteAsync(id) +
client.Connections.DeleteAsync(id) -> WithRawResponseTask
@@ -2074,7 +2074,7 @@ await client.Connections.UpdateAsync("id", new UpdateConnectionRequestContent())
-
client.Connections.CheckStatusAsync(id) +
client.Connections.CheckStatusAsync(id) -> WithRawResponseTask
@@ -2412,7 +2412,7 @@ await client.CustomDomains.GetAsync("id");
-
client.CustomDomains.DeleteAsync(id) +
client.CustomDomains.DeleteAsync(id) -> WithRawResponseTask
@@ -2805,7 +2805,7 @@ await client.DeviceCredentials.CreatePublicKeyAsync(
-
client.DeviceCredentials.DeleteAsync(id) +
client.DeviceCredentials.DeleteAsync(id) -> WithRawResponseTask
@@ -3240,7 +3240,7 @@ await client.EventStreams.GetAsync("id");
-
client.EventStreams.DeleteAsync(id) +
client.EventStreams.DeleteAsync(id) -> WithRawResponseTask
@@ -3345,7 +3345,7 @@ await client.EventStreams.TestAsync( "id", new CreateEventStreamTestEventRequestContent { - EventType = EventStreamTestEventTypeEnum.GroupCreated, + EventType = EventStreamTestEventTypeEnum.ConnectionCreated, } ); ``` @@ -3383,7 +3383,7 @@ await client.EventStreams.TestAsync(
## Events -
client.Events.SubscribeAsync(SubscribeEventsRequestParameters { ... }) -> IAsyncEnumerable<EventStreamSubscribeEventsResponseContent> +
client.Events.SubscribeAsync(SubscribeEventsRequestParameters { ... }) -> WithRawResponseStream<EventStreamSubscribeEventsResponseContent>
@@ -3417,7 +3417,7 @@ client.Events.SubscribeAsync( FromTimestamp = "from_timestamp", EventType = new List() { - EventStreamSubscribeEventsEventTypeEnum.GroupCreated, + EventStreamSubscribeEventsEventTypeEnum.ConnectionCreated, }, } ); @@ -3597,7 +3597,7 @@ await client.Flows.GetAsync(
-
client.Flows.DeleteAsync(id) +
client.Flows.DeleteAsync(id) -> WithRawResponseTask
@@ -3834,7 +3834,7 @@ await client.Forms.GetAsync(
-
client.Forms.DeleteAsync(id) +
client.Forms.DeleteAsync(id) -> WithRawResponseTask
@@ -3987,7 +3987,7 @@ await client.UserGrants.ListAsync(
-
client.UserGrants.DeleteByUserIdAsync(DeleteUserGrantByUserIdRequestParameters { ... }) +
client.UserGrants.DeleteByUserIdAsync(DeleteUserGrantByUserIdRequestParameters { ... }) -> WithRawResponseTask
@@ -4043,7 +4043,7 @@ await client.UserGrants.DeleteByUserIdAsync(
-
client.UserGrants.DeleteAsync(id) +
client.UserGrants.DeleteAsync(id) -> WithRawResponseTask
@@ -4218,7 +4218,7 @@ await client.Groups.GetAsync("id");
-
client.Groups.DeleteAsync(id) +
client.Groups.DeleteAsync(id) -> WithRawResponseTask
@@ -4460,7 +4460,7 @@ await client.Hooks.GetAsync("id", new GetHookRequestParameters { Fields = "field
-
client.Hooks.DeleteAsync(id) +
client.Hooks.DeleteAsync(id) -> WithRawResponseTask
@@ -5202,7 +5202,7 @@ await client.LogStreams.GetAsync("id");
-
client.LogStreams.DeleteAsync(id) +
client.LogStreams.DeleteAsync(id) -> WithRawResponseTask
@@ -5598,7 +5598,7 @@ await client.NetworkAcls.ListAsync(
-
client.NetworkAcls.CreateAsync(CreateNetworkAclRequestContent { ... }) +
client.NetworkAcls.CreateAsync(CreateNetworkAclRequestContent { ... }) -> WithRawResponseTask
@@ -5791,7 +5791,7 @@ await client.NetworkAcls.SetAsync(
-
client.NetworkAcls.DeleteAsync(id) +
client.NetworkAcls.DeleteAsync(id) -> WithRawResponseTask
@@ -6147,7 +6147,7 @@ await client.Organizations.GetAsync("id");
-
client.Organizations.DeleteAsync(id) +
client.Organizations.DeleteAsync(id) -> WithRawResponseTask
@@ -6500,7 +6500,7 @@ await client.RateLimitPolicies.GetAsync("id");
-
client.RateLimitPolicies.DeleteAsync(id) +
client.RateLimitPolicies.DeleteAsync(id) -> WithRawResponseTask
@@ -6662,7 +6662,7 @@ await client.RefreshTokens.ListAsync(
-
client.RefreshTokens.RevokeAsync(RevokeRefreshTokensRequestContent { ... }) +
client.RefreshTokens.RevokeAsync(RevokeRefreshTokensRequestContent { ... }) -> WithRawResponseTask
@@ -6770,7 +6770,7 @@ await client.RefreshTokens.GetAsync("id");
-
client.RefreshTokens.DeleteAsync(id) +
client.RefreshTokens.DeleteAsync(id) -> WithRawResponseTask
@@ -7071,7 +7071,7 @@ await client.ResourceServers.GetAsync(
-
client.ResourceServers.DeleteAsync(id) +
client.ResourceServers.DeleteAsync(id) -> WithRawResponseTask
@@ -7362,7 +7362,7 @@ await client.Roles.GetAsync("id");
-
client.Roles.DeleteAsync(id) +
client.Roles.DeleteAsync(id) -> WithRawResponseTask
@@ -7664,7 +7664,7 @@ await client.Rules.GetAsync(
-
client.Rules.DeleteAsync(id) +
client.Rules.DeleteAsync(id) -> WithRawResponseTask
@@ -7884,7 +7884,7 @@ await client.RulesConfigs.SetAsync("key", new SetRulesConfigRequestContent { Val
-
client.RulesConfigs.DeleteAsync(key) +
client.RulesConfigs.DeleteAsync(key) -> WithRawResponseTask
@@ -8110,7 +8110,7 @@ await client.SelfServiceProfiles.GetAsync("id");
-
client.SelfServiceProfiles.DeleteAsync(id) +
client.SelfServiceProfiles.DeleteAsync(id) -> WithRawResponseTask
@@ -8281,7 +8281,7 @@ await client.Sessions.GetAsync("id");
-
client.Sessions.DeleteAsync(id) +
client.Sessions.DeleteAsync(id) -> WithRawResponseTask
@@ -8397,7 +8397,7 @@ await client.Sessions.UpdateAsync("id", new UpdateSessionRequestContent());
-
client.Sessions.RevokeAsync(id) +
client.Sessions.RevokeAsync(id) -> WithRawResponseTask
@@ -8938,7 +8938,7 @@ await client.TokenExchangeProfiles.GetAsync("id");
-
client.TokenExchangeProfiles.DeleteAsync(id) +
client.TokenExchangeProfiles.DeleteAsync(id) -> WithRawResponseTask
@@ -8994,7 +8994,7 @@ await client.TokenExchangeProfiles.DeleteAsync("id");
-
client.TokenExchangeProfiles.UpdateAsync(id, UpdateTokenExchangeProfileRequestContent { ... }) +
client.TokenExchangeProfiles.UpdateAsync(id, UpdateTokenExchangeProfileRequestContent { ... }) -> WithRawResponseTask
@@ -9340,7 +9340,7 @@ await client.UserAttributeProfiles.GetAsync("id");
-
client.UserAttributeProfiles.DeleteAsync(id) +
client.UserAttributeProfiles.DeleteAsync(id) -> WithRawResponseTask
@@ -9520,7 +9520,7 @@ await client.UserBlocks.ListByIdentifierAsync(
-
client.UserBlocks.DeleteByIdentifierAsync(DeleteUserBlocksByIdentifierRequestParameters { ... }) +
client.UserBlocks.DeleteByIdentifierAsync(DeleteUserBlocksByIdentifierRequestParameters { ... }) -> WithRawResponseTask
@@ -9643,7 +9643,7 @@ await client.UserBlocks.ListAsync(
-
client.UserBlocks.DeleteAsync(id) +
client.UserBlocks.DeleteAsync(id) -> WithRawResponseTask
@@ -9971,7 +9971,7 @@ await client.Users.GetAsync(
-
client.Users.DeleteAsync(id) +
client.Users.DeleteAsync(id) -> WithRawResponseTask
@@ -10231,7 +10231,7 @@ await client.Users.RegenerateRecoveryCodeAsync("id");
-
client.Users.RevokeAccessAsync(id, RevokeUserAccessRequestContent { ... }) +
client.Users.RevokeAccessAsync(id, RevokeUserAccessRequestContent { ... }) -> WithRawResponseTask
@@ -10717,7 +10717,7 @@ await client.Actions.Modules.GetAsync("id");
-
client.Actions.Modules.DeleteAsync(id) +
client.Actions.Modules.DeleteAsync(id) -> WithRawResponseTask
@@ -11317,7 +11317,7 @@ await client.Actions.Triggers.Bindings.UpdateManyAsync(
## Anomaly Blocks -
client.Anomaly.Blocks.CheckIpAsync(id) +
client.Anomaly.Blocks.CheckIpAsync(id) -> WithRawResponseTask
@@ -11371,7 +11371,7 @@ await client.Anomaly.Blocks.CheckIpAsync("id");
-
client.Anomaly.Blocks.UnblockIpAsync(id) +
client.Anomaly.Blocks.UnblockIpAsync(id) -> WithRawResponseTask
@@ -12030,7 +12030,7 @@ await client.Branding.Templates.GetUniversalLoginAsync();
-
client.Branding.Templates.UpdateUniversalLoginAsync(UpdateUniversalLoginTemplateRequestContent { ... }) +
client.Branding.Templates.UpdateUniversalLoginAsync(UpdateUniversalLoginTemplateRequestContent { ... }) -> WithRawResponseTask
@@ -12107,7 +12107,7 @@ await client.Branding.Templates.UpdateUniversalLoginAsync("string");
-
client.Branding.Templates.DeleteUniversalLoginAsync() +
client.Branding.Templates.DeleteUniversalLoginAsync() -> WithRawResponseTask
@@ -12341,7 +12341,7 @@ await client.Branding.Themes.GetAsync("themeId");
-
client.Branding.Themes.DeleteAsync(themeId) +
client.Branding.Themes.DeleteAsync(themeId) -> WithRawResponseTask
@@ -12691,7 +12691,7 @@ await client.Branding.Phone.Providers.GetAsync("id");
-
client.Branding.Phone.Providers.DeleteAsync(id) +
client.Branding.Phone.Providers.DeleteAsync(id) -> WithRawResponseTask
@@ -12985,7 +12985,7 @@ await client.Branding.Phone.Templates.GetAsync("id");
-
client.Branding.Phone.Templates.DeleteAsync(id) +
client.Branding.Phone.Templates.DeleteAsync(id) -> WithRawResponseTask
@@ -13469,7 +13469,7 @@ await client.Clients.Credentials.GetAsync("client_id", "credential_id");
-
client.Clients.Credentials.DeleteAsync(clientId, credentialId) +
client.Clients.Credentials.DeleteAsync(clientId, credentialId) -> WithRawResponseTask
@@ -13857,7 +13857,7 @@ await client.Connections.DirectoryProvisioning.CreateAsync(
-
client.Connections.DirectoryProvisioning.DeleteAsync(id) +
client.Connections.DirectoryProvisioning.DeleteAsync(id) -> WithRawResponseTask
@@ -14095,7 +14095,7 @@ await client.Connections.DirectoryProvisioning.ListSynchronizedGroupsAsync(
-
client.Connections.DirectoryProvisioning.SetAsync(id, ReplaceSynchronizedGroupsRequestContent { ... }) +
client.Connections.DirectoryProvisioning.SetAsync(id, ReplaceSynchronizedGroupsRequestContent { ... }) -> WithRawResponseTask
@@ -14342,7 +14342,7 @@ await client.Connections.ScimConfiguration.CreateAsync(
-
client.Connections.ScimConfiguration.DeleteAsync(id) +
client.Connections.ScimConfiguration.DeleteAsync(id) -> WithRawResponseTask
@@ -14587,7 +14587,7 @@ await client.Connections.Clients.GetAsync(
-
client.Connections.Clients.UpdateAsync(id, IEnumerable<UpdateEnabledClientConnectionsRequestContentItem> { ... }) +
client.Connections.Clients.UpdateAsync(id, IEnumerable<UpdateEnabledClientConnectionsRequestContentItem> { ... }) -> WithRawResponseTask
@@ -14825,7 +14825,7 @@ await client.Connections.Keys.RotateAsync("id", new RotateConnectionKeysRequestC
## Connections Users -
client.Connections.Users.DeleteByEmailAsync(id, DeleteConnectionUsersByEmailQueryParameters { ... }) +
client.Connections.Users.DeleteByEmailAsync(id, DeleteConnectionUsersByEmailQueryParameters { ... }) -> WithRawResponseTask
@@ -15065,7 +15065,7 @@ await client.Connections.ScimConfiguration.Tokens.CreateAsync(
-
client.Connections.ScimConfiguration.Tokens.DeleteAsync(id, tokenId) +
client.Connections.ScimConfiguration.Tokens.DeleteAsync(id, tokenId) -> WithRawResponseTask
@@ -15268,7 +15268,7 @@ await client.Emails.Provider.CreateAsync(
-
client.Emails.Provider.DeleteAsync() +
client.Emails.Provider.DeleteAsync() -> WithRawResponseTask
@@ -15546,7 +15546,7 @@ await client.EventStreams.Redeliveries.CreateAsync(
-
client.EventStreams.Redeliveries.CreateByIdAsync(id, eventId) +
client.EventStreams.Redeliveries.CreateByIdAsync(id, eventId) -> WithRawResponseTask
@@ -15712,7 +15712,7 @@ await client.Flows.Executions.GetAsync(
-
client.Flows.Executions.DeleteAsync(flowId, executionId) +
client.Flows.Executions.DeleteAsync(flowId, executionId) -> WithRawResponseTask
@@ -15900,7 +15900,7 @@ await client.Flows.Vault.Connections.GetAsync("id");
-
client.Flows.Vault.Connections.DeleteAsync(id) +
client.Flows.Vault.Connections.DeleteAsync(id) -> WithRawResponseTask
@@ -16129,7 +16129,7 @@ await client.Groups.Roles.ListAsync(
-
client.Groups.Roles.CreateAsync(id, CreateGroupRolesRequestParameters { ... }) +
client.Groups.Roles.CreateAsync(id, CreateGroupRolesRequestParameters { ... }) -> WithRawResponseTask
@@ -16194,7 +16194,7 @@ await client.Groups.Roles.CreateAsync(
-
client.Groups.Roles.DeleteAsync(id, DeleteGroupRolesRequestContent { ... }) +
client.Groups.Roles.DeleteAsync(id, DeleteGroupRolesRequestContent { ... }) -> WithRawResponseTask
@@ -16370,7 +16370,7 @@ await client.Guardian.Enrollments.GetAsync("id");
-
client.Guardian.Enrollments.DeleteAsync(id) +
client.Guardian.Enrollments.DeleteAsync(id) -> WithRawResponseTask
@@ -17846,7 +17846,7 @@ await client.Guardian.Factors.Sms.SetProviderAsync(
-
client.Guardian.Factors.Sms.GetTemplatesAsync() -> WithRawResponseTask<GetGuardianFactorSmsTemplatesResponseContent> +
client.Guardian.Factors.Sms.GetTemplatesAsync() -> WithRawResponseTask<GetGuardianFactorSmsTemplatesResponseContent?>
@@ -18142,7 +18142,7 @@ await client.Hooks.Secrets.GetAsync("id");
-
client.Hooks.Secrets.CreateAsync(id, Dictionary<string, string> { ... }) +
client.Hooks.Secrets.CreateAsync(id, Dictionary<string, string> { ... }) -> WithRawResponseTask
@@ -18207,7 +18207,7 @@ await client.Hooks.Secrets.CreateAsync(
-
client.Hooks.Secrets.DeleteAsync(id, IEnumerable<string> { ... }) +
client.Hooks.Secrets.DeleteAsync(id, IEnumerable<string> { ... }) -> WithRawResponseTask
@@ -18269,7 +18269,7 @@ await client.Hooks.Secrets.DeleteAsync("id", new List() { "string" });
-
client.Hooks.Secrets.UpdateAsync(id, Dictionary<string, string> { ... }) +
client.Hooks.Secrets.UpdateAsync(id, Dictionary<string, string> { ... }) -> WithRawResponseTask
@@ -18506,7 +18506,7 @@ await client.Jobs.VerificationEmail.CreateAsync(
## Jobs Errors -
client.Jobs.Errors.GetAsync(id) -> WithRawResponseTask<ErrorsGetResponse> +
client.Jobs.Errors.GetAsync(id) -> WithRawResponseTask<ErrorsGetResponse?>
@@ -18662,7 +18662,7 @@ await client.Keys.CustomSigning.SetAsync(
-
client.Keys.CustomSigning.DeleteAsync() +
client.Keys.CustomSigning.DeleteAsync() -> WithRawResponseTask
@@ -18819,7 +18819,7 @@ await client.Keys.Encryption.CreateAsync(
-
client.Keys.Encryption.RekeyAsync() +
client.Keys.Encryption.RekeyAsync() -> WithRawResponseTask
@@ -18977,7 +18977,7 @@ await client.Keys.Encryption.ImportAsync(
-
client.Keys.Encryption.DeleteAsync(kid) +
client.Keys.Encryption.DeleteAsync(kid) -> WithRawResponseTask
@@ -19383,7 +19383,7 @@ await client.Organizations.ClientGrants.CreateAsync(
-
client.Organizations.ClientGrants.DeleteAsync(id, grantId) +
client.Organizations.ClientGrants.DeleteAsync(id, grantId) -> WithRawResponseTask
@@ -19588,7 +19588,7 @@ await client.Organizations.Connections.GetAsync("id", "connection_id");
-
client.Organizations.Connections.DeleteAsync(id, connectionId) +
client.Organizations.Connections.DeleteAsync(id, connectionId) -> WithRawResponseTask
@@ -19954,7 +19954,7 @@ await client.Organizations.DiscoveryDomains.GetAsync("id", "discovery_domain_id"
-
client.Organizations.DiscoveryDomains.DeleteAsync(id, discoveryDomainId) +
client.Organizations.DiscoveryDomains.DeleteAsync(id, discoveryDomainId) -> WithRawResponseTask
@@ -20290,7 +20290,7 @@ await client.Organizations.EnabledConnections.GetAsync("id", "connectionId");
-
client.Organizations.EnabledConnections.DeleteAsync(id, connectionId) +
client.Organizations.EnabledConnections.DeleteAsync(id, connectionId) -> WithRawResponseTask
@@ -20632,7 +20632,7 @@ await client.Organizations.Invitations.GetAsync(
-
client.Organizations.Invitations.DeleteAsync(id, invitationId) +
client.Organizations.Invitations.DeleteAsync(id, invitationId) -> WithRawResponseTask
@@ -20767,7 +20767,7 @@ await client.Organizations.Members.ListAsync(
-
client.Organizations.Members.CreateAsync(id, CreateOrganizationMemberRequestContent { ... }) +
client.Organizations.Members.CreateAsync(id, CreateOrganizationMemberRequestContent { ... }) -> WithRawResponseTask
@@ -20834,7 +20834,7 @@ await client.Organizations.Members.CreateAsync(
-
client.Organizations.Members.DeleteAsync(id, DeleteOrganizationMembersRequestContent { ... }) +
client.Organizations.Members.DeleteAsync(id, DeleteOrganizationMembersRequestContent { ... }) -> WithRawResponseTask
@@ -21026,7 +21026,7 @@ await client.Organizations.Groups.Roles.ListAsync(
-
client.Organizations.Groups.Roles.CreateAsync(organizationId, groupId, CreateOrganizationGroupRolesRequestContent { ... }) +
client.Organizations.Groups.Roles.CreateAsync(organizationId, groupId, CreateOrganizationGroupRolesRequestContent { ... }) -> WithRawResponseTask
@@ -21100,7 +21100,7 @@ await client.Organizations.Groups.Roles.CreateAsync(
-
client.Organizations.Groups.Roles.DeleteAsync(organizationId, groupId, DeleteOrganizationGroupRolesRequestContent { ... }) +
client.Organizations.Groups.Roles.DeleteAsync(organizationId, groupId, DeleteOrganizationGroupRolesRequestContent { ... }) -> WithRawResponseTask
@@ -21331,7 +21331,7 @@ await client.Organizations.Members.Roles.ListAsync(
-
client.Organizations.Members.Roles.AssignAsync(id, userId, AssignOrganizationMemberRolesRequestContent { ... }) +
client.Organizations.Members.Roles.AssignAsync(id, userId, AssignOrganizationMemberRolesRequestContent { ... }) -> WithRawResponseTask
@@ -21407,7 +21407,7 @@ await client.Organizations.Members.Roles.AssignAsync(
-
client.Organizations.Members.Roles.DeleteAsync(id, userId, DeleteOrganizationMemberRolesRequestContent { ... }) +
client.Organizations.Members.Roles.DeleteAsync(id, userId, DeleteOrganizationMemberRolesRequestContent { ... }) -> WithRawResponseTask
@@ -21559,6 +21559,87 @@ await client.Organizations.Members.EffectiveRoles.Sources.Groups.ListAsync(
+ + +
+ +## Organizations Roles Members +
client.Organizations.Roles.Members.ListAsync(id, roleId, ListOrganizationRoleMembersRequestParameters { ... }) -> Pager<RoleMember> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List the organization members assigned a specific role within the context of an organization. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Organizations.Roles.Members.ListAsync( + "id", + "role_id", + new ListOrganizationRoleMembersRequestParameters + { + From = "from", + Take = 1, + Fields = "fields", + IncludeFields = true, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `string` — ID of the organization. + +
+
+ +
+
+ +**roleId:** `string` — ID of the role to retrieve the assigned members for. + +
+
+ +
+
+ +**request:** `ListOrganizationRoleMembersRequestParameters` + +
+
+
+
+ +
@@ -21895,7 +21976,7 @@ await client.Prompts.CustomText.GetAsync(PromptGroupNameEnum.Login, PromptLangua
-
client.Prompts.CustomText.SetAsync(prompt, language, Dictionary<string, object?> { ... }) +
client.Prompts.CustomText.SetAsync(prompt, language, Dictionary<string, object?> { ... }) -> WithRawResponseTask
@@ -22024,7 +22105,7 @@ await client.Prompts.Partials.GetAsync(PartialGroupsEnum.Login);
-
client.Prompts.Partials.SetAsync(prompt, Dictionary<string, object?> { ... }) +
client.Prompts.Partials.SetAsync(prompt, Dictionary<string, object?> { ... }) -> WithRawResponseTask
@@ -22344,7 +22425,7 @@ await client.Roles.Groups.GetAsync("id", new ListRoleGroupsParameters { From = "
-
client.Roles.Groups.CreateAsync(id, AssignRoleGroupsRequestContent { ... }) +
client.Roles.Groups.CreateAsync(id, AssignRoleGroupsRequestContent { ... }) -> WithRawResponseTask
@@ -22409,7 +22490,7 @@ await client.Roles.Groups.CreateAsync(
-
client.Roles.Groups.DeleteAsync(id, DeleteRoleGroupsRequestContent { ... }) +
client.Roles.Groups.DeleteAsync(id, DeleteRoleGroupsRequestContent { ... }) -> WithRawResponseTask
@@ -22545,7 +22626,7 @@ await client.Roles.Permissions.ListAsync(
-
client.Roles.Permissions.AddAsync(id, AddRolePermissionsRequestContent { ... }) +
client.Roles.Permissions.AddAsync(id, AddRolePermissionsRequestContent { ... }) -> WithRawResponseTask
@@ -22620,7 +22701,7 @@ await client.Roles.Permissions.AddAsync(
-
client.Roles.Permissions.DeleteAsync(id, DeleteRolePermissionsRequestContent { ... }) +
client.Roles.Permissions.DeleteAsync(id, DeleteRolePermissionsRequestContent { ... }) -> WithRawResponseTask
@@ -22777,7 +22858,7 @@ await client.Roles.Users.ListAsync(
-
client.Roles.Users.AssignAsync(id, AssignRoleUsersRequestContent { ... }) +
client.Roles.Users.AssignAsync(id, AssignRoleUsersRequestContent { ... }) -> WithRawResponseTask
@@ -23068,7 +23149,7 @@ await client.SelfServiceProfiles.SsoTicket.CreateAsync(
-
client.SelfServiceProfiles.SsoTicket.RevokeAsync(profileId, id) +
client.SelfServiceProfiles.SsoTicket.RevokeAsync(profileId, id) -> WithRawResponseTask
@@ -23451,7 +23532,7 @@ await client.Users.AuthenticationMethods.SetAsync(
-
client.Users.AuthenticationMethods.DeleteAllAsync(id) +
client.Users.AuthenticationMethods.DeleteAllAsync(id) -> WithRawResponseTask
@@ -23553,7 +23634,7 @@ await client.Users.AuthenticationMethods.GetAsync("id", "authentication_method_i
-
client.Users.AuthenticationMethods.DeleteAsync(id, authenticationMethodId) +
client.Users.AuthenticationMethods.DeleteAsync(id, authenticationMethodId) -> WithRawResponseTask
@@ -23690,7 +23771,7 @@ await client.Users.AuthenticationMethods.UpdateAsync(
## Users Authenticators -
client.Users.Authenticators.DeleteAllAsync(id) +
client.Users.Authenticators.DeleteAllAsync(id) -> WithRawResponseTask
@@ -24057,7 +24138,7 @@ await client.Users.FederatedConnectionsTokensets.ListAsync("id");
-
client.Users.FederatedConnectionsTokensets.DeleteAsync(id, tokensetId) +
client.Users.FederatedConnectionsTokensets.DeleteAsync(id, tokensetId) -> WithRawResponseTask
@@ -24419,7 +24500,7 @@ await client.Users.Logs.ListAsync(
## Users Multifactor -
client.Users.Multifactor.InvalidateRememberBrowserAsync(id) +
client.Users.Multifactor.InvalidateRememberBrowserAsync(id) -> WithRawResponseTask
@@ -24473,7 +24554,7 @@ await client.Users.Multifactor.InvalidateRememberBrowserAsync("id");
-
client.Users.Multifactor.DeleteProviderAsync(id, provider) +
client.Users.Multifactor.DeleteProviderAsync(id, provider) -> WithRawResponseTask
@@ -24677,7 +24758,7 @@ await client.Users.Permissions.ListAsync(
-
client.Users.Permissions.CreateAsync(id, CreateUserPermissionsRequestContent { ... }) +
client.Users.Permissions.CreateAsync(id, CreateUserPermissionsRequestContent { ... }) -> WithRawResponseTask
@@ -24752,7 +24833,7 @@ await client.Users.Permissions.CreateAsync(
-
client.Users.Permissions.DeleteAsync(id, DeleteUserPermissionsRequestContent { ... }) +
client.Users.Permissions.DeleteAsync(id, DeleteUserPermissionsRequestContent { ... }) -> WithRawResponseTask
@@ -24828,7 +24909,7 @@ await client.Users.Permissions.DeleteAsync(
## Users RiskAssessments -
client.Users.RiskAssessments.ClearAsync(id, ClearAssessorsRequestContent { ... }) +
client.Users.RiskAssessments.ClearAsync(id, ClearAssessorsRequestContent { ... }) -> WithRawResponseTask
@@ -24970,7 +25051,7 @@ await client.Users.Roles.ListAsync(
-
client.Users.Roles.AssignAsync(id, AssignUserRolesRequestContent { ... }) +
client.Users.Roles.AssignAsync(id, AssignUserRolesRequestContent { ... }) -> WithRawResponseTask
@@ -25037,7 +25118,7 @@ await client.Users.Roles.AssignAsync(
-
client.Users.Roles.DeleteAsync(id, DeleteUserRolesRequestContent { ... }) +
client.Users.Roles.DeleteAsync(id, DeleteUserRolesRequestContent { ... }) -> WithRawResponseTask
@@ -25170,7 +25251,7 @@ await client.Users.RefreshToken.ListAsync(
-
client.Users.RefreshToken.DeleteAsync(userId) +
client.Users.RefreshToken.DeleteAsync(userId) -> WithRawResponseTask
@@ -25290,7 +25371,7 @@ await client.Users.Sessions.ListAsync(
-
client.Users.Sessions.DeleteAsync(userId) +
client.Users.Sessions.DeleteAsync(userId) -> WithRawResponseTask
@@ -25667,7 +25748,7 @@ await client.VerifiableCredentials.Verification.Templates.GetAsync("id");
-
client.VerifiableCredentials.Verification.Templates.DeleteAsync(id) +
client.VerifiableCredentials.Verification.Templates.DeleteAsync(id) -> WithRawResponseTask
diff --git a/src/Auth0.ManagementApi/Actions/ActionsClient.cs b/src/Auth0.ManagementApi/Actions/ActionsClient.cs index 7376c97f6..8adc3e629 100644 --- a/src/Auth0.ManagementApi/Actions/ActionsClient.cs +++ b/src/Auth0.ManagementApi/Actions/ActionsClient.cs @@ -86,7 +86,7 @@ private async Task> ListInt return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -100,7 +100,13 @@ private async Task> ListInt "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -113,13 +119,53 @@ private async Task> ListInt switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -129,7 +175,13 @@ private async Task> ListInt throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -140,6 +192,9 @@ private async Task> CreateAsyncCore CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -153,6 +208,7 @@ private async Task> CreateAsyncCore Method = HttpMethod.Post, Path = "actions/actions", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -173,7 +229,7 @@ private async Task> CreateAsyncCore return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -187,7 +243,13 @@ private async Task> CreateAsyncCore "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -200,13 +262,53 @@ private async Task> CreateAsyncCore switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -216,7 +318,13 @@ private async Task> CreateAsyncCore throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -227,6 +335,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -242,6 +353,7 @@ private async Task> GetAsyncCore( "actions/actions/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -259,7 +371,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -273,7 +385,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -286,15 +404,195 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + DeleteActionRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 1) + .Add("force", request.Force.IsDefined ? request.Force.Value : null) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "actions/actions/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -304,7 +602,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -316,6 +620,9 @@ private async Task> UpdateAsyncCore CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -332,6 +639,7 @@ private async Task> UpdateAsyncCore ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -352,7 +660,7 @@ private async Task> UpdateAsyncCore return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -366,7 +674,13 @@ private async Task> UpdateAsyncCore "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -379,15 +693,65 @@ private async Task> UpdateAsyncCore switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -397,7 +761,13 @@ private async Task> UpdateAsyncCore throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -408,6 +778,9 @@ private async Task> DeployAsyncCore CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -423,6 +796,7 @@ private async Task> DeployAsyncCore "actions/actions/{0}/deploy", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -442,7 +816,7 @@ private async Task> DeployAsyncCore return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -456,7 +830,13 @@ private async Task> DeployAsyncCore "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -469,13 +849,53 @@ private async Task> DeployAsyncCore switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -485,7 +905,13 @@ private async Task> DeployAsyncCore throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -497,6 +923,9 @@ private async Task> TestAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -513,6 +942,7 @@ private async Task> TestAsyncCore( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -531,7 +961,7 @@ private async Task> TestAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -545,7 +975,13 @@ private async Task> TestAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -558,13 +994,53 @@ private async Task> TestAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -574,7 +1050,13 @@ private async Task> TestAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -678,73 +1160,14 @@ public WithRawResponseTask GetAsync( /// /// await client.Actions.DeleteAsync("id", new DeleteActionRequestParameters { Force = true }); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, DeleteActionRequestParameters request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 1) - .Add("force", request.Force.IsDefined ? request.Force.Value : null) - .MergeAdditional(options?.AdditionalQueryParameters) - .Build(); - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "actions/actions/{0}", - ValueConvert.ToPathParameterString(id) - ), - QueryString = _queryString, - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, request, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Actions/Executions/ExecutionsClient.cs b/src/Auth0.ManagementApi/Actions/Executions/ExecutionsClient.cs index 485d0b524..fa3ebb680 100644 --- a/src/Auth0.ManagementApi/Actions/Executions/ExecutionsClient.cs +++ b/src/Auth0.ManagementApi/Actions/Executions/ExecutionsClient.cs @@ -19,6 +19,9 @@ private async Task> GetAsyncC CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -34,6 +37,7 @@ private async Task> GetAsyncC "actions/executions/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -53,7 +57,7 @@ private async Task> GetAsyncC return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -67,7 +71,13 @@ private async Task> GetAsyncC "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -80,15 +90,65 @@ private async Task> GetAsyncC switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -98,7 +158,13 @@ private async Task> GetAsyncC throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Actions/IActionsClient.cs b/src/Auth0.ManagementApi/Actions/IActionsClient.cs index 237d05ac8..9295029a3 100644 --- a/src/Auth0.ManagementApi/Actions/IActionsClient.cs +++ b/src/Auth0.ManagementApi/Actions/IActionsClient.cs @@ -40,7 +40,7 @@ WithRawResponseTask GetAsync( /// /// Deletes an action and all of its associated versions. An action must be unbound from all triggers before it can be deleted. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, DeleteActionRequestParameters request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Actions/Modules/IModulesClient.cs b/src/Auth0.ManagementApi/Actions/Modules/IModulesClient.cs index e9f36e579..0b9d3f7b2 100644 --- a/src/Auth0.ManagementApi/Actions/Modules/IModulesClient.cs +++ b/src/Auth0.ManagementApi/Actions/Modules/IModulesClient.cs @@ -37,7 +37,7 @@ WithRawResponseTask GetAsync( /// /// Permanently delete an Actions Module. This will fail if the module is still in use by any actions. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Actions/Modules/ModulesClient.cs b/src/Auth0.ManagementApi/Actions/Modules/ModulesClient.cs index 3342728fa..d5e2b3415 100644 --- a/src/Auth0.ManagementApi/Actions/Modules/ModulesClient.cs +++ b/src/Auth0.ManagementApi/Actions/Modules/ModulesClient.cs @@ -73,7 +73,7 @@ private async Task> ListInterna return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -87,7 +87,13 @@ private async Task> ListInterna "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -100,13 +106,53 @@ private async Task> ListInterna switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -116,7 +162,13 @@ private async Task> ListInterna throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -127,6 +179,9 @@ private async Task> CreateAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -140,6 +195,7 @@ private async Task> CreateAsy Method = HttpMethod.Post, Path = "actions/modules", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -160,7 +216,7 @@ private async Task> CreateAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -174,7 +230,13 @@ private async Task> CreateAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -187,15 +249,65 @@ private async Task> CreateAsy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -205,7 +317,13 @@ private async Task> CreateAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -216,6 +334,9 @@ private async Task> GetAsyncCore CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -231,6 +352,7 @@ private async Task> GetAsyncCore "actions/modules/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -250,7 +372,7 @@ private async Task> GetAsyncCore return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -264,7 +386,13 @@ private async Task> GetAsyncCore "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -277,15 +405,65 @@ private async Task> GetAsyncCore switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -295,7 +473,153 @@ private async Task> GetAsyncCore throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "actions/modules/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 412: + throw new PreconditionFailedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -307,6 +631,9 @@ private async Task> UpdateAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -323,6 +650,7 @@ private async Task> UpdateAsy ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -343,7 +671,7 @@ private async Task> UpdateAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -357,7 +685,13 @@ private async Task> UpdateAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -370,17 +704,77 @@ private async Task> UpdateAsy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -390,7 +784,13 @@ private async Task> UpdateAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -459,7 +859,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -473,7 +873,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -486,15 +892,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -504,7 +960,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -516,6 +978,9 @@ private async Task> Rollbac CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -532,6 +997,7 @@ private async Task> Rollbac ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -552,7 +1018,7 @@ private async Task> Rollbac return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -566,7 +1032,13 @@ private async Task> Rollbac "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -579,17 +1051,77 @@ private async Task> Rollbac switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -599,7 +1131,13 @@ private async Task> Rollbac throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -688,71 +1226,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Actions.Modules.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "actions/modules/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 412: - throw new PreconditionFailedError( - JsonUtils.Deserialize(responseBody) - ); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Actions/Modules/Versions/VersionsClient.cs b/src/Auth0.ManagementApi/Actions/Modules/Versions/VersionsClient.cs index e83d16d4c..ba7f50cc8 100644 --- a/src/Auth0.ManagementApi/Actions/Modules/Versions/VersionsClient.cs +++ b/src/Auth0.ManagementApi/Actions/Modules/Versions/VersionsClient.cs @@ -77,7 +77,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -91,7 +91,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -104,15 +110,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -122,7 +178,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -133,6 +195,9 @@ private async Task> Cr CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -148,6 +213,7 @@ private async Task> Cr "actions/modules/{0}/versions", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -167,7 +233,7 @@ private async Task> Cr return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -181,7 +247,13 @@ private async Task> Cr "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -194,18 +266,76 @@ private async Task> Cr switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 412: throw new PreconditionFailedError( - JsonUtils.Deserialize(responseBody) + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -216,7 +346,13 @@ private async Task> Cr throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -228,6 +364,9 @@ private async Task> GetAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -244,6 +383,7 @@ private async Task> GetAs ValueConvert.ToPathParameterString(id), ValueConvert.ToPathParameterString(versionId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -263,7 +403,7 @@ private async Task> GetAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -277,7 +417,13 @@ private async Task> GetAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -290,15 +436,65 @@ private async Task> GetAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -308,7 +504,13 @@ private async Task> GetAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Actions/Triggers/Bindings/BindingsClient.cs b/src/Auth0.ManagementApi/Actions/Triggers/Bindings/BindingsClient.cs index c749a379e..1001be22a 100644 --- a/src/Auth0.ManagementApi/Actions/Triggers/Bindings/BindingsClient.cs +++ b/src/Auth0.ManagementApi/Actions/Triggers/Bindings/BindingsClient.cs @@ -78,7 +78,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -92,7 +92,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -105,13 +111,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -121,7 +167,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -133,6 +185,9 @@ private async Task> UpdateM CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -149,6 +204,7 @@ private async Task> UpdateM ValueConvert.ToPathParameterString(triggerId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -169,7 +225,7 @@ private async Task> UpdateM return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -183,7 +239,13 @@ private async Task> UpdateM "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -196,13 +258,53 @@ private async Task> UpdateM switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -212,7 +314,13 @@ private async Task> UpdateM throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Actions/Triggers/TriggersClient.cs b/src/Auth0.ManagementApi/Actions/Triggers/TriggersClient.cs index 2f2392436..7ae7a26db 100644 --- a/src/Auth0.ManagementApi/Actions/Triggers/TriggersClient.cs +++ b/src/Auth0.ManagementApi/Actions/Triggers/TriggersClient.cs @@ -22,6 +22,9 @@ private async Task> ListAsync CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -34,6 +37,7 @@ private async Task> ListAsync { Method = HttpMethod.Get, Path = "actions/triggers", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -53,7 +57,7 @@ private async Task> ListAsync return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -67,7 +71,13 @@ private async Task> ListAsync "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -80,13 +90,53 @@ private async Task> ListAsync switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -96,7 +146,13 @@ private async Task> ListAsync throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Actions/Versions/VersionsClient.cs b/src/Auth0.ManagementApi/Actions/Versions/VersionsClient.cs index 59fd531e5..697f188fa 100644 --- a/src/Auth0.ManagementApi/Actions/Versions/VersionsClient.cs +++ b/src/Auth0.ManagementApi/Actions/Versions/VersionsClient.cs @@ -78,7 +78,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -92,7 +92,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -105,13 +111,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -121,7 +167,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -133,6 +185,9 @@ private async Task> GetAsyncCor CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -149,6 +204,7 @@ private async Task> GetAsyncCor ValueConvert.ToPathParameterString(actionId), ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -168,7 +224,7 @@ private async Task> GetAsyncCor return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -182,7 +238,13 @@ private async Task> GetAsyncCor "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -195,15 +257,65 @@ private async Task> GetAsyncCor switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -213,7 +325,13 @@ private async Task> GetAsyncCor throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -226,6 +344,9 @@ private async Task> DeployAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -243,6 +364,7 @@ private async Task> DeployAs ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -262,7 +384,7 @@ private async Task> DeployAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -276,7 +398,13 @@ private async Task> DeployAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -289,13 +417,53 @@ private async Task> DeployAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -305,7 +473,13 @@ private async Task> DeployAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Anomaly/Blocks/BlocksClient.cs b/src/Auth0.ManagementApi/Anomaly/Blocks/BlocksClient.cs index 7e58362e5..4770b8d37 100644 --- a/src/Auth0.ManagementApi/Anomaly/Blocks/BlocksClient.cs +++ b/src/Auth0.ManagementApi/Anomaly/Blocks/BlocksClient.cs @@ -13,18 +13,15 @@ internal BlocksClient(RawClient client) _client = client; } - /// - /// Check if the given IP address is blocked via the Suspicious IP Throttling due to multiple suspicious attempts. - /// - /// - /// await client.Anomaly.Blocks.CheckIpAsync("id"); - /// - public async Task CheckIpAsync( + private async Task CheckIpAsyncCore( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -40,6 +37,7 @@ public async Task CheckIpAsync( "anomaly/blocks/ips/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -48,7 +46,12 @@ public async Task CheckIpAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -59,15 +62,65 @@ public async Task CheckIpAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -77,23 +130,26 @@ public async Task CheckIpAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Remove a block imposed by Suspicious IP Throttling for the given IP address. - /// - /// - /// await client.Anomaly.Blocks.UnblockIpAsync("id"); - /// - public async Task UnblockIpAsync( + private async Task UnblockIpAsyncCore( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -109,6 +165,7 @@ public async Task UnblockIpAsync( "anomaly/blocks/ips/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -117,7 +174,12 @@ public async Task UnblockIpAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -128,13 +190,53 @@ public async Task UnblockIpAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -144,8 +246,44 @@ public async Task UnblockIpAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Check if the given IP address is blocked via the Suspicious IP Throttling due to multiple suspicious attempts. + /// + /// + /// await client.Anomaly.Blocks.CheckIpAsync("id"); + /// + public WithRawResponseTask CheckIpAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(CheckIpAsyncCore(id, options, cancellationToken)); + } + + /// + /// Remove a block imposed by Suspicious IP Throttling for the given IP address. + /// + /// + /// await client.Anomaly.Blocks.UnblockIpAsync("id"); + /// + public WithRawResponseTask UnblockIpAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(UnblockIpAsyncCore(id, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Anomaly/Blocks/IBlocksClient.cs b/src/Auth0.ManagementApi/Anomaly/Blocks/IBlocksClient.cs index 967637784..95186bde7 100644 --- a/src/Auth0.ManagementApi/Anomaly/Blocks/IBlocksClient.cs +++ b/src/Auth0.ManagementApi/Anomaly/Blocks/IBlocksClient.cs @@ -7,7 +7,7 @@ public partial interface IBlocksClient /// /// Check if the given IP address is blocked via the Suspicious IP Throttling due to multiple suspicious attempts. /// - Task CheckIpAsync( + WithRawResponseTask CheckIpAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -16,7 +16,7 @@ Task CheckIpAsync( /// /// Remove a block imposed by Suspicious IP Throttling for the given IP address. /// - Task UnblockIpAsync( + WithRawResponseTask UnblockIpAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/AttackProtection/BotDetection/BotDetectionClient.cs b/src/Auth0.ManagementApi/AttackProtection/BotDetection/BotDetectionClient.cs index 86f09f763..27a940464 100644 --- a/src/Auth0.ManagementApi/AttackProtection/BotDetection/BotDetectionClient.cs +++ b/src/Auth0.ManagementApi/AttackProtection/BotDetection/BotDetectionClient.cs @@ -18,6 +18,9 @@ private async Task> GetA CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -30,6 +33,7 @@ private async Task> GetA { Method = HttpMethod.Get, Path = "attack-protection/bot-detection", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -49,7 +53,7 @@ private async Task> GetA return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -63,7 +67,13 @@ private async Task> GetA "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -76,13 +86,53 @@ private async Task> GetA switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -92,7 +142,13 @@ private async Task> GetA throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -103,6 +159,9 @@ private async Task> U CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -116,6 +175,7 @@ private async Task> U Method = HttpMethodExtensions.Patch, Path = "attack-protection/bot-detection", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -136,7 +196,7 @@ private async Task> U return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -150,7 +210,13 @@ private async Task> U "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -163,15 +229,65 @@ private async Task> U switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -181,7 +297,13 @@ private async Task> U throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/AttackProtection/BreachedPasswordDetection/BreachedPasswordDetectionClient.cs b/src/Auth0.ManagementApi/AttackProtection/BreachedPasswordDetection/BreachedPasswordDetectionClient.cs index d554af87c..f2779a65d 100644 --- a/src/Auth0.ManagementApi/AttackProtection/BreachedPasswordDetection/BreachedPasswordDetectionClient.cs +++ b/src/Auth0.ManagementApi/AttackProtection/BreachedPasswordDetection/BreachedPasswordDetectionClient.cs @@ -17,6 +17,9 @@ private async Task< WithRawResponse > GetAsyncCore(RequestOptions? options = null, CancellationToken cancellationToken = default) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -29,6 +32,7 @@ private async Task< { Method = HttpMethod.Get, Path = "attack-protection/breached-password-detection", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -49,7 +53,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -63,7 +67,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -76,11 +86,41 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -90,7 +130,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -103,6 +149,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -116,6 +165,7 @@ private async Task< Method = HttpMethodExtensions.Patch, Path = "attack-protection/breached-password-detection", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -137,7 +187,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -151,7 +201,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -164,13 +220,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -180,7 +276,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/AttackProtection/BruteForceProtection/BruteForceProtectionClient.cs b/src/Auth0.ManagementApi/AttackProtection/BruteForceProtection/BruteForceProtectionClient.cs index 45f137f96..ecf65e0b6 100644 --- a/src/Auth0.ManagementApi/AttackProtection/BruteForceProtection/BruteForceProtectionClient.cs +++ b/src/Auth0.ManagementApi/AttackProtection/BruteForceProtection/BruteForceProtectionClient.cs @@ -18,6 +18,9 @@ private async Task> GetAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -30,6 +33,7 @@ private async Task> GetAsy { Method = HttpMethod.Get, Path = "attack-protection/brute-force-protection", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -49,7 +53,7 @@ private async Task> GetAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -63,7 +67,13 @@ private async Task> GetAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -76,11 +86,41 @@ private async Task> GetAsy switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -90,7 +130,13 @@ private async Task> GetAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -101,6 +147,9 @@ private async Task> Upd CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -114,6 +163,7 @@ private async Task> Upd Method = HttpMethodExtensions.Patch, Path = "attack-protection/brute-force-protection", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -134,7 +184,7 @@ private async Task> Upd return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -148,7 +198,13 @@ private async Task> Upd "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -161,13 +217,53 @@ private async Task> Upd switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -177,7 +273,13 @@ private async Task> Upd throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/AttackProtection/Captcha/CaptchaClient.cs b/src/Auth0.ManagementApi/AttackProtection/Captcha/CaptchaClient.cs index 431ecf4b2..5e1d4cef4 100644 --- a/src/Auth0.ManagementApi/AttackProtection/Captcha/CaptchaClient.cs +++ b/src/Auth0.ManagementApi/AttackProtection/Captcha/CaptchaClient.cs @@ -18,6 +18,9 @@ private async Task> G CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -30,6 +33,7 @@ private async Task> G { Method = HttpMethod.Get, Path = "attack-protection/captcha", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -49,7 +53,7 @@ private async Task> G return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -63,7 +67,13 @@ private async Task> G "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -76,13 +86,53 @@ private async Task> G switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -92,7 +142,13 @@ private async Task> G throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -105,6 +161,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -118,6 +177,7 @@ private async Task< Method = HttpMethodExtensions.Patch, Path = "attack-protection/captcha", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -139,7 +199,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -153,7 +213,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -166,13 +232,53 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -182,7 +288,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/AttackProtection/PhoneProviderProtection/PhoneProviderProtectionClient.cs b/src/Auth0.ManagementApi/AttackProtection/PhoneProviderProtection/PhoneProviderProtectionClient.cs index 6f62561f9..377e37ec4 100644 --- a/src/Auth0.ManagementApi/AttackProtection/PhoneProviderProtection/PhoneProviderProtectionClient.cs +++ b/src/Auth0.ManagementApi/AttackProtection/PhoneProviderProtection/PhoneProviderProtectionClient.cs @@ -18,6 +18,9 @@ private async Task> G CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -30,6 +33,7 @@ private async Task> G { Method = HttpMethod.Get, Path = "attack-protection/phone-provider-protection", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -49,7 +53,7 @@ private async Task> G return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -63,7 +67,13 @@ private async Task> G "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -76,13 +86,53 @@ private async Task> G switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -92,7 +142,13 @@ private async Task> G throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -103,6 +159,9 @@ private async Task> CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -116,6 +175,7 @@ private async Task> Method = HttpMethodExtensions.Patch, Path = "attack-protection/phone-provider-protection", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -137,7 +197,7 @@ private async Task> return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -151,7 +211,13 @@ private async Task> "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -164,11 +230,41 @@ private async Task> switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -178,7 +274,13 @@ private async Task> throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/AttackProtection/SuspiciousIpThrottling/SuspiciousIpThrottlingClient.cs b/src/Auth0.ManagementApi/AttackProtection/SuspiciousIpThrottling/SuspiciousIpThrottlingClient.cs index 83abdbc53..d839ba4c2 100644 --- a/src/Auth0.ManagementApi/AttackProtection/SuspiciousIpThrottling/SuspiciousIpThrottlingClient.cs +++ b/src/Auth0.ManagementApi/AttackProtection/SuspiciousIpThrottling/SuspiciousIpThrottlingClient.cs @@ -17,6 +17,9 @@ private async Task< WithRawResponse > GetAsyncCore(RequestOptions? options = null, CancellationToken cancellationToken = default) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -29,6 +32,7 @@ private async Task< { Method = HttpMethod.Get, Path = "attack-protection/suspicious-ip-throttling", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -49,7 +53,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -63,7 +67,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -76,11 +86,41 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -90,7 +130,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -103,6 +149,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -116,6 +165,7 @@ private async Task< Method = HttpMethodExtensions.Patch, Path = "attack-protection/suspicious-ip-throttling", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -137,7 +187,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -151,7 +201,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -164,13 +220,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -180,7 +276,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Auth0.ManagementApi.csproj b/src/Auth0.ManagementApi/Auth0.ManagementApi.csproj index efc3b8fdb..0c9865f24 100644 --- a/src/Auth0.ManagementApi/Auth0.ManagementApi.csproj +++ b/src/Auth0.ManagementApi/Auth0.ManagementApi.csproj @@ -5,7 +5,7 @@ enable 12 enable - 7.46.0 + 7.47.0 $(Version) $(Version) README.md diff --git a/src/Auth0.ManagementApi/Branding/BrandingClient.cs b/src/Auth0.ManagementApi/Branding/BrandingClient.cs index d5ccd65d3..036364b8b 100644 --- a/src/Auth0.ManagementApi/Branding/BrandingClient.cs +++ b/src/Auth0.ManagementApi/Branding/BrandingClient.cs @@ -27,6 +27,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -39,6 +42,7 @@ private async Task> GetAsyncCore( { Method = HttpMethod.Get, Path = "branding", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -56,7 +60,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -70,7 +74,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -83,11 +93,41 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -97,7 +137,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -108,6 +154,9 @@ private async Task> UpdateAsyncCo CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -121,6 +170,7 @@ private async Task> UpdateAsyncCo Method = HttpMethodExtensions.Patch, Path = "branding", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -141,7 +191,7 @@ private async Task> UpdateAsyncCo return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -155,7 +205,13 @@ private async Task> UpdateAsyncCo "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -168,13 +224,53 @@ private async Task> UpdateAsyncCo switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -184,7 +280,13 @@ private async Task> UpdateAsyncCo throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Branding/Phone/Providers/IProvidersClient.cs b/src/Auth0.ManagementApi/Branding/Phone/Providers/IProvidersClient.cs index 777a68fcd..623fa8c76 100644 --- a/src/Auth0.ManagementApi/Branding/Phone/Providers/IProvidersClient.cs +++ b/src/Auth0.ManagementApi/Branding/Phone/Providers/IProvidersClient.cs @@ -35,7 +35,7 @@ WithRawResponseTask GetAsync( /// /// Delete the configured phone provider. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Branding/Phone/Providers/ProvidersClient.cs b/src/Auth0.ManagementApi/Branding/Phone/Providers/ProvidersClient.cs index 14398c862..b495963e9 100644 --- a/src/Auth0.ManagementApi/Branding/Phone/Providers/ProvidersClient.cs +++ b/src/Auth0.ManagementApi/Branding/Phone/Providers/ProvidersClient.cs @@ -55,7 +55,7 @@ private async Task> L return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -69,7 +69,13 @@ private async Task> L "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -82,13 +88,53 @@ private async Task> L switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -98,7 +144,13 @@ private async Task> L throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,6 +161,9 @@ private async Task> CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -122,6 +177,7 @@ private async Task> Method = HttpMethod.Post, Path = "branding/phone/providers", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -143,7 +199,7 @@ private async Task> return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -157,7 +213,13 @@ private async Task> "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -170,15 +232,65 @@ private async Task> switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -188,7 +300,13 @@ private async Task> throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -199,6 +317,9 @@ private async Task> Get CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -214,6 +335,7 @@ private async Task> Get "branding/phone/providers/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -233,7 +355,7 @@ private async Task> Get return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -247,7 +369,13 @@ private async Task> Get "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -260,15 +388,65 @@ private async Task> Get switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -278,7 +456,129 @@ private async Task> Get throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "branding/phone/providers/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -290,6 +590,9 @@ private async Task> CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -306,6 +609,7 @@ private async Task> ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -327,7 +631,7 @@ private async Task> return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -341,7 +645,13 @@ private async Task> "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -354,17 +664,77 @@ private async Task> switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -374,7 +744,13 @@ private async Task> throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -386,6 +762,9 @@ private async Task> CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -402,6 +781,7 @@ private async Task> ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -423,7 +803,7 @@ private async Task> return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -437,7 +817,13 @@ private async Task> "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -450,17 +836,77 @@ private async Task> switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -470,7 +916,13 @@ private async Task> throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -541,65 +993,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Branding.Phone.Providers.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "branding/phone/providers/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Branding/Phone/Templates/ITemplatesClient.cs b/src/Auth0.ManagementApi/Branding/Phone/Templates/ITemplatesClient.cs index 15d369277..e5020e4d0 100644 --- a/src/Auth0.ManagementApi/Branding/Phone/Templates/ITemplatesClient.cs +++ b/src/Auth0.ManagementApi/Branding/Phone/Templates/ITemplatesClient.cs @@ -22,7 +22,7 @@ WithRawResponseTask GetAsync( CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Branding/Phone/Templates/TemplatesClient.cs b/src/Auth0.ManagementApi/Branding/Phone/Templates/TemplatesClient.cs index 0d4b5ff02..95e391a2d 100644 --- a/src/Auth0.ManagementApi/Branding/Phone/Templates/TemplatesClient.cs +++ b/src/Auth0.ManagementApi/Branding/Phone/Templates/TemplatesClient.cs @@ -55,7 +55,7 @@ private async Task> ListAsync return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -69,7 +69,13 @@ private async Task> ListAsync "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -82,13 +88,53 @@ private async Task> ListAsync switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -98,7 +144,13 @@ private async Task> ListAsync throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,6 +161,9 @@ private async Task> CreateAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -122,6 +177,7 @@ private async Task> CreateAs Method = HttpMethod.Post, Path = "branding/phone/templates", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -142,7 +198,7 @@ private async Task> CreateAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -156,7 +212,13 @@ private async Task> CreateAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -169,15 +231,65 @@ private async Task> CreateAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -187,7 +299,13 @@ private async Task> CreateAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -198,6 +316,9 @@ private async Task> GetAsyncCor CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -213,6 +334,7 @@ private async Task> GetAsyncCor "branding/phone/templates/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -232,7 +354,7 @@ private async Task> GetAsyncCor return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -246,7 +368,13 @@ private async Task> GetAsyncCor "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -259,15 +387,193 @@ private async Task> GetAsyncCor switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "branding/phone/templates/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -277,7 +583,13 @@ private async Task> GetAsyncCor throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -289,6 +601,9 @@ private async Task> UpdateAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -305,6 +620,7 @@ private async Task> UpdateAs ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -325,7 +641,7 @@ private async Task> UpdateAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -339,7 +655,13 @@ private async Task> UpdateAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -352,15 +674,65 @@ private async Task> UpdateAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -370,7 +742,13 @@ private async Task> UpdateAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -382,6 +760,9 @@ private async Task> ResetAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -398,6 +779,7 @@ private async Task> ResetAsyn ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -417,7 +799,7 @@ private async Task> ResetAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -431,7 +813,13 @@ private async Task> ResetAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -444,13 +832,53 @@ private async Task> ResetAsyn switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -460,7 +888,13 @@ private async Task> ResetAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -474,6 +908,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -490,6 +927,7 @@ private async Task< ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -511,7 +949,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -525,7 +963,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -538,15 +982,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -556,7 +1050,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -608,67 +1108,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Branding.Phone.Templates.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "branding/phone/templates/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Branding/Templates/ITemplatesClient.cs b/src/Auth0.ManagementApi/Branding/Templates/ITemplatesClient.cs index a37c12410..0a9d4b6fb 100644 --- a/src/Auth0.ManagementApi/Branding/Templates/ITemplatesClient.cs +++ b/src/Auth0.ManagementApi/Branding/Templates/ITemplatesClient.cs @@ -35,13 +35,13 @@ WithRawResponseTask GetUniversalLoginA /// </html> /// ``` /// - Task UpdateUniversalLoginAsync( + WithRawResponseTask UpdateUniversalLoginAsync( UpdateUniversalLoginTemplateRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ); - Task DeleteUniversalLoginAsync( + WithRawResponseTask DeleteUniversalLoginAsync( RequestOptions? options = null, CancellationToken cancellationToken = default ); diff --git a/src/Auth0.ManagementApi/Branding/Templates/TemplatesClient.cs b/src/Auth0.ManagementApi/Branding/Templates/TemplatesClient.cs index 9df39dfe6..e49641355 100644 --- a/src/Auth0.ManagementApi/Branding/Templates/TemplatesClient.cs +++ b/src/Auth0.ManagementApi/Branding/Templates/TemplatesClient.cs @@ -20,6 +20,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -32,6 +35,7 @@ private async Task< { Method = HttpMethod.Get, Path = "branding/templates/universal-login", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -51,7 +55,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -65,7 +69,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -78,15 +88,65 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 402: - throw new PaymentRequiredError(JsonUtils.Deserialize(responseBody)); + throw new PaymentRequiredError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -96,59 +156,26 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// await client.Branding.Templates.GetUniversalLoginAsync(); - /// - public WithRawResponseTask GetUniversalLoginAsync( - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask( - GetUniversalLoginAsyncCore(options, cancellationToken) - ); - } - - /// - /// Update the Universal Login branding template. - /// - /// When `content-type` header is set to `application/json`: - /// - /// ```json - /// { - /// "template": "{% assign resolved_dir = dir | default: \"auto\" %}<html lang=\"{{locale}}\" dir=\"{{resolved_dir}}\"><head>{%- auth0:head -%}</head><body class=\"_widget-auto-layout\">{%- auth0:widget -%}</body></html>" - /// } - /// ``` - /// - /// When `content-type` header is set to `text/html`: - /// - /// ```html - /// - /// {% assign resolved_dir = dir | default: "auto" %} - /// <html lang="{{locale}}" dir="{{resolved_dir}}"> - /// <head> - /// {%- auth0:head -%} - /// </head> - /// <body class="_widget-auto-layout"> - /// {%- auth0:widget -%} - /// </body> - /// </html> - /// ``` - /// - /// - /// await client.Branding.Templates.UpdateUniversalLoginAsync("string"); - /// - public async Task UpdateUniversalLoginAsync( + private async Task UpdateUniversalLoginAsyncCore( UpdateUniversalLoginTemplateRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -162,6 +189,7 @@ public async Task UpdateUniversalLoginAsync( Method = HttpMethod.Put, Path = "branding/templates/universal-login", Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -170,7 +198,12 @@ public async Task UpdateUniversalLoginAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -181,17 +214,77 @@ public async Task UpdateUniversalLoginAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 402: - throw new PaymentRequiredError(JsonUtils.Deserialize(responseBody)); + throw new PaymentRequiredError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -201,19 +294,25 @@ public async Task UpdateUniversalLoginAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// await client.Branding.Templates.DeleteUniversalLoginAsync(); - /// - public async Task DeleteUniversalLoginAsync( + private async Task DeleteUniversalLoginAsyncCore( RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -226,6 +325,7 @@ public async Task DeleteUniversalLoginAsync( { Method = HttpMethod.Delete, Path = "branding/templates/universal-login", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -234,7 +334,12 @@ public async Task DeleteUniversalLoginAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -245,13 +350,53 @@ public async Task DeleteUniversalLoginAsync( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 402: - throw new PaymentRequiredError(JsonUtils.Deserialize(responseBody)); + throw new PaymentRequiredError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -261,8 +406,78 @@ public async Task DeleteUniversalLoginAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// await client.Branding.Templates.GetUniversalLoginAsync(); + /// + public WithRawResponseTask GetUniversalLoginAsync( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + GetUniversalLoginAsyncCore(options, cancellationToken) + ); + } + + /// + /// Update the Universal Login branding template. + /// + /// When `content-type` header is set to `application/json`: + /// + /// ```json + /// { + /// "template": "{% assign resolved_dir = dir | default: \"auto\" %}<html lang=\"{{locale}}\" dir=\"{{resolved_dir}}\"><head>{%- auth0:head -%}</head><body class=\"_widget-auto-layout\">{%- auth0:widget -%}</body></html>" + /// } + /// ``` + /// + /// When `content-type` header is set to `text/html`: + /// + /// ```html + /// + /// {% assign resolved_dir = dir | default: "auto" %} + /// <html lang="{{locale}}" dir="{{resolved_dir}}"> + /// <head> + /// {%- auth0:head -%} + /// </head> + /// <body class="_widget-auto-layout"> + /// {%- auth0:widget -%} + /// </body> + /// </html> + /// ``` + /// + /// + /// await client.Branding.Templates.UpdateUniversalLoginAsync("string"); + /// + public WithRawResponseTask UpdateUniversalLoginAsync( + UpdateUniversalLoginTemplateRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + UpdateUniversalLoginAsyncCore(request, options, cancellationToken) + ); + } + + /// + /// await client.Branding.Templates.DeleteUniversalLoginAsync(); + /// + public WithRawResponseTask DeleteUniversalLoginAsync( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteUniversalLoginAsyncCore(options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Branding/Themes/IThemesClient.cs b/src/Auth0.ManagementApi/Branding/Themes/IThemesClient.cs index aada4e6c0..beec0ef79 100644 --- a/src/Auth0.ManagementApi/Branding/Themes/IThemesClient.cs +++ b/src/Auth0.ManagementApi/Branding/Themes/IThemesClient.cs @@ -33,7 +33,7 @@ WithRawResponseTask GetAsync( /// /// Delete branding theme. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string themeId, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Branding/Themes/ThemesClient.cs b/src/Auth0.ManagementApi/Branding/Themes/ThemesClient.cs index 360e7f95a..3b7e67065 100644 --- a/src/Auth0.ManagementApi/Branding/Themes/ThemesClient.cs +++ b/src/Auth0.ManagementApi/Branding/Themes/ThemesClient.cs @@ -19,6 +19,9 @@ private async Task> CreateAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -32,6 +35,7 @@ private async Task> CreateAs Method = HttpMethod.Post, Path = "branding/themes", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -52,7 +56,7 @@ private async Task> CreateAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -66,7 +70,13 @@ private async Task> CreateAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -79,15 +89,65 @@ private async Task> CreateAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -97,7 +157,13 @@ private async Task> CreateAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -107,6 +173,9 @@ private async Task> GetD CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -119,6 +188,7 @@ private async Task> GetD { Method = HttpMethod.Get, Path = "branding/themes/default", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -138,7 +208,7 @@ private async Task> GetD return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -152,7 +222,13 @@ private async Task> GetD "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -165,13 +241,53 @@ private async Task> GetD switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -181,7 +297,13 @@ private async Task> GetD throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -192,6 +314,9 @@ private async Task> GetAsyncCor CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -207,6 +332,7 @@ private async Task> GetAsyncCor "branding/themes/{0}", ValueConvert.ToPathParameterString(themeId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -226,7 +352,7 @@ private async Task> GetAsyncCor return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -240,7 +366,13 @@ private async Task> GetAsyncCor "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -253,13 +385,169 @@ private async Task> GetAsyncCor switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string themeId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "branding/themes/{0}", + ValueConvert.ToPathParameterString(themeId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -269,7 +557,13 @@ private async Task> GetAsyncCor throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -281,6 +575,9 @@ private async Task> UpdateAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -297,6 +594,7 @@ private async Task> UpdateAs ValueConvert.ToPathParameterString(themeId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -317,7 +615,7 @@ private async Task> UpdateAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -331,7 +629,13 @@ private async Task> UpdateAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -344,15 +648,65 @@ private async Task> UpdateAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -362,7 +716,13 @@ private async Task> UpdateAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -484,65 +844,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Branding.Themes.DeleteAsync("themeId"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string themeId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "branding/themes/{0}", - ValueConvert.ToPathParameterString(themeId) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(themeId, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/ClientGrants/ClientGrantsClient.cs b/src/Auth0.ManagementApi/ClientGrants/ClientGrantsClient.cs index 490e71cc3..25b3de9a6 100644 --- a/src/Auth0.ManagementApi/ClientGrants/ClientGrantsClient.cs +++ b/src/Auth0.ManagementApi/ClientGrants/ClientGrantsClient.cs @@ -82,7 +82,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -96,7 +96,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,11 +115,41 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -123,7 +159,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -134,6 +176,9 @@ private async Task> CreateAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -147,6 +192,7 @@ private async Task> CreateAsyn Method = HttpMethod.Post, Path = "client-grants", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -167,7 +213,7 @@ private async Task> CreateAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -181,7 +227,13 @@ private async Task> CreateAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -194,17 +246,77 @@ private async Task> CreateAsyn switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -214,7 +326,13 @@ private async Task> CreateAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -225,6 +343,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -240,6 +361,7 @@ private async Task> GetAsyncCore( "client-grants/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -259,7 +381,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -273,7 +395,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -286,13 +414,169 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "client-grants/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -302,7 +586,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -314,6 +604,9 @@ private async Task> UpdateAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -330,6 +623,7 @@ private async Task> UpdateAsyn ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -350,7 +644,7 @@ private async Task> UpdateAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -364,7 +658,13 @@ private async Task> UpdateAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -377,15 +677,65 @@ private async Task> UpdateAsyn switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -395,7 +745,13 @@ private async Task> UpdateAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -494,65 +850,13 @@ public WithRawResponseTask GetAsync( /// /// await client.ClientGrants.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "client-grants/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/ClientGrants/IClientGrantsClient.cs b/src/Auth0.ManagementApi/ClientGrants/IClientGrantsClient.cs index 169118473..c337d6cf8 100644 --- a/src/Auth0.ManagementApi/ClientGrants/IClientGrantsClient.cs +++ b/src/Auth0.ManagementApi/ClientGrants/IClientGrantsClient.cs @@ -37,7 +37,7 @@ WithRawResponseTask GetAsync( /// /// Delete the [Client Credential Flow](https://www.auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow) from your machine-to-machine application. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/ClientGrants/Organizations/OrganizationsClient.cs b/src/Auth0.ManagementApi/ClientGrants/Organizations/OrganizationsClient.cs index c38e6c487..3f301e79d 100644 --- a/src/Auth0.ManagementApi/ClientGrants/Organizations/OrganizationsClient.cs +++ b/src/Auth0.ManagementApi/ClientGrants/Organizations/OrganizationsClient.cs @@ -75,7 +75,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -89,7 +89,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -102,15 +108,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -120,7 +176,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Clients/ClientsClient.cs b/src/Auth0.ManagementApi/Clients/ClientsClient.cs index df4df85aa..a0ff56e1a 100644 --- a/src/Auth0.ManagementApi/Clients/ClientsClient.cs +++ b/src/Auth0.ManagementApi/Clients/ClientsClient.cs @@ -122,7 +122,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -136,7 +136,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -149,13 +155,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -165,7 +211,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -176,6 +228,9 @@ private async Task> CreateAsyncCore CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -189,6 +244,7 @@ private async Task> CreateAsyncCore Method = HttpMethod.Post, Path = "clients", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -209,7 +265,7 @@ private async Task> CreateAsyncCore return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -223,7 +279,13 @@ private async Task> CreateAsyncCore "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -236,17 +298,77 @@ private async Task> CreateAsyncCore switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -256,7 +378,13 @@ private async Task> CreateAsyncCore throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -269,6 +397,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -282,6 +413,7 @@ private async Task< Method = HttpMethod.Post, Path = "clients/cimd/preview", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -302,7 +434,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -316,7 +448,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -329,15 +467,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 500: - throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + throw new InternalServerError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -347,7 +535,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -360,6 +554,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -373,6 +570,7 @@ private async Task< Method = HttpMethod.Post, Path = "clients/cimd/register", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -393,7 +591,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -407,7 +605,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -420,15 +624,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 500: - throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + throw new InternalServerError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -438,7 +692,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -488,7 +748,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -502,7 +762,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -515,15 +781,178 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format("clients/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -533,7 +962,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -545,6 +980,9 @@ private async Task> UpdateAsyncCore CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -558,6 +996,7 @@ private async Task> UpdateAsyncCore Method = HttpMethodExtensions.Patch, Path = string.Format("clients/{0}", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -578,7 +1017,7 @@ private async Task> UpdateAsyncCore return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -592,7 +1031,13 @@ private async Task> UpdateAsyncCore "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -605,15 +1050,65 @@ private async Task> UpdateAsyncCore switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -623,7 +1118,13 @@ private async Task> UpdateAsyncCore throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -634,6 +1135,9 @@ private async Task> RotateSec CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -649,6 +1153,7 @@ private async Task> RotateSec "clients/{0}/rotate-secret", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -668,7 +1173,7 @@ private async Task> RotateSec return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -682,7 +1187,13 @@ private async Task> RotateSec "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -695,15 +1206,65 @@ private async Task> RotateSec switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -713,7 +1274,13 @@ private async Task> RotateSec throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -926,62 +1493,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Clients.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format("clients/{0}", ValueConvert.ToPathParameterString(id)), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Clients/Connections/ConnectionsClient.cs b/src/Auth0.ManagementApi/Clients/Connections/ConnectionsClient.cs index 25ac076fb..f6ef1e3d4 100644 --- a/src/Auth0.ManagementApi/Clients/Connections/ConnectionsClient.cs +++ b/src/Auth0.ManagementApi/Clients/Connections/ConnectionsClient.cs @@ -84,7 +84,7 @@ private async Task> GetInt return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -98,7 +98,13 @@ private async Task> GetInt "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -111,15 +117,65 @@ private async Task> GetInt switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -129,7 +185,13 @@ private async Task> GetInt throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Clients/Credentials/CredentialsClient.cs b/src/Auth0.ManagementApi/Clients/Credentials/CredentialsClient.cs index 95f0eaf9f..557864f6e 100644 --- a/src/Auth0.ManagementApi/Clients/Credentials/CredentialsClient.cs +++ b/src/Auth0.ManagementApi/Clients/Credentials/CredentialsClient.cs @@ -19,6 +19,9 @@ private async Task>> ListAsyncCore CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -34,6 +37,7 @@ private async Task>> ListAsyncCore "clients/{0}/credentials", ValueConvert.ToPathParameterString(clientId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -53,7 +57,7 @@ private async Task>> ListAsyncCore return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -67,7 +71,13 @@ private async Task>> ListAsyncCore "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -80,13 +90,53 @@ private async Task>> ListAsyncCore switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -96,7 +146,13 @@ private async Task>> ListAsyncCore throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -108,6 +164,9 @@ private async Task> CreateA CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -124,6 +183,7 @@ private async Task> CreateA ValueConvert.ToPathParameterString(clientId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -144,7 +204,7 @@ private async Task> CreateA return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -158,7 +218,13 @@ private async Task> CreateA "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -171,15 +237,65 @@ private async Task> CreateA switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -189,7 +305,13 @@ private async Task> CreateA throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -201,6 +323,9 @@ private async Task> GetAsync CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -217,6 +342,7 @@ private async Task> GetAsync ValueConvert.ToPathParameterString(clientId), ValueConvert.ToPathParameterString(credentialId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -236,7 +362,7 @@ private async Task> GetAsync return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -250,7 +376,13 @@ private async Task> GetAsync "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -263,13 +395,171 @@ private async Task> GetAsync switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string clientId, + string credentialId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "clients/{0}/credentials/{1}", + ValueConvert.ToPathParameterString(clientId), + ValueConvert.ToPathParameterString(credentialId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -279,7 +569,13 @@ private async Task> GetAsync throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -292,6 +588,9 @@ private async Task> Update CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -309,6 +608,7 @@ private async Task> Update ValueConvert.ToPathParameterString(credentialId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -329,7 +629,7 @@ private async Task> Update return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -343,7 +643,13 @@ private async Task> Update "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -356,15 +662,65 @@ private async Task> Update switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -374,7 +730,13 @@ private async Task> Update throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -501,67 +863,16 @@ public WithRawResponseTask GetAsync( /// /// await client.Clients.Credentials.DeleteAsync("client_id", "credential_id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string clientId, string credentialId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "clients/{0}/credentials/{1}", - ValueConvert.ToPathParameterString(clientId), - ValueConvert.ToPathParameterString(credentialId) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask( + DeleteAsyncCore(clientId, credentialId, options, cancellationToken) + ); } /// diff --git a/src/Auth0.ManagementApi/Clients/Credentials/ICredentialsClient.cs b/src/Auth0.ManagementApi/Clients/Credentials/ICredentialsClient.cs index d267a38c3..723e6fe44 100644 --- a/src/Auth0.ManagementApi/Clients/Credentials/ICredentialsClient.cs +++ b/src/Auth0.ManagementApi/Clients/Credentials/ICredentialsClient.cs @@ -96,7 +96,7 @@ WithRawResponseTask GetAsync( /// /// Delete a client credential you previously created. May be enabled or disabled. For more information, read Client Credential Flow. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string clientId, string credentialId, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Clients/IClientsClient.cs b/src/Auth0.ManagementApi/Clients/IClientsClient.cs index 4845dbe33..d1644eb19 100644 --- a/src/Auth0.ManagementApi/Clients/IClientsClient.cs +++ b/src/Auth0.ManagementApi/Clients/IClientsClient.cs @@ -129,7 +129,7 @@ WithRawResponseTask GetAsync( /// /// Delete a client and related configuration (rules, connections, etc). /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/ConnectionProfiles/ConnectionProfilesClient.cs b/src/Auth0.ManagementApi/ConnectionProfiles/ConnectionProfilesClient.cs index 0ecb2b7b8..d9755fe12 100644 --- a/src/Auth0.ManagementApi/ConnectionProfiles/ConnectionProfilesClient.cs +++ b/src/Auth0.ManagementApi/ConnectionProfiles/ConnectionProfilesClient.cs @@ -72,7 +72,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -86,7 +86,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -99,13 +105,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -115,7 +161,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -126,6 +178,9 @@ private async Task> Crea CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -139,6 +194,7 @@ private async Task> Crea Method = HttpMethod.Post, Path = "connection-profiles", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -159,7 +215,7 @@ private async Task> Crea return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -173,7 +229,13 @@ private async Task> Crea "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -186,15 +248,65 @@ private async Task> Crea switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -204,7 +316,13 @@ private async Task> Crea throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -216,6 +334,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -228,6 +349,7 @@ private async Task< { Method = HttpMethod.Get, Path = "connection-profiles/templates", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -248,7 +370,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -262,7 +384,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -275,11 +403,41 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -289,7 +447,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -302,6 +466,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -317,6 +484,7 @@ private async Task< "connection-profiles/templates/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -337,7 +505,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -351,7 +519,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -364,13 +538,53 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -380,7 +594,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -391,6 +611,9 @@ private async Task> GetAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -406,6 +629,7 @@ private async Task> GetAsyn "connection-profiles/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -425,7 +649,7 @@ private async Task> GetAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -439,7 +663,13 @@ private async Task> GetAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -452,13 +682,157 @@ private async Task> GetAsyn switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "connection-profiles/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -468,7 +842,13 @@ private async Task> GetAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -480,6 +860,9 @@ private async Task> Upda CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -496,6 +879,7 @@ private async Task> Upda ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -516,7 +900,7 @@ private async Task> Upda return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -530,7 +914,13 @@ private async Task> Upda "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -543,15 +933,65 @@ private async Task> Upda switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -561,7 +1001,13 @@ private async Task> Upda throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -683,63 +1129,13 @@ public WithRawResponseTask GetAsync( /// /// await client.ConnectionProfiles.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "connection-profiles/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/ConnectionProfiles/IConnectionProfilesClient.cs b/src/Auth0.ManagementApi/ConnectionProfiles/IConnectionProfilesClient.cs index 3d709df7d..a6e369676 100644 --- a/src/Auth0.ManagementApi/ConnectionProfiles/IConnectionProfilesClient.cs +++ b/src/Auth0.ManagementApi/ConnectionProfiles/IConnectionProfilesClient.cs @@ -51,7 +51,7 @@ WithRawResponseTask GetAsync( /// /// Delete a single Connection Profile specified by ID. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Connections/Clients/ClientsClient.cs b/src/Auth0.ManagementApi/Connections/Clients/ClientsClient.cs index 8b6cb9325..efa977922 100644 --- a/src/Auth0.ManagementApi/Connections/Clients/ClientsClient.cs +++ b/src/Auth0.ManagementApi/Connections/Clients/ClientsClient.cs @@ -80,7 +80,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -94,7 +94,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -107,15 +113,195 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task UpdateAsyncCore( + string id, + IEnumerable request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethodExtensions.Patch, + Path = string.Format( + "connections/{0}/clients", + ValueConvert.ToPathParameterString(id) + ), + Body = request, + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -125,7 +311,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -190,68 +382,13 @@ await GetInternalAsync(id, request, options, cancellationToken) /// } /// ); /// - public async Task UpdateAsync( + public WithRawResponseTask UpdateAsync( string id, IEnumerable request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethodExtensions.Patch, - Path = string.Format( - "connections/{0}/clients", - ValueConvert.ToPathParameterString(id) - ), - Body = request, - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(UpdateAsyncCore(id, request, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/Connections/Clients/IClientsClient.cs b/src/Auth0.ManagementApi/Connections/Clients/IClientsClient.cs index 08ffcb5c2..bf7236f98 100644 --- a/src/Auth0.ManagementApi/Connections/Clients/IClientsClient.cs +++ b/src/Auth0.ManagementApi/Connections/Clients/IClientsClient.cs @@ -17,7 +17,7 @@ Task> GetAsync( CancellationToken cancellationToken = default ); - Task UpdateAsync( + WithRawResponseTask UpdateAsync( string id, IEnumerable request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Connections/ConnectionsClient.cs b/src/Auth0.ManagementApi/Connections/ConnectionsClient.cs index b699af58f..8cbab0582 100644 --- a/src/Auth0.ManagementApi/Connections/ConnectionsClient.cs +++ b/src/Auth0.ManagementApi/Connections/ConnectionsClient.cs @@ -111,7 +111,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -125,7 +125,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -138,13 +144,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -154,7 +200,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -165,6 +217,9 @@ private async Task> CreateAsync CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -178,6 +233,7 @@ private async Task> CreateAsync Method = HttpMethod.Post, Path = "connections", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -198,7 +254,7 @@ private async Task> CreateAsync return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -212,7 +268,13 @@ private async Task> CreateAsync "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -225,15 +287,65 @@ private async Task> CreateAsync switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -243,7 +355,13 @@ private async Task> CreateAsync throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -295,7 +413,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -309,7 +427,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -322,15 +446,178 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format("connections/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -340,7 +627,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -352,6 +645,9 @@ private async Task> UpdateAsync CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -365,6 +661,7 @@ private async Task> UpdateAsync Method = HttpMethodExtensions.Patch, Path = string.Format("connections/{0}", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -385,7 +682,7 @@ private async Task> UpdateAsync return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -399,7 +696,13 @@ private async Task> UpdateAsync "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -412,17 +715,205 @@ private async Task> UpdateAsync switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task CheckStatusAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Get, + Path = string.Format( + "connections/{0}/status", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -432,7 +923,13 @@ private async Task> UpdateAsync throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -557,62 +1054,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Connections.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format("connections/{0}", ValueConvert.ToPathParameterString(id)), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// @@ -641,66 +1089,12 @@ public WithRawResponseTask UpdateAsync( /// /// await client.Connections.CheckStatusAsync("id"); /// - public async Task CheckStatusAsync( + public WithRawResponseTask CheckStatusAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Get, - Path = string.Format( - "connections/{0}/status", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(CheckStatusAsyncCore(id, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/DirectoryProvisioningClient.cs b/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/DirectoryProvisioningClient.cs index a23b9a0b1..a2754af26 100644 --- a/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/DirectoryProvisioningClient.cs +++ b/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/DirectoryProvisioningClient.cs @@ -76,7 +76,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -90,7 +90,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -103,13 +109,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -119,7 +165,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -130,6 +182,9 @@ private async Task> Get CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -145,6 +200,7 @@ private async Task> Get "connections/{0}/directory-provisioning", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -164,7 +220,7 @@ private async Task> Get return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -178,7 +234,13 @@ private async Task> Get "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -191,15 +253,65 @@ private async Task> Get switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -209,7 +321,13 @@ private async Task> Get throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -221,6 +339,9 @@ private async Task> CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -237,6 +358,7 @@ private async Task> ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -257,7 +379,7 @@ private async Task> return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -271,7 +393,13 @@ private async Task> "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -284,17 +412,77 @@ private async Task> switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -304,7 +492,141 @@ private async Task> throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "connections/{0}/directory-provisioning", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -316,6 +638,9 @@ private async Task> CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -332,6 +657,7 @@ private async Task> ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -352,7 +678,7 @@ private async Task> return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -366,7 +692,13 @@ private async Task> "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -379,15 +711,65 @@ private async Task> switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -397,7 +779,13 @@ private async Task> throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -410,6 +798,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -425,6 +816,7 @@ private async Task< "connections/{0}/directory-provisioning/default-mapping", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -445,7 +837,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -459,7 +851,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -472,15 +870,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -490,7 +938,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -559,7 +1013,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -573,7 +1027,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -586,15 +1046,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -604,7 +1114,156 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task SetAsyncCore( + string id, + ReplaceSynchronizedGroupsRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Put, + Path = string.Format( + "connections/{0}/directory-provisioning/synchronized-groups", + ValueConvert.ToPathParameterString(id) + ), + Body = request, + QueryString = _queryString, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 409: + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -695,67 +1354,13 @@ public WithRawResponseTask CreateAsy /// /// await client.Connections.DirectoryProvisioning.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "connections/{0}/directory-provisioning", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// @@ -861,71 +1466,13 @@ await ListSynchronizedGroupsInternalAsync( /// } /// ); /// - public async Task SetAsync( + public WithRawResponseTask SetAsync( string id, ReplaceSynchronizedGroupsRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Put, - Path = string.Format( - "connections/{0}/directory-provisioning/synchronized-groups", - ValueConvert.ToPathParameterString(id) - ), - Body = request, - Headers = _headers, - ContentType = "application/json", - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(SetAsyncCore(id, request, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/IDirectoryProvisioningClient.cs b/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/IDirectoryProvisioningClient.cs index 8f4920c3b..07dda9f64 100644 --- a/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/IDirectoryProvisioningClient.cs +++ b/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/IDirectoryProvisioningClient.cs @@ -39,7 +39,7 @@ WithRawResponseTask CreateAsync( /// /// Delete the directory provisioning configuration of a connection. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -77,7 +77,7 @@ Task> ListSynchronizedGroupsAsync( /// /// Create or replace the selected groups for a connection directory provisioning configuration. /// - Task SetAsync( + WithRawResponseTask SetAsync( string id, ReplaceSynchronizedGroupsRequestContent request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/Synchronizations/SynchronizationsClient.cs b/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/Synchronizations/SynchronizationsClient.cs index 8689ce85d..83426b5d2 100644 --- a/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/Synchronizations/SynchronizationsClient.cs +++ b/src/Auth0.ManagementApi/Connections/DirectoryProvisioning/Synchronizations/SynchronizationsClient.cs @@ -21,6 +21,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -36,6 +39,7 @@ private async Task< "connections/{0}/directory-provisioning/synchronizations", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -56,7 +60,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -70,7 +74,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -83,17 +93,77 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -103,7 +173,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Connections/IConnectionsClient.cs b/src/Auth0.ManagementApi/Connections/IConnectionsClient.cs index e656013a9..1f72bd590 100644 --- a/src/Auth0.ManagementApi/Connections/IConnectionsClient.cs +++ b/src/Auth0.ManagementApi/Connections/IConnectionsClient.cs @@ -62,7 +62,7 @@ WithRawResponseTask GetAsync( /// /// **Note:** If your connection has a large amount of users associated with it, please be aware that this operation can be long running after the response is returned and may impact concurrent [create connection](https://auth0.com/docs/api/management/v2/connections/post-connections) requests, if they use an identical connection name. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -83,7 +83,7 @@ WithRawResponseTask UpdateAsync( /// /// Retrieves the status of an ad/ldap connection referenced by its `ID`. `200 OK` http status code response is returned when the connection is online, otherwise a `404` status code is returned along with an error message /// - Task CheckStatusAsync( + WithRawResponseTask CheckStatusAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Connections/Keys/KeysClient.cs b/src/Auth0.ManagementApi/Connections/Keys/KeysClient.cs index f503bec7c..f34a1726a 100644 --- a/src/Auth0.ManagementApi/Connections/Keys/KeysClient.cs +++ b/src/Auth0.ManagementApi/Connections/Keys/KeysClient.cs @@ -19,6 +19,9 @@ private async Task>> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -34,6 +37,7 @@ private async Task>> GetAsyncCore( "connections/{0}/keys", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -51,7 +55,7 @@ private async Task>> GetAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -65,7 +69,13 @@ private async Task>> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -78,15 +88,65 @@ private async Task>> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -96,7 +156,13 @@ private async Task>> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -110,6 +176,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -126,6 +195,7 @@ private async Task< ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -145,7 +215,7 @@ private async Task< return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -159,7 +229,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -172,17 +248,77 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -192,7 +328,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -204,6 +346,9 @@ private async Task> Rotate CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -220,6 +365,7 @@ private async Task> Rotate ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -239,7 +385,7 @@ private async Task> Rotate return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -253,7 +399,13 @@ private async Task> Rotate "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -266,15 +418,65 @@ private async Task> Rotate switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -284,7 +486,13 @@ private async Task> Rotate throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Connections/ScimConfiguration/IScimConfigurationClient.cs b/src/Auth0.ManagementApi/Connections/ScimConfiguration/IScimConfigurationClient.cs index 09bac481f..1bf743ff0 100644 --- a/src/Auth0.ManagementApi/Connections/ScimConfiguration/IScimConfigurationClient.cs +++ b/src/Auth0.ManagementApi/Connections/ScimConfiguration/IScimConfigurationClient.cs @@ -39,7 +39,7 @@ WithRawResponseTask CreateAsync( /// /// Deletes a scim configuration by its `connectionId`. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Connections/ScimConfiguration/ScimConfigurationClient.cs b/src/Auth0.ManagementApi/Connections/ScimConfiguration/ScimConfigurationClient.cs index f9a38ad40..6e899f2d7 100644 --- a/src/Auth0.ManagementApi/Connections/ScimConfiguration/ScimConfigurationClient.cs +++ b/src/Auth0.ManagementApi/Connections/ScimConfiguration/ScimConfigurationClient.cs @@ -76,7 +76,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -90,7 +90,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -103,13 +109,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -119,7 +165,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -130,6 +182,9 @@ private async Task> GetAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -145,6 +200,7 @@ private async Task> GetAsyn "connections/{0}/scim-configuration", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -164,7 +220,7 @@ private async Task> GetAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -178,7 +234,13 @@ private async Task> GetAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -191,9 +253,29 @@ private async Task> GetAsyn switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -203,7 +285,13 @@ private async Task> GetAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -215,6 +303,9 @@ private async Task> Crea CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -231,6 +322,7 @@ private async Task> Crea ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -250,7 +342,7 @@ private async Task> Crea return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -264,7 +356,13 @@ private async Task> Crea "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -277,9 +375,29 @@ private async Task> Crea switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -289,7 +407,105 @@ private async Task> Crea throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "connections/{0}/scim-configuration", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -301,6 +517,9 @@ private async Task> Upda CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -317,6 +536,7 @@ private async Task> Upda ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -337,7 +557,7 @@ private async Task> Upda return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -351,7 +571,13 @@ private async Task> Upda "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -364,9 +590,29 @@ private async Task> Upda switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -376,7 +622,13 @@ private async Task> Upda throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -389,6 +641,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -404,6 +659,7 @@ private async Task< "connections/{0}/scim-configuration/default-mapping", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -424,7 +680,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -438,7 +694,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -451,9 +713,29 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -463,7 +745,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -554,61 +842,13 @@ public WithRawResponseTask CreateAsync( /// /// await client.Connections.ScimConfiguration.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "connections/{0}/scim-configuration", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Connections/ScimConfiguration/Tokens/ITokensClient.cs b/src/Auth0.ManagementApi/Connections/ScimConfiguration/Tokens/ITokensClient.cs index ade775a08..a6c740f22 100644 --- a/src/Auth0.ManagementApi/Connections/ScimConfiguration/Tokens/ITokensClient.cs +++ b/src/Auth0.ManagementApi/Connections/ScimConfiguration/Tokens/ITokensClient.cs @@ -26,7 +26,7 @@ WithRawResponseTask CreateAsync( /// /// Deletes a scim token by its connection `id` and `tokenId`. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, string tokenId, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Connections/ScimConfiguration/Tokens/TokensClient.cs b/src/Auth0.ManagementApi/Connections/ScimConfiguration/Tokens/TokensClient.cs index 47127367b..9932aab00 100644 --- a/src/Auth0.ManagementApi/Connections/ScimConfiguration/Tokens/TokensClient.cs +++ b/src/Auth0.ManagementApi/Connections/ScimConfiguration/Tokens/TokensClient.cs @@ -19,6 +19,9 @@ private async Task>> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -34,6 +37,7 @@ private async Task>> GetAsyncCore( "connections/{0}/scim-configuration/tokens", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -51,7 +55,7 @@ private async Task>> GetAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -65,7 +69,13 @@ private async Task>> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -78,9 +88,29 @@ private async Task>> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -90,7 +120,13 @@ private async Task>> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -102,6 +138,9 @@ private async Task> CreateAsyncC CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -118,6 +157,7 @@ private async Task> CreateAsyncC ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -138,7 +178,7 @@ private async Task> CreateAsyncC return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -152,7 +192,13 @@ private async Task> CreateAsyncC "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -165,11 +211,41 @@ private async Task> CreateAsyncC switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -179,62 +255,27 @@ private async Task> CreateAsyncC throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Retrieves all scim tokens by its connection `id`. - /// - /// - /// await client.Connections.ScimConfiguration.Tokens.GetAsync("id"); - /// - public WithRawResponseTask> GetAsync( - string id, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask>( - GetAsyncCore(id, options, cancellationToken) - ); - } - - /// - /// Create a scim token for a scim client. - /// - /// - /// await client.Connections.ScimConfiguration.Tokens.CreateAsync( - /// "id", - /// new CreateScimTokenRequestContent() - /// ); - /// - public WithRawResponseTask CreateAsync( - string id, - CreateScimTokenRequestContent request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask( - CreateAsyncCore(id, request, options, cancellationToken) - ); - } - - /// - /// Deletes a scim token by its connection `id` and `tokenId`. - /// - /// - /// await client.Connections.ScimConfiguration.Tokens.DeleteAsync("id", "tokenId"); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, string tokenId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -251,6 +292,7 @@ public async Task DeleteAsync( ValueConvert.ToPathParameterString(id), ValueConvert.ToPathParameterString(tokenId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -259,7 +301,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -270,9 +317,29 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -282,8 +349,68 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Retrieves all scim tokens by its connection `id`. + /// + /// + /// await client.Connections.ScimConfiguration.Tokens.GetAsync("id"); + /// + public WithRawResponseTask> GetAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask>( + GetAsyncCore(id, options, cancellationToken) + ); + } + + /// + /// Create a scim token for a scim client. + /// + /// + /// await client.Connections.ScimConfiguration.Tokens.CreateAsync( + /// "id", + /// new CreateScimTokenRequestContent() + /// ); + /// + public WithRawResponseTask CreateAsync( + string id, + CreateScimTokenRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + CreateAsyncCore(id, request, options, cancellationToken) + ); + } + + /// + /// Deletes a scim token by its connection `id` and `tokenId`. + /// + /// + /// await client.Connections.ScimConfiguration.Tokens.DeleteAsync("id", "tokenId"); + /// + public WithRawResponseTask DeleteAsync( + string id, + string tokenId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, tokenId, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Connections/Users/IUsersClient.cs b/src/Auth0.ManagementApi/Connections/Users/IUsersClient.cs index 17bec04b5..c5fa7ea09 100644 --- a/src/Auth0.ManagementApi/Connections/Users/IUsersClient.cs +++ b/src/Auth0.ManagementApi/Connections/Users/IUsersClient.cs @@ -7,7 +7,7 @@ public partial interface IUsersClient /// /// Deletes a specified connection user by its email (you cannot delete all users from specific connection). Currently, only Database Connections are supported. /// - Task DeleteByEmailAsync( + WithRawResponseTask DeleteByEmailAsync( string id, DeleteConnectionUsersByEmailQueryParameters request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Connections/Users/UsersClient.cs b/src/Auth0.ManagementApi/Connections/Users/UsersClient.cs index 84a8140ae..3e92eff95 100644 --- a/src/Auth0.ManagementApi/Connections/Users/UsersClient.cs +++ b/src/Auth0.ManagementApi/Connections/Users/UsersClient.cs @@ -13,16 +13,7 @@ internal UsersClient(RawClient client) _client = client; } - /// - /// Deletes a specified connection user by its email (you cannot delete all users from specific connection). Currently, only Database Connections are supported. - /// - /// - /// await client.Connections.Users.DeleteByEmailAsync( - /// "id", - /// new DeleteConnectionUsersByEmailQueryParameters { Email = "email" } - /// ); - /// - public async Task DeleteByEmailAsync( + private async Task DeleteByEmailAsyncCore( string id, DeleteConnectionUsersByEmailQueryParameters request, RequestOptions? options = null, @@ -57,7 +48,12 @@ public async Task DeleteByEmailAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -68,15 +64,65 @@ public async Task DeleteByEmailAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -86,8 +132,35 @@ public async Task DeleteByEmailAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Deletes a specified connection user by its email (you cannot delete all users from specific connection). Currently, only Database Connections are supported. + /// + /// + /// await client.Connections.Users.DeleteByEmailAsync( + /// "id", + /// new DeleteConnectionUsersByEmailQueryParameters { Email = "email" } + /// ); + /// + public WithRawResponseTask DeleteByEmailAsync( + string id, + DeleteConnectionUsersByEmailQueryParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + DeleteByEmailAsyncCore(id, request, options, cancellationToken) + ); + } } diff --git a/src/Auth0.ManagementApi/Core/IRequestOptions.cs b/src/Auth0.ManagementApi/Core/IRequestOptions.cs index 9a9d63039..5a4488e1c 100644 --- a/src/Auth0.ManagementApi/Core/IRequestOptions.cs +++ b/src/Auth0.ManagementApi/Core/IRequestOptions.cs @@ -58,6 +58,30 @@ internal interface IRequestOptions #endif } + /// + /// The max number of reconnection attempts for streaming endpoints. + /// Only applies to SSE streams marked as resumable. + /// + public int? MaxStreamReconnectAttempts { get; +#if NET5_0_OR_GREATER + init; +#else + set; +#endif + } + + /// + /// When true, disables automatic reconnection for streaming endpoints. + /// Only applies to SSE streams marked as resumable. + /// + public bool? DisableStreamReconnection { get; +#if NET5_0_OR_GREATER + init; +#else + set; +#endif + } + /// /// Additional query parameters sent with the request. /// diff --git a/src/Auth0.ManagementApi/Core/JsonConfiguration.cs b/src/Auth0.ManagementApi/Core/JsonConfiguration.cs index 7588e83c1..2ef97a37a 100644 --- a/src/Auth0.ManagementApi/Core/JsonConfiguration.cs +++ b/src/Auth0.ManagementApi/Core/JsonConfiguration.cs @@ -17,7 +17,6 @@ static JsonOptions() var options = new JsonSerializerOptions { Converters = { new DateTimeSerializer(), - new BooleanStringConverter(), #if USE_PORTABLE_DATE_ONLY new DateOnlyConverter(), #endif diff --git a/src/Auth0.ManagementApi/Core/Page.cs b/src/Auth0.ManagementApi/Core/Page.cs index 09f6c8360..80f4e23a3 100644 --- a/src/Auth0.ManagementApi/Core/Page.cs +++ b/src/Auth0.ManagementApi/Core/Page.cs @@ -27,13 +27,15 @@ public Page( IReadOnlyList items, object? response, HttpStatusCode statusCode, - ResponseHeaders? headers + ResponseHeaders? headers, + Uri? url = null ) { Items = items; Response = response; StatusCode = statusCode; Headers = headers; + Url = url; } /// @@ -57,6 +59,11 @@ public Page( /// public ResponseHeaders? Headers { get; } + /// + /// The request URL that produced this page. + /// + public Uri? Url { get; } + /// /// Enumerate the items in this . /// diff --git a/src/Auth0.ManagementApi/Core/Pager.cs b/src/Auth0.ManagementApi/Core/Pager.cs index cee94f7ee..acb18bec0 100644 --- a/src/Auth0.ManagementApi/Core/Pager.cs +++ b/src/Auth0.ManagementApi/Core/Pager.cs @@ -224,7 +224,8 @@ private static (TRequest? nextRequest, bool hasNextPage, Page page) Parse items, response, wrappedResponse.RawResponse.StatusCode, - wrappedResponse.RawResponse.Headers + wrappedResponse.RawResponse.Headers, + wrappedResponse.RawResponse.Url ) : Page.Empty; var offset = getOffset(request); @@ -468,7 +469,8 @@ SetCursor setCursor items, response, wrappedResponse.RawResponse.StatusCode, - wrappedResponse.RawResponse.Headers + wrappedResponse.RawResponse.Headers, + wrappedResponse.RawResponse.Url ) : Page.Empty; var cursor = getNextCursor(response); diff --git a/src/Auth0.ManagementApi/Core/Public/ClientOptions.cs b/src/Auth0.ManagementApi/Core/Public/ClientOptions.cs index 9c2f8f852..ac2cec818 100644 --- a/src/Auth0.ManagementApi/Core/Public/ClientOptions.cs +++ b/src/Auth0.ManagementApi/Core/Public/ClientOptions.cs @@ -64,7 +64,7 @@ public partial class ClientOptions #else set; #endif - } = TimeSpan.FromSeconds(30); + } = TimeSpan.FromMilliseconds(30000); /// /// Clones this and returns a new instance diff --git a/src/Auth0.ManagementApi/Core/Public/ManagementApiException.cs b/src/Auth0.ManagementApi/Core/Public/ManagementApiException.cs index fad4c48e7..eefb9b665 100644 --- a/src/Auth0.ManagementApi/Core/Public/ManagementApiException.cs +++ b/src/Auth0.ManagementApi/Core/Public/ManagementApiException.cs @@ -7,7 +7,8 @@ public class ManagementApiException( string message, int statusCode, object body, - Exception? innerException = null + Exception? innerException = null, + Auth0.ManagementApi.RawResponse? rawResponse = null ) : ManagementException(message, innerException) { /// @@ -20,6 +21,11 @@ public class ManagementApiException( /// public object Body => body; + /// + /// The raw HTTP response (status code, URL, headers) that triggered the exception, if available. + /// + public Auth0.ManagementApi.RawResponse? RawResponse => rawResponse; + public override string ToString() { var sb = new System.Text.StringBuilder(); diff --git a/src/Auth0.ManagementApi/Core/Public/RequestOptions.cs b/src/Auth0.ManagementApi/Core/Public/RequestOptions.cs index 716a44bb3..117a254f8 100644 --- a/src/Auth0.ManagementApi/Core/Public/RequestOptions.cs +++ b/src/Auth0.ManagementApi/Core/Public/RequestOptions.cs @@ -61,6 +61,30 @@ public partial class RequestOptions : IRequestOptions #endif } + /// + /// The max number of reconnection attempts for streaming endpoints. + /// Only applies to SSE streams marked as resumable. + /// + public int? MaxStreamReconnectAttempts { get; +#if NET5_0_OR_GREATER + init; +#else + set; +#endif + } + + /// + /// When true, disables automatic reconnection for streaming endpoints. + /// Only applies to SSE streams marked as resumable. + /// + public bool? DisableStreamReconnection { get; +#if NET5_0_OR_GREATER + init; +#else + set; +#endif + } + /// /// Additional query parameters sent with the request. /// diff --git a/src/Auth0.ManagementApi/Core/Public/WithRawResponseStream.cs b/src/Auth0.ManagementApi/Core/Public/WithRawResponseStream.cs new file mode 100644 index 000000000..b9603271c --- /dev/null +++ b/src/Auth0.ManagementApi/Core/Public/WithRawResponseStream.cs @@ -0,0 +1,66 @@ +using global::System.Collections.Generic; +using global::System.Runtime.CompilerServices; +using global::System.Threading; +using global::System.Threading.Tasks; + +namespace Auth0.ManagementApi; + +/// +/// A streaming wrapper that provides dual-mode access to a streaming endpoint: +/// - Direct await foreach iterates the parsed stream values (zero-allocation path for common case) +/// - .WithRawResponse() yields the underlying exposing both the stream and raw response metadata +/// +/// The element type of the parsed stream. +public readonly struct WithRawResponseStream : IAsyncEnumerable +{ + private readonly Task>> _task; + private readonly CancellationToken _originalCancellationToken; + + /// + /// Creates a new WithRawResponseStream wrapping the given task that opens the underlying HTTP response. + /// + /// The task opening the HTTP response and producing the parsed stream. + /// + /// The cancellation token supplied at the SDK call site. Linked with any token supplied via + /// .WithCancellation(...) on the enumerator so both cancel the inner reads. + /// + public WithRawResponseStream( + Task>> task, + CancellationToken cancellationToken = default + ) + { + _task = task; + _originalCancellationToken = cancellationToken; + } + + /// + /// Returns the underlying task that yields both the stream and raw response metadata once headers are received. + /// + public Task>> WithRawResponse() => _task; + + /// + /// Returns an enumerator that iterates the parsed stream values. Awaits the underlying HTTP response, then yields each parsed element from the body stream. + /// + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) => + EnumerateAsync(_task, _originalCancellationToken, cancellationToken) + .GetAsyncEnumerator(cancellationToken); + + private static async IAsyncEnumerable EnumerateAsync( + Task>> task, + CancellationToken originalCancellationToken, + [EnumeratorCancellation] CancellationToken cancellationToken + ) + { + using var linkedCts = CancellationTokenSource.CreateLinkedTokenSource( + originalCancellationToken, + cancellationToken + ); + var wrapped = await task.ConfigureAwait(false); + await foreach ( + var item in wrapped.Data.WithCancellation(linkedCts.Token).ConfigureAwait(false) + ) + { + yield return item; + } + } +} diff --git a/src/Auth0.ManagementApi/Core/Public/WithRawResponseTask.cs b/src/Auth0.ManagementApi/Core/Public/WithRawResponseTask.cs index 6f445e093..5c0e9ae72 100644 --- a/src/Auth0.ManagementApi/Core/Public/WithRawResponseTask.cs +++ b/src/Auth0.ManagementApi/Core/Public/WithRawResponseTask.cs @@ -142,3 +142,46 @@ public void UnsafeOnCompleted(global::System.Action continuation) => } } } + +/// +/// A task-like type that wraps Task<RawResponse> and provides dual-mode awaiting for endpoints with no response body: +/// - Direct await completes with no value (void semantics) +/// - .WithRawResponse() yields RawResponse (when raw response metadata is needed) +/// +public readonly struct WithRawResponseTask +{ + private readonly global::System.Threading.Tasks.Task _task; + + /// + /// Creates a new WithRawResponseTask wrapping the given task. + /// + public WithRawResponseTask(global::System.Threading.Tasks.Task task) + { + _task = task; + } + + /// + /// Returns the underlying task that yields raw response metadata. + /// + public global::System.Threading.Tasks.Task WithRawResponse() => _task; + + /// + /// Awaiter delegates to the non-generic Task, completing with no value. + /// + public TaskAwaiter GetAwaiter() => ((global::System.Threading.Tasks.Task)_task).GetAwaiter(); + + /// + /// Configures the awaiter to continue on the captured context or not. The configured awaitable completes with no value. + /// + public global::System.Runtime.CompilerServices.ConfiguredTaskAwaitable ConfigureAwait( + bool continueOnCapturedContext + ) => ((global::System.Threading.Tasks.Task)_task).ConfigureAwait(continueOnCapturedContext); + + /// + /// Implicitly converts WithRawResponseTask to global::System.Threading.Tasks.Task for backward compatibility. + /// + public static implicit operator global::System.Threading.Tasks.Task(WithRawResponseTask task) + { + return task._task; + } +} diff --git a/src/Auth0.ManagementApi/Core/RawClient.cs b/src/Auth0.ManagementApi/Core/RawClient.cs index 13c1758e0..a24aefd2a 100644 --- a/src/Auth0.ManagementApi/Core/RawClient.cs +++ b/src/Auth0.ManagementApi/Core/RawClient.cs @@ -57,7 +57,8 @@ internal partial class RawClient(ClientOptions clientOptions) } private static async global::System.Threading.Tasks.Task CloneRequestAsync( - HttpRequestMessage request + HttpRequestMessage request, + CancellationToken cancellationToken = default ) { var clonedRequest = new HttpRequestMessage(request.Method, request.RequestUri); @@ -83,7 +84,11 @@ HttpRequestMessage request foreach (var content in oldMultipartFormContent) { var ms = new MemoryStream(); +#if NET5_0_OR_GREATER + await content.CopyToAsync(ms, cancellationToken).ConfigureAwait(false); +#else await content.CopyToAsync(ms).ConfigureAwait(false); +#endif ms.Position = 0; var newPart = new StreamContent(ms); foreach (var header in content.Headers) @@ -98,7 +103,13 @@ HttpRequestMessage request break; default: var bodyStream = new MemoryStream(); +#if NET5_0_OR_GREATER + await request + .Content.CopyToAsync(bodyStream, cancellationToken) + .ConfigureAwait(false); +#else await request.Content.CopyToAsync(bodyStream).ConfigureAwait(false); +#endif bodyStream.Position = 0; var clonedContent = new StreamContent(bodyStream); foreach (var header in request.Content.Headers) @@ -130,14 +141,14 @@ CancellationToken cancellationToken ) { var httpClient = options?.HttpClient ?? Options.HttpClient; - var maxRetries = options?.MaxRetries ?? Options.MaxRetries; - var response = await httpClient - .SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken) - .ConfigureAwait(false); + var maxRetries = Math.Max(0, options?.MaxRetries ?? Options.MaxRetries); var isRetryableContent = IsRetryableContent(request); - if (!isRetryableContent) + if (!isRetryableContent || maxRetries == 0) { + var response = await httpClient + .SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken) + .ConfigureAwait(false); return new global::Auth0.ManagementApi.Core.ApiResponse { StatusCode = (int)response.StatusCode, @@ -145,29 +156,37 @@ CancellationToken cancellationToken }; } - for (var i = 0; i < maxRetries; i++) + // Always send a clone, never the original: HttpClient (e.g. under HTTP/2) disposes + // request.Content after sending, which would break the next attempt's clone. + HttpResponseMessage? retryResponse = null; + for (var attempt = 0; attempt <= maxRetries; attempt++) { - if (!ShouldRetry(response)) + if (attempt > 0) { - break; + var delayMs = GetRetryDelayFromHeaders(retryResponse!, attempt - 1); + await SystemTask.Delay(delayMs, cancellationToken).ConfigureAwait(false); } - var delayMs = GetRetryDelayFromHeaders(response, i); - await SystemTask.Delay(delayMs, cancellationToken).ConfigureAwait(false); - using var retryRequest = await CloneRequestAsync(request).ConfigureAwait(false); - response = await httpClient + using var attemptRequest = await CloneRequestAsync(request, cancellationToken) + .ConfigureAwait(false); + retryResponse = await httpClient .SendAsync( - retryRequest, + attemptRequest, HttpCompletionOption.ResponseHeadersRead, cancellationToken ) .ConfigureAwait(false); + + if (!ShouldRetry(retryResponse)) + { + break; + } } return new global::Auth0.ManagementApi.Core.ApiResponse { - StatusCode = (int)response.StatusCode, - Raw = response, + StatusCode = (int)retryResponse!.StatusCode, + Raw = retryResponse, }; } diff --git a/src/Auth0.ManagementApi/Core/SseReconnectHelper.cs b/src/Auth0.ManagementApi/Core/SseReconnectHelper.cs new file mode 100644 index 000000000..ceb395cba --- /dev/null +++ b/src/Auth0.ManagementApi/Core/SseReconnectHelper.cs @@ -0,0 +1,210 @@ +using global::System.IO; +using global::System.Net.ServerSentEvents; +using global::System.Runtime.CompilerServices; + +namespace Auth0.ManagementApi.Core; + +/// +/// Provides SSE stream enumeration with transparent mid-stream reconnection. +/// When a stream ends before the configured terminator and a last event ID is +/// available, this helper reconnects using the Last-Event-ID header. +/// +internal static class SseReconnectHelper +{ + private const int DefaultMaxReconnectAttempts = 5; + private static readonly TimeSpan DefaultReconnectDelay = TimeSpan.FromSeconds(1); + private static readonly TimeSpan MaxReconnectDelay = TimeSpan.FromSeconds(30); + + /// + /// Enumerates SSE items from the given response, automatically reconnecting + /// on premature stream termination when reconnection is enabled. + /// + /// The initial API response to start reading from. + /// + /// A delegate that issues a new HTTP request with the Last-Event-ID + /// header and returns a fresh . + /// + /// + /// The maximum number of consecutive reconnection attempts before giving up. + /// Defaults to 5 when null. The counter resets to zero each + /// time a reconnected stream successfully yields at least one event. + /// + /// + /// When true, reconnection is disabled and the stream ends on premature EOF. + /// + /// + /// The SSE data value that signals the end of the stream. When null, + /// reconnection is disabled because the client cannot distinguish a completed + /// stream from a dropped connection. + /// + /// A token to cancel the enumeration. + /// An async enumerable of items. + internal static async IAsyncEnumerable> EnumerateWithReconnectAsync( + global::Auth0.ManagementApi.Core.ApiResponse initialResponse, + Func< + string, + CancellationToken, + global::System.Threading.Tasks.Task + > reconnectFn, + int? maxReconnectAttempts, + bool disableReconnection, + string? terminator, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + var response = initialResponse; + var maxAttempts = maxReconnectAttempts ?? DefaultMaxReconnectAttempts; + var reconnectAttempts = 0; + var isReconnectedResponse = false; + // Track the last event ID from the most recently *dispatched* (yielded) + // event, not the last parsed id. Per the WHATWG EventSource spec the + // "last event ID" is only committed when an event is dispatched — if a + // connection drops after an id: line but before the event's terminating + // blank line, reconnecting with the parsed-but-undispatched id would + // skip an event that was never delivered to the caller. + string? lastDispatchedEventId = null; + Exception? lastReconnectException = null; + + while (true) + { + var stream = await response + .Raw.Content.ReadAsStreamAsync( +#if NET5_0_OR_GREATER + cancellationToken +#endif + ) + .ConfigureAwait(false); + var parser = SseParser.Create(stream); + var terminatorReached = false; + var streamDropped = false; + + var enumerator = parser + .EnumerateAsync(cancellationToken) + .GetAsyncEnumerator(cancellationToken); + try + { + while (true) + { + bool hasNext; + try + { + hasNext = await enumerator.MoveNextAsync().ConfigureAwait(false); + } + catch (IOException) + { + streamDropped = true; + break; + } + + if (!hasNext) + { + break; + } + + var item = enumerator.Current; + + if ( + terminator != null + && !string.IsNullOrEmpty(item.Data) + && item.Data == terminator + ) + { + terminatorReached = true; + break; + } + + yield return item; + // Capture parser.LastEventId immediately after a successful + // dispatch — at this point it reflects the just-dispatched + // event's id. We must snapshot it before the next + // MoveNextAsync could partially update it with a new id: + // line from an incomplete event. + if (!string.IsNullOrEmpty(parser.LastEventId)) + { + lastDispatchedEventId = parser.LastEventId; + } + reconnectAttempts = 0; + } + } + finally + { + await enumerator.DisposeAsync().ConfigureAwait(false); + } + + if (terminatorReached) + { + yield break; + } + + // Determine whether reconnection should be attempted. + // Without a terminator the client cannot distinguish "stream + // completed" from "connection dropped", so reconnection is disabled. + if ( + disableReconnection + || terminator == null + || string.IsNullOrEmpty(lastDispatchedEventId) + || reconnectAttempts >= maxAttempts + ) + { + if (streamDropped || lastReconnectException != null) + { + throw new IOException( + "SSE stream connection lost and reconnection " + + ( + lastReconnectException != null + ? "failed after exhausting all attempts." + : "was not attempted." + ), + lastReconnectException + ); + } + yield break; + } + + reconnectAttempts++; + + // Use the server-sent retry interval if available; otherwise fall + // back to DefaultReconnectDelay (1s) to avoid hammering the server. + var delay = + parser.ReconnectionInterval > TimeSpan.Zero + ? parser.ReconnectionInterval + : DefaultReconnectDelay; + if (delay > MaxReconnectDelay) + { + delay = MaxReconnectDelay; + } + await global::System + .Threading.Tasks.Task.Delay(delay, cancellationToken) + .ConfigureAwait(false); + + ApiResponse newResponse; + try + { + newResponse = await reconnectFn(lastDispatchedEventId!, cancellationToken) + .ConfigureAwait(false); + } + catch (Exception ex) when (!cancellationToken.IsCancellationRequested) + { + // Failed reconnect (e.g. HTTP error or null body). Treat as a + // failed attempt — the next loop iteration will check the cap. + // Do NOT dispose the previous response here: we need it to stay + // valid in case the retry loop re-enters the stream-read path. + lastReconnectException = ex; + continue; + } + + // Successful reconnect — clear any stale failure so it doesn't + // cause a misleading IOException if a later cap-exhaustion occurs + // via empty-body reconnects (which don't set lastReconnectException). + lastReconnectException = null; + + // Only dispose the old response after a new one is successfully obtained. + if (isReconnectedResponse) + { + response.Raw?.Dispose(); + } + response = newResponse; + isReconnectedResponse = true; + } + } +} diff --git a/src/Auth0.ManagementApi/CustomDomains/CustomDomainsClient.cs b/src/Auth0.ManagementApi/CustomDomains/CustomDomainsClient.cs index 414befe7e..4ebfca096 100644 --- a/src/Auth0.ManagementApi/CustomDomains/CustomDomainsClient.cs +++ b/src/Auth0.ManagementApi/CustomDomains/CustomDomainsClient.cs @@ -58,7 +58,7 @@ private async Task>> ListAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -72,7 +72,13 @@ private async Task>> ListAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -85,11 +91,41 @@ private async Task>> ListAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -99,7 +135,13 @@ private async Task>> ListAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -110,6 +152,9 @@ private async Task> CreateAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -123,6 +168,7 @@ private async Task> CreateAsy Method = HttpMethod.Post, Path = "custom-domains", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -143,7 +189,7 @@ private async Task> CreateAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -157,7 +203,13 @@ private async Task> CreateAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -170,15 +222,65 @@ private async Task> CreateAsy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -188,7 +290,13 @@ private async Task> CreateAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -198,6 +306,9 @@ private async Task> GetDefaultA CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -210,6 +321,7 @@ private async Task> GetDefaultA { Method = HttpMethod.Get, Path = "custom-domains/default", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -229,7 +341,7 @@ private async Task> GetDefaultA return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -243,7 +355,13 @@ private async Task> GetDefaultA "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -256,11 +374,41 @@ private async Task> GetDefaultA switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -270,7 +418,13 @@ private async Task> GetDefaultA throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -281,6 +435,9 @@ private async Task> SetDefau CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -294,6 +451,7 @@ private async Task> SetDefau Method = HttpMethodExtensions.Patch, Path = "custom-domains/default", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -314,7 +472,7 @@ private async Task> SetDefau return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -328,7 +486,13 @@ private async Task> SetDefau "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -341,9 +505,29 @@ private async Task> SetDefau switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -353,7 +537,13 @@ private async Task> SetDefau throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -364,6 +554,9 @@ private async Task> GetAsyncCore CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -379,6 +572,7 @@ private async Task> GetAsyncCore "custom-domains/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -398,7 +592,7 @@ private async Task> GetAsyncCore return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -412,7 +606,13 @@ private async Task> GetAsyncCore "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -425,15 +625,193 @@ private async Task> GetAsyncCore switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "custom-domains/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 409: + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -443,7 +821,13 @@ private async Task> GetAsyncCore throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -455,6 +839,9 @@ private async Task> UpdateAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -471,6 +858,7 @@ private async Task> UpdateAsy ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -491,7 +879,7 @@ private async Task> UpdateAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -505,7 +893,13 @@ private async Task> UpdateAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -518,13 +912,53 @@ private async Task> UpdateAsy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -534,7 +968,13 @@ private async Task> UpdateAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -545,6 +985,9 @@ private async Task> TestAsyncCo CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -560,6 +1003,7 @@ private async Task> TestAsyncCo "custom-domains/{0}/test", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -579,7 +1023,7 @@ private async Task> TestAsyncCo return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -593,7 +1037,13 @@ private async Task> TestAsyncCo "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -606,15 +1056,65 @@ private async Task> TestAsyncCo switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -624,7 +1124,13 @@ private async Task> TestAsyncCo throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -635,6 +1141,9 @@ private async Task> VerifyAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -650,6 +1159,7 @@ private async Task> VerifyAsy "custom-domains/{0}/verify", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -669,7 +1179,7 @@ private async Task> VerifyAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -683,7 +1193,13 @@ private async Task> VerifyAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -696,15 +1212,65 @@ private async Task> VerifyAsy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -714,7 +1280,13 @@ private async Task> VerifyAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -837,67 +1409,13 @@ public WithRawResponseTask GetAsync( /// /// await client.CustomDomains.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "custom-domains/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/CustomDomains/ICustomDomainsClient.cs b/src/Auth0.ManagementApi/CustomDomains/ICustomDomainsClient.cs index 4e38ef4ac..15d0bf43d 100644 --- a/src/Auth0.ManagementApi/CustomDomains/ICustomDomainsClient.cs +++ b/src/Auth0.ManagementApi/CustomDomains/ICustomDomainsClient.cs @@ -61,7 +61,7 @@ WithRawResponseTask GetAsync( /// /// Delete a custom domain and stop serving requests for it. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/DeviceCredentials/DeviceCredentialsClient.cs b/src/Auth0.ManagementApi/DeviceCredentials/DeviceCredentialsClient.cs index 75dacd5a0..4a5c516ce 100644 --- a/src/Auth0.ManagementApi/DeviceCredentials/DeviceCredentialsClient.cs +++ b/src/Auth0.ManagementApi/DeviceCredentials/DeviceCredentialsClient.cs @@ -84,7 +84,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -98,7 +98,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -111,13 +117,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -127,7 +173,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -140,6 +192,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -153,6 +208,7 @@ private async Task< Method = HttpMethod.Post, Path = "device-credentials", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -174,7 +230,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -188,7 +244,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -201,15 +263,181 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "device-credentials/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -219,7 +447,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -309,64 +543,12 @@ public WithRawResponseTask Creat /// /// await client.DeviceCredentials.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "device-credentials/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/DeviceCredentials/IDeviceCredentialsClient.cs b/src/Auth0.ManagementApi/DeviceCredentials/IDeviceCredentialsClient.cs index 2eab6be27..a2f9299b3 100644 --- a/src/Auth0.ManagementApi/DeviceCredentials/IDeviceCredentialsClient.cs +++ b/src/Auth0.ManagementApi/DeviceCredentials/IDeviceCredentialsClient.cs @@ -27,7 +27,7 @@ WithRawResponseTask CreatePublic /// /// Permanently delete a device credential (such as a refresh token or public key) with the given ID. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/EmailTemplates/EmailTemplatesClient.cs b/src/Auth0.ManagementApi/EmailTemplates/EmailTemplatesClient.cs index 93c22625e..6de8663b1 100644 --- a/src/Auth0.ManagementApi/EmailTemplates/EmailTemplatesClient.cs +++ b/src/Auth0.ManagementApi/EmailTemplates/EmailTemplatesClient.cs @@ -18,6 +18,9 @@ private async Task> CreateAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -31,6 +34,7 @@ private async Task> CreateAs Method = HttpMethod.Post, Path = "email-templates", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -51,7 +55,7 @@ private async Task> CreateAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -65,7 +69,13 @@ private async Task> CreateAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -78,15 +88,65 @@ private async Task> CreateAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -96,7 +156,13 @@ private async Task> CreateAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -107,6 +173,9 @@ private async Task> GetAsyncCor CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -122,6 +191,7 @@ private async Task> GetAsyncCor "email-templates/{0}", ValueConvert.ToPathParameterString(templateName) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -141,7 +211,7 @@ private async Task> GetAsyncCor return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -155,7 +225,13 @@ private async Task> GetAsyncCor "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -168,13 +244,53 @@ private async Task> GetAsyncCor switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -184,7 +300,13 @@ private async Task> GetAsyncCor throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -196,6 +318,9 @@ private async Task> SetAsyncCor CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -212,6 +337,7 @@ private async Task> SetAsyncCor ValueConvert.ToPathParameterString(templateName) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -232,7 +358,7 @@ private async Task> SetAsyncCor return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -246,7 +372,13 @@ private async Task> SetAsyncCor "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -259,15 +391,65 @@ private async Task> SetAsyncCor switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -277,7 +459,13 @@ private async Task> SetAsyncCor throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -289,6 +477,9 @@ private async Task> UpdateAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -305,6 +496,7 @@ private async Task> UpdateAs ValueConvert.ToPathParameterString(templateName) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -325,7 +517,7 @@ private async Task> UpdateAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -339,7 +531,13 @@ private async Task> UpdateAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -352,15 +550,65 @@ private async Task> UpdateAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -370,7 +618,13 @@ private async Task> UpdateAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Emails/Provider/IProviderClient.cs b/src/Auth0.ManagementApi/Emails/Provider/IProviderClient.cs index 4d2fef675..f0de91ac3 100644 --- a/src/Auth0.ManagementApi/Emails/Provider/IProviderClient.cs +++ b/src/Auth0.ManagementApi/Emails/Provider/IProviderClient.cs @@ -49,7 +49,10 @@ WithRawResponseTask CreateAsync( /// /// Delete the email provider. /// - Task DeleteAsync(RequestOptions? options = null, CancellationToken cancellationToken = default); + WithRawResponseTask DeleteAsync( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); /// /// Update an [email provider](https://auth0.com/docs/email/providers). The `credentials` object diff --git a/src/Auth0.ManagementApi/Emails/Provider/ProviderClient.cs b/src/Auth0.ManagementApi/Emails/Provider/ProviderClient.cs index 884b96791..65ded9d9e 100644 --- a/src/Auth0.ManagementApi/Emails/Provider/ProviderClient.cs +++ b/src/Auth0.ManagementApi/Emails/Provider/ProviderClient.cs @@ -59,7 +59,7 @@ private async Task> GetAsyncCor return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -73,7 +73,13 @@ private async Task> GetAsyncCor "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -86,15 +92,65 @@ private async Task> GetAsyncCor switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -104,7 +160,13 @@ private async Task> GetAsyncCor throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -115,6 +177,9 @@ private async Task> CreateAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -128,6 +193,7 @@ private async Task> CreateAs Method = HttpMethod.Post, Path = "emails/provider", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -148,7 +214,7 @@ private async Task> CreateAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -162,7 +228,13 @@ private async Task> CreateAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -175,15 +247,189 @@ private async Task> CreateAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = "emails/provider", + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -193,7 +439,13 @@ private async Task> CreateAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -204,6 +456,9 @@ private async Task> UpdateAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -217,6 +472,7 @@ private async Task> UpdateAs Method = HttpMethodExtensions.Patch, Path = "emails/provider", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -237,7 +493,7 @@ private async Task> UpdateAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -251,7 +507,13 @@ private async Task> UpdateAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -264,17 +526,77 @@ private async Task> UpdateAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -284,7 +606,13 @@ private async Task> UpdateAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -361,63 +689,12 @@ public WithRawResponseTask CreateAsync( /// /// await client.Emails.Provider.DeleteAsync(); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = "emails/provider", - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/EventStreams/Deliveries/DeliveriesClient.cs b/src/Auth0.ManagementApi/EventStreams/Deliveries/DeliveriesClient.cs index ab0083964..b8693bed6 100644 --- a/src/Auth0.ManagementApi/EventStreams/Deliveries/DeliveriesClient.cs +++ b/src/Auth0.ManagementApi/EventStreams/Deliveries/DeliveriesClient.cs @@ -64,7 +64,7 @@ private async Task>> ListAsyncC return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -78,7 +78,13 @@ private async Task>> ListAsyncC "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -91,15 +97,65 @@ private async Task>> ListAsyncC switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -109,7 +165,13 @@ private async Task>> ListAsyncC throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -123,6 +185,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -139,6 +204,7 @@ private async Task< ValueConvert.ToPathParameterString(id), ValueConvert.ToPathParameterString(eventId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -159,7 +225,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -173,7 +239,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -186,13 +258,53 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -202,7 +314,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/EventStreams/EventStreamsClient.cs b/src/Auth0.ManagementApi/EventStreams/EventStreamsClient.cs index 4a4589ea3..0b238ded7 100644 --- a/src/Auth0.ManagementApi/EventStreams/EventStreamsClient.cs +++ b/src/Auth0.ManagementApi/EventStreams/EventStreamsClient.cs @@ -73,7 +73,7 @@ private async Task> ListInterna return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -87,7 +87,13 @@ private async Task> ListInterna "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -100,13 +106,53 @@ private async Task> ListInterna switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -116,7 +162,13 @@ private async Task> ListInterna throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -127,6 +179,9 @@ private async Task> CreateAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -140,6 +195,7 @@ private async Task> CreateAsyn Method = HttpMethod.Post, Path = "event-streams", Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -159,7 +215,7 @@ private async Task> CreateAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -173,7 +229,13 @@ private async Task> CreateAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -186,15 +248,65 @@ private async Task> CreateAsyn switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -204,7 +316,13 @@ private async Task> CreateAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -215,6 +333,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -230,6 +351,7 @@ private async Task> GetAsyncCore( "event-streams/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -249,7 +371,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -263,7 +385,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -276,13 +404,53 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -292,7 +460,129 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "event-streams/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -304,6 +594,9 @@ private async Task> UpdateAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -320,6 +613,7 @@ private async Task> UpdateAsyn ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -340,7 +634,7 @@ private async Task> UpdateAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -354,7 +648,13 @@ private async Task> UpdateAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -367,13 +667,53 @@ private async Task> UpdateAsyn switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -383,7 +723,13 @@ private async Task> UpdateAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -395,6 +741,9 @@ private async Task> T CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -411,6 +760,7 @@ private async Task> T ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -431,7 +781,7 @@ private async Task> T return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -445,7 +795,13 @@ private async Task> T "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -458,11 +814,41 @@ private async Task> T switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -472,7 +858,13 @@ private async Task> T throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -564,65 +956,13 @@ public WithRawResponseTask GetAsync( /// /// await client.EventStreams.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "event-streams/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// @@ -645,7 +985,7 @@ public WithRawResponseTask UpdateAsync( /// "id", /// new CreateEventStreamTestEventRequestContent /// { - /// EventType = EventStreamTestEventTypeEnum.GroupCreated, + /// EventType = EventStreamTestEventTypeEnum.ConnectionCreated, /// } /// ); /// diff --git a/src/Auth0.ManagementApi/EventStreams/IEventStreamsClient.cs b/src/Auth0.ManagementApi/EventStreams/IEventStreamsClient.cs index 20d9ce309..8fae69e67 100644 --- a/src/Auth0.ManagementApi/EventStreams/IEventStreamsClient.cs +++ b/src/Auth0.ManagementApi/EventStreams/IEventStreamsClient.cs @@ -25,7 +25,7 @@ WithRawResponseTask GetAsync( CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/EventStreams/Redeliveries/IRedeliveriesClient.cs b/src/Auth0.ManagementApi/EventStreams/Redeliveries/IRedeliveriesClient.cs index ab60bbb1f..b8f7ff487 100644 --- a/src/Auth0.ManagementApi/EventStreams/Redeliveries/IRedeliveriesClient.cs +++ b/src/Auth0.ManagementApi/EventStreams/Redeliveries/IRedeliveriesClient.cs @@ -11,7 +11,7 @@ WithRawResponseTask CreateAsync( CancellationToken cancellationToken = default ); - Task CreateByIdAsync( + WithRawResponseTask CreateByIdAsync( string id, string eventId, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/EventStreams/Redeliveries/RedeliveriesClient.cs b/src/Auth0.ManagementApi/EventStreams/Redeliveries/RedeliveriesClient.cs index 90ae00384..ceee0be64 100644 --- a/src/Auth0.ManagementApi/EventStreams/Redeliveries/RedeliveriesClient.cs +++ b/src/Auth0.ManagementApi/EventStreams/Redeliveries/RedeliveriesClient.cs @@ -20,6 +20,9 @@ private async Task> CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -36,6 +39,7 @@ private async Task> ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -57,7 +61,7 @@ private async Task> return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -71,7 +75,13 @@ private async Task> "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -84,15 +94,65 @@ private async Task> switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -102,39 +162,27 @@ private async Task> throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// await client.EventStreams.Redeliveries.CreateAsync( - /// "id", - /// new CreateEventStreamRedeliveryRequestContent() - /// ); - /// - public WithRawResponseTask CreateAsync( - string id, - CreateEventStreamRedeliveryRequestContent request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask( - CreateAsyncCore(id, request, options, cancellationToken) - ); - } - - /// - /// await client.EventStreams.Redeliveries.CreateByIdAsync("id", "event_id"); - /// - public async Task CreateByIdAsync( + private async Task CreateByIdAsyncCore( string id, string eventId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -151,6 +199,7 @@ public async Task CreateByIdAsync( ValueConvert.ToPathParameterString(id), ValueConvert.ToPathParameterString(eventId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -159,7 +208,12 @@ public async Task CreateByIdAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -170,15 +224,65 @@ public async Task CreateByIdAsync( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -188,8 +292,47 @@ public async Task CreateByIdAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// await client.EventStreams.Redeliveries.CreateAsync( + /// "id", + /// new CreateEventStreamRedeliveryRequestContent() + /// ); + /// + public WithRawResponseTask CreateAsync( + string id, + CreateEventStreamRedeliveryRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + CreateAsyncCore(id, request, options, cancellationToken) + ); + } + + /// + /// await client.EventStreams.Redeliveries.CreateByIdAsync("id", "event_id"); + /// + public WithRawResponseTask CreateByIdAsync( + string id, + string eventId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + CreateByIdAsyncCore(id, eventId, options, cancellationToken) + ); + } } diff --git a/src/Auth0.ManagementApi/Events/EventsClient.cs b/src/Auth0.ManagementApi/Events/EventsClient.cs index 2911f2bd5..d172f4799 100644 --- a/src/Auth0.ManagementApi/Events/EventsClient.cs +++ b/src/Auth0.ManagementApi/Events/EventsClient.cs @@ -1,5 +1,5 @@ using Auth0.ManagementApi.Core; -using global::System.Net.ServerSentEvents; +using global::System.Runtime.CompilerServices; using global::System.Text.Json; namespace Auth0.ManagementApi; @@ -13,23 +13,9 @@ internal EventsClient(RawClient client) _client = client; } - /// - /// Subscribe to events via Server-Sent Events (SSE) - /// - /// - /// client.Events.SubscribeAsync( - /// new SubscribeEventsRequestParameters - /// { - /// From = "from", - /// FromTimestamp = "from_timestamp", - /// EventType = new List<EventStreamSubscribeEventsEventTypeEnum?>() - /// { - /// EventStreamSubscribeEventsEventTypeEnum.GroupCreated, - /// }, - /// } - /// ); - /// - public async IAsyncEnumerable SubscribeAsync( + private async Task< + WithRawResponse> + > SubscribeAsyncCore( SubscribeEventsRequestParameters request, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -50,46 +36,46 @@ public async IAsyncEnumerable Subscri .Add(options?.AdditionalHeaders) .BuildAsync() .ConfigureAwait(false); + var request_ = new JsonRequest + { + Method = HttpMethod.Get, + Path = "events", + QueryString = _queryString, + Headers = _headers, + Options = options, + }; var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Get, - Path = "events", - QueryString = _queryString, - Headers = _headers, - Options = options, - }, - cancellationToken - ) + .SendRequestAsync(request_, cancellationToken) .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - await foreach ( - var item in SseParser - .Create(await response.Raw.Content.ReadAsStreamAsync()) - .EnumerateAsync(cancellationToken) + async global::System.Threading.Tasks.Task ReconnectAsync( + string lastEventId, + CancellationToken ct ) { - if (!string.IsNullOrEmpty(item.Data)) - { - EventStreamSubscribeEventsResponseContent? result; - try - { - result = JsonUtils.Deserialize( - item.Data - ); - } - catch (JsonException e) - { - throw new ManagementException( - "Failed to deserialize streaming response", - e - ); - } - } + var reconnectHeaders = new Dictionary( + request_.Headers, + StringComparer.OrdinalIgnoreCase + ); + reconnectHeaders["Last-Event-ID"] = lastEventId; + return await _client + .SendRequestAsync(request_ with { Headers = reconnectHeaders }, ct) + .ConfigureAwait(false); } - yield break; + + return new WithRawResponse< + IAsyncEnumerable + >() + { + Data = SubscribeAsyncBody(response, ReconnectAsync, options, cancellationToken), + RawResponse = new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; } { var responseBody = await response @@ -100,17 +86,77 @@ var item in SseParser switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 410: - throw new GoneError(JsonUtils.Deserialize(responseBody)); + throw new GoneError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -120,8 +166,80 @@ var item in SseParser throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + private async IAsyncEnumerable SubscribeAsyncBody( + ApiResponse response, + Func> reconnectFn, + RequestOptions? options, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + await foreach ( + var item in SseReconnectHelper + .EnumerateWithReconnectAsync( + response, + reconnectFn, + options?.MaxStreamReconnectAttempts, + options?.DisableStreamReconnection ?? false, + null, + cancellationToken + ) + .ConfigureAwait(false) + ) + { + if (!string.IsNullOrEmpty(item.Data)) + { + EventStreamSubscribeEventsResponseContent? result; + try + { + result = JsonUtils.Deserialize( + item.Data + ); + } + catch (JsonException e) + { + throw new ManagementException("Failed to deserialize streaming response", e); + } + yield return result!; + } + } + } + + /// + /// Subscribe to events via Server-Sent Events (SSE) + /// + /// + /// client.Events.SubscribeAsync( + /// new SubscribeEventsRequestParameters + /// { + /// From = "from", + /// FromTimestamp = "from_timestamp", + /// EventType = new List<EventStreamSubscribeEventsEventTypeEnum?>() + /// { + /// EventStreamSubscribeEventsEventTypeEnum.ConnectionCreated, + /// }, + /// } + /// ); + /// + public WithRawResponseStream SubscribeAsync( + SubscribeEventsRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseStream( + SubscribeAsyncCore(request, options, cancellationToken), + cancellationToken + ); + } } diff --git a/src/Auth0.ManagementApi/Events/IEventsClient.cs b/src/Auth0.ManagementApi/Events/IEventsClient.cs index 3da34cca1..9c093e958 100644 --- a/src/Auth0.ManagementApi/Events/IEventsClient.cs +++ b/src/Auth0.ManagementApi/Events/IEventsClient.cs @@ -5,7 +5,7 @@ public partial interface IEventsClient /// /// Subscribe to events via Server-Sent Events (SSE) /// - IAsyncEnumerable SubscribeAsync( + WithRawResponseStream SubscribeAsync( SubscribeEventsRequestParameters request, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Exceptions/BadRequestError.cs b/src/Auth0.ManagementApi/Exceptions/BadRequestError.cs index 8743b7632..aba76445f 100644 --- a/src/Auth0.ManagementApi/Exceptions/BadRequestError.cs +++ b/src/Auth0.ManagementApi/Exceptions/BadRequestError.cs @@ -4,4 +4,5 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class BadRequestError(object body) : ManagementApiException("BadRequestError", 400, body); +public class BadRequestError(object body, Auth0.ManagementApi.RawResponse? rawResponse = null) + : ManagementApiException("BadRequestError", 400, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Exceptions/ConflictError.cs b/src/Auth0.ManagementApi/Exceptions/ConflictError.cs index c7466c55f..7975d54a1 100644 --- a/src/Auth0.ManagementApi/Exceptions/ConflictError.cs +++ b/src/Auth0.ManagementApi/Exceptions/ConflictError.cs @@ -4,4 +4,5 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class ConflictError(object body) : ManagementApiException("ConflictError", 409, body); +public class ConflictError(object body, Auth0.ManagementApi.RawResponse? rawResponse = null) + : ManagementApiException("ConflictError", 409, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Exceptions/ContentTooLargeError.cs b/src/Auth0.ManagementApi/Exceptions/ContentTooLargeError.cs index dac20c049..208c8bdb4 100644 --- a/src/Auth0.ManagementApi/Exceptions/ContentTooLargeError.cs +++ b/src/Auth0.ManagementApi/Exceptions/ContentTooLargeError.cs @@ -4,5 +4,5 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class ContentTooLargeError(object body) - : ManagementApiException("ContentTooLargeError", 413, body); +public class ContentTooLargeError(object body, Auth0.ManagementApi.RawResponse? rawResponse = null) + : ManagementApiException("ContentTooLargeError", 413, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Exceptions/ForbiddenError.cs b/src/Auth0.ManagementApi/Exceptions/ForbiddenError.cs index ed8d154af..364e14382 100644 --- a/src/Auth0.ManagementApi/Exceptions/ForbiddenError.cs +++ b/src/Auth0.ManagementApi/Exceptions/ForbiddenError.cs @@ -4,4 +4,5 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class ForbiddenError(object body) : ManagementApiException("ForbiddenError", 403, body); +public class ForbiddenError(object body, Auth0.ManagementApi.RawResponse? rawResponse = null) + : ManagementApiException("ForbiddenError", 403, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Exceptions/GoneError.cs b/src/Auth0.ManagementApi/Exceptions/GoneError.cs index c21babc6b..af08a93ba 100644 --- a/src/Auth0.ManagementApi/Exceptions/GoneError.cs +++ b/src/Auth0.ManagementApi/Exceptions/GoneError.cs @@ -4,4 +4,5 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class GoneError(object body) : ManagementApiException("GoneError", 410, body); +public class GoneError(object body, Auth0.ManagementApi.RawResponse? rawResponse = null) + : ManagementApiException("GoneError", 410, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Exceptions/InternalServerError.cs b/src/Auth0.ManagementApi/Exceptions/InternalServerError.cs index ac8ca988b..fe566aac3 100644 --- a/src/Auth0.ManagementApi/Exceptions/InternalServerError.cs +++ b/src/Auth0.ManagementApi/Exceptions/InternalServerError.cs @@ -4,5 +4,5 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class InternalServerError(object body) - : ManagementApiException("InternalServerError", 500, body); +public class InternalServerError(object body, Auth0.ManagementApi.RawResponse? rawResponse = null) + : ManagementApiException("InternalServerError", 500, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Exceptions/NotFoundError.cs b/src/Auth0.ManagementApi/Exceptions/NotFoundError.cs index 8091cb089..1161274d9 100644 --- a/src/Auth0.ManagementApi/Exceptions/NotFoundError.cs +++ b/src/Auth0.ManagementApi/Exceptions/NotFoundError.cs @@ -4,4 +4,5 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class NotFoundError(object body) : ManagementApiException("NotFoundError", 404, body); +public class NotFoundError(object body, Auth0.ManagementApi.RawResponse? rawResponse = null) + : ManagementApiException("NotFoundError", 404, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Exceptions/PaymentRequiredError.cs b/src/Auth0.ManagementApi/Exceptions/PaymentRequiredError.cs index b3b2e7ce6..32f36b41b 100644 --- a/src/Auth0.ManagementApi/Exceptions/PaymentRequiredError.cs +++ b/src/Auth0.ManagementApi/Exceptions/PaymentRequiredError.cs @@ -4,5 +4,5 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class PaymentRequiredError(object body) - : ManagementApiException("PaymentRequiredError", 402, body); +public class PaymentRequiredError(object body, Auth0.ManagementApi.RawResponse? rawResponse = null) + : ManagementApiException("PaymentRequiredError", 402, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Exceptions/PreconditionFailedError.cs b/src/Auth0.ManagementApi/Exceptions/PreconditionFailedError.cs index b435cecd1..314073c75 100644 --- a/src/Auth0.ManagementApi/Exceptions/PreconditionFailedError.cs +++ b/src/Auth0.ManagementApi/Exceptions/PreconditionFailedError.cs @@ -4,5 +4,7 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class PreconditionFailedError(object body) - : ManagementApiException("PreconditionFailedError", 412, body); +public class PreconditionFailedError( + object body, + Auth0.ManagementApi.RawResponse? rawResponse = null +) : ManagementApiException("PreconditionFailedError", 412, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Exceptions/ServiceUnavailableError.cs b/src/Auth0.ManagementApi/Exceptions/ServiceUnavailableError.cs index 2be44fe23..e2feca88b 100644 --- a/src/Auth0.ManagementApi/Exceptions/ServiceUnavailableError.cs +++ b/src/Auth0.ManagementApi/Exceptions/ServiceUnavailableError.cs @@ -4,5 +4,7 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class ServiceUnavailableError(object body) - : ManagementApiException("ServiceUnavailableError", 503, body); +public class ServiceUnavailableError( + object body, + Auth0.ManagementApi.RawResponse? rawResponse = null +) : ManagementApiException("ServiceUnavailableError", 503, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Exceptions/TooManyRequestsError.cs b/src/Auth0.ManagementApi/Exceptions/TooManyRequestsError.cs index 6b7eb6abf..f23b96778 100644 --- a/src/Auth0.ManagementApi/Exceptions/TooManyRequestsError.cs +++ b/src/Auth0.ManagementApi/Exceptions/TooManyRequestsError.cs @@ -4,5 +4,5 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class TooManyRequestsError(object body) - : ManagementApiException("TooManyRequestsError", 429, body); +public class TooManyRequestsError(object body, Auth0.ManagementApi.RawResponse? rawResponse = null) + : ManagementApiException("TooManyRequestsError", 429, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Exceptions/UnauthorizedError.cs b/src/Auth0.ManagementApi/Exceptions/UnauthorizedError.cs index d23a6d30b..4a44eaff4 100644 --- a/src/Auth0.ManagementApi/Exceptions/UnauthorizedError.cs +++ b/src/Auth0.ManagementApi/Exceptions/UnauthorizedError.cs @@ -4,5 +4,5 @@ namespace Auth0.ManagementApi; /// This exception type will be thrown for any non-2XX API responses. /// [Serializable] -public class UnauthorizedError(object body) - : ManagementApiException("UnauthorizedError", 401, body); +public class UnauthorizedError(object body, Auth0.ManagementApi.RawResponse? rawResponse = null) + : ManagementApiException("UnauthorizedError", 401, body, rawResponse: rawResponse); diff --git a/src/Auth0.ManagementApi/Flows/Executions/ExecutionsClient.cs b/src/Auth0.ManagementApi/Flows/Executions/ExecutionsClient.cs index c49189983..cddb5b65a 100644 --- a/src/Auth0.ManagementApi/Flows/Executions/ExecutionsClient.cs +++ b/src/Auth0.ManagementApi/Flows/Executions/ExecutionsClient.cs @@ -75,7 +75,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -89,7 +89,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -102,13 +108,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -118,7 +164,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -171,7 +223,7 @@ private async Task> GetAsyncCor return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -185,7 +237,13 @@ private async Task> GetAsyncCor "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -198,13 +256,53 @@ private async Task> GetAsyncCor switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -214,7 +312,131 @@ private async Task> GetAsyncCor throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string flowId, + string executionId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "flows/{0}/executions/{1}", + ValueConvert.ToPathParameterString(flowId), + ValueConvert.ToPathParameterString(executionId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -290,66 +512,15 @@ public WithRawResponseTask GetAsync( /// /// await client.Flows.Executions.DeleteAsync("flow_id", "execution_id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string flowId, string executionId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "flows/{0}/executions/{1}", - ValueConvert.ToPathParameterString(flowId), - ValueConvert.ToPathParameterString(executionId) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask( + DeleteAsyncCore(flowId, executionId, options, cancellationToken) + ); } } diff --git a/src/Auth0.ManagementApi/Flows/Executions/IExecutionsClient.cs b/src/Auth0.ManagementApi/Flows/Executions/IExecutionsClient.cs index e3e2b8c69..0e7404637 100644 --- a/src/Auth0.ManagementApi/Flows/Executions/IExecutionsClient.cs +++ b/src/Auth0.ManagementApi/Flows/Executions/IExecutionsClient.cs @@ -20,7 +20,7 @@ WithRawResponseTask GetAsync( CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string flowId, string executionId, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Flows/FlowsClient.cs b/src/Auth0.ManagementApi/Flows/FlowsClient.cs index 88bcbee72..9ea846bf3 100644 --- a/src/Auth0.ManagementApi/Flows/FlowsClient.cs +++ b/src/Auth0.ManagementApi/Flows/FlowsClient.cs @@ -81,7 +81,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -95,7 +95,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -108,13 +114,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -124,7 +170,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -135,6 +187,9 @@ private async Task> CreateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -148,6 +203,7 @@ private async Task> CreateAsyncCore( Method = HttpMethod.Post, Path = "flows", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -166,7 +222,7 @@ private async Task> CreateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -180,7 +236,13 @@ private async Task> CreateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -193,13 +255,53 @@ private async Task> CreateAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -209,7 +311,13 @@ private async Task> CreateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -255,7 +363,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -269,7 +377,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -282,15 +396,65 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -300,7 +464,138 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format("flows/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -312,6 +607,9 @@ private async Task> UpdateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -325,6 +623,7 @@ private async Task> UpdateAsyncCore( Method = HttpMethodExtensions.Patch, Path = string.Format("flows/{0}", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -343,7 +642,7 @@ private async Task> UpdateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -357,7 +656,13 @@ private async Task> UpdateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -370,13 +675,53 @@ private async Task> UpdateAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -386,7 +731,13 @@ private async Task> UpdateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -481,64 +832,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Flows.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format("flows/{0}", ValueConvert.ToPathParameterString(id)), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Flows/IFlowsClient.cs b/src/Auth0.ManagementApi/Flows/IFlowsClient.cs index a9b008ba8..10090a5d5 100644 --- a/src/Auth0.ManagementApi/Flows/IFlowsClient.cs +++ b/src/Auth0.ManagementApi/Flows/IFlowsClient.cs @@ -26,7 +26,7 @@ WithRawResponseTask GetAsync( CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Flows/Vault/Connections/ConnectionsClient.cs b/src/Auth0.ManagementApi/Flows/Vault/Connections/ConnectionsClient.cs index 514bc2e73..99dc64a47 100644 --- a/src/Auth0.ManagementApi/Flows/Vault/Connections/ConnectionsClient.cs +++ b/src/Auth0.ManagementApi/Flows/Vault/Connections/ConnectionsClient.cs @@ -74,7 +74,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -88,7 +88,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -101,13 +107,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -117,7 +163,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -128,6 +180,9 @@ private async Task> C CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -141,6 +196,7 @@ private async Task> C Method = HttpMethod.Post, Path = "flows/vault/connections", Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -160,7 +216,7 @@ private async Task> C return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -174,7 +230,13 @@ private async Task> C "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -187,13 +249,53 @@ private async Task> C switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -203,7 +305,13 @@ private async Task> C throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -214,6 +322,9 @@ private async Task> GetA CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -229,6 +340,7 @@ private async Task> GetA "flows/vault/connections/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -248,7 +360,7 @@ private async Task> GetA return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -262,7 +374,13 @@ private async Task> GetA "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -275,15 +393,181 @@ private async Task> GetA switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "flows/vault/connections/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -293,7 +577,13 @@ private async Task> GetA throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -305,6 +595,9 @@ private async Task> U CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -321,6 +614,7 @@ private async Task> U ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -341,7 +635,7 @@ private async Task> U return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -355,7 +649,13 @@ private async Task> U "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -368,15 +668,65 @@ private async Task> U switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -386,7 +736,13 @@ private async Task> U throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -478,65 +834,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Flows.Vault.Connections.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "flows/vault/connections/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Flows/Vault/Connections/IConnectionsClient.cs b/src/Auth0.ManagementApi/Flows/Vault/Connections/IConnectionsClient.cs index 32d9fb161..48462ff7d 100644 --- a/src/Auth0.ManagementApi/Flows/Vault/Connections/IConnectionsClient.cs +++ b/src/Auth0.ManagementApi/Flows/Vault/Connections/IConnectionsClient.cs @@ -23,7 +23,7 @@ WithRawResponseTask GetAsync( CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Forms/FormsClient.cs b/src/Auth0.ManagementApi/Forms/FormsClient.cs index 5c5385bf9..742ebe26d 100644 --- a/src/Auth0.ManagementApi/Forms/FormsClient.cs +++ b/src/Auth0.ManagementApi/Forms/FormsClient.cs @@ -73,7 +73,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -87,7 +87,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -100,13 +106,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -116,7 +162,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -127,6 +179,9 @@ private async Task> CreateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -140,6 +195,7 @@ private async Task> CreateAsyncCore( Method = HttpMethod.Post, Path = "forms", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -158,7 +214,7 @@ private async Task> CreateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -172,7 +228,13 @@ private async Task> CreateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -185,13 +247,53 @@ private async Task> CreateAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -201,7 +303,13 @@ private async Task> CreateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -247,7 +355,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -261,7 +369,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -274,15 +388,65 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -292,7 +456,126 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format("forms/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -304,6 +587,9 @@ private async Task> UpdateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -317,6 +603,7 @@ private async Task> UpdateAsyncCore( Method = HttpMethodExtensions.Patch, Path = string.Format("forms/{0}", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -335,7 +622,7 @@ private async Task> UpdateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -349,7 +636,13 @@ private async Task> UpdateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -362,11 +655,41 @@ private async Task> UpdateAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -376,7 +699,13 @@ private async Task> UpdateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -470,62 +799,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Forms.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format("forms/{0}", ValueConvert.ToPathParameterString(id)), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Forms/IFormsClient.cs b/src/Auth0.ManagementApi/Forms/IFormsClient.cs index b3a192a36..bf9b4d721 100644 --- a/src/Auth0.ManagementApi/Forms/IFormsClient.cs +++ b/src/Auth0.ManagementApi/Forms/IFormsClient.cs @@ -23,7 +23,7 @@ WithRawResponseTask GetAsync( CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Groups/GroupsClient.cs b/src/Auth0.ManagementApi/Groups/GroupsClient.cs index aab3438ed..ac0c10e58 100644 --- a/src/Auth0.ManagementApi/Groups/GroupsClient.cs +++ b/src/Auth0.ManagementApi/Groups/GroupsClient.cs @@ -87,7 +87,7 @@ private async Task> ListInte return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -101,7 +101,13 @@ private async Task> ListInte "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -114,13 +120,53 @@ private async Task> ListInte switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -130,7 +176,13 @@ private async Task> ListInte throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -141,6 +193,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -153,6 +208,7 @@ private async Task> GetAsyncCore( { Method = HttpMethod.Get, Path = string.Format("groups/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -170,7 +226,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -184,7 +240,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -197,15 +259,178 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format("groups/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -215,7 +440,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -295,61 +526,12 @@ public WithRawResponseTask GetAsync( /// /// await client.Groups.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format("groups/{0}", ValueConvert.ToPathParameterString(id)), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/Groups/IGroupsClient.cs b/src/Auth0.ManagementApi/Groups/IGroupsClient.cs index 2e60af160..6b0302b59 100644 --- a/src/Auth0.ManagementApi/Groups/IGroupsClient.cs +++ b/src/Auth0.ManagementApi/Groups/IGroupsClient.cs @@ -28,7 +28,7 @@ WithRawResponseTask GetAsync( /// /// Delete a group by its ID. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Groups/Members/MembersClient.cs b/src/Auth0.ManagementApi/Groups/Members/MembersClient.cs index 7c79a969a..c425d31a6 100644 --- a/src/Auth0.ManagementApi/Groups/Members/MembersClient.cs +++ b/src/Auth0.ManagementApi/Groups/Members/MembersClient.cs @@ -80,7 +80,7 @@ private async Task> GetInternalA return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -94,7 +94,13 @@ private async Task> GetInternalA "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -107,15 +113,65 @@ private async Task> GetInternalA switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -125,7 +181,13 @@ private async Task> GetInternalA throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Groups/Roles/IRolesClient.cs b/src/Auth0.ManagementApi/Groups/Roles/IRolesClient.cs index 7dacec278..cde9bec81 100644 --- a/src/Auth0.ManagementApi/Groups/Roles/IRolesClient.cs +++ b/src/Auth0.ManagementApi/Groups/Roles/IRolesClient.cs @@ -18,7 +18,7 @@ Task> ListAsync( /// /// Assign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) to a specified group. /// - Task CreateAsync( + WithRawResponseTask CreateAsync( string id, CreateGroupRolesRequestParameters request, RequestOptions? options = null, @@ -28,7 +28,7 @@ Task CreateAsync( /// /// Unassign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) from a specified group. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, DeleteGroupRolesRequestContent request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Groups/Roles/RolesClient.cs b/src/Auth0.ManagementApi/Groups/Roles/RolesClient.cs index 254de171f..bb45cc947 100644 --- a/src/Auth0.ManagementApi/Groups/Roles/RolesClient.cs +++ b/src/Auth0.ManagementApi/Groups/Roles/RolesClient.cs @@ -75,7 +75,7 @@ private async Task> ListInternalA return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -89,7 +89,13 @@ private async Task> ListInternalA "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -102,15 +108,65 @@ private async Task> ListInternalA switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -120,72 +176,27 @@ private async Task> ListInternalA throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Lists the [roles](https://auth0.com/docs/manage-users/access-control/rbac) assigned to a group. - /// - /// - /// await client.Groups.Roles.ListAsync( - /// "id", - /// new ListGroupRolesRequestParameters { From = "from", Take = 1 } - /// ); - /// - public async Task> ListAsync( - string id, - ListGroupRolesRequestParameters request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - if (request is not null) - { - request = request with { }; - } - var pager = await CursorPager< - ListGroupRolesRequestParameters, - RequestOptions?, - ListGroupRolesResponseContent, - string?, - Role - > - .CreateInstanceAsync( - request, - options, - async (request, options, cancellationToken) => - await ListInternalAsync(id, request, options, cancellationToken) - .WithRawResponse(), - (request, cursor) => - { - request.From = cursor; - }, - response => response.Next, - response => response.Roles?.ToList(), - cancellationToken - ) - .ConfigureAwait(false); - return pager; - } - - /// - /// Assign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) to a specified group. - /// - /// - /// await client.Groups.Roles.CreateAsync( - /// "id", - /// new CreateGroupRolesRequestParameters { Roles = new List<string>() { "roles" } } - /// ); - /// - public async Task CreateAsync( + private async Task CreateAsyncCore( string id, CreateGroupRolesRequestParameters request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -202,6 +213,7 @@ public async Task CreateAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -211,7 +223,12 @@ public async Task CreateAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -222,15 +239,65 @@ public async Task CreateAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -240,27 +307,27 @@ public async Task CreateAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Unassign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) from a specified group. - /// - /// - /// await client.Groups.Roles.DeleteAsync( - /// "id", - /// new DeleteGroupRolesRequestContent { Roles = new List<string>() { "roles" } } - /// ); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, DeleteGroupRolesRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -277,6 +344,7 @@ public async Task DeleteAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -286,7 +354,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -297,15 +370,65 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -315,8 +438,97 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Lists the [roles](https://auth0.com/docs/manage-users/access-control/rbac) assigned to a group. + /// + /// + /// await client.Groups.Roles.ListAsync( + /// "id", + /// new ListGroupRolesRequestParameters { From = "from", Take = 1 } + /// ); + /// + public async Task> ListAsync( + string id, + ListGroupRolesRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + if (request is not null) + { + request = request with { }; + } + var pager = await CursorPager< + ListGroupRolesRequestParameters, + RequestOptions?, + ListGroupRolesResponseContent, + string?, + Role + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await ListInternalAsync(id, request, options, cancellationToken) + .WithRawResponse(), + (request, cursor) => + { + request.From = cursor; + }, + response => response.Next, + response => response.Roles?.ToList(), + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } + + /// + /// Assign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) to a specified group. + /// + /// + /// await client.Groups.Roles.CreateAsync( + /// "id", + /// new CreateGroupRolesRequestParameters { Roles = new List<string>() { "roles" } } + /// ); + /// + public WithRawResponseTask CreateAsync( + string id, + CreateGroupRolesRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(CreateAsyncCore(id, request, options, cancellationToken)); + } + + /// + /// Unassign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) from a specified group. + /// + /// + /// await client.Groups.Roles.DeleteAsync( + /// "id", + /// new DeleteGroupRolesRequestContent { Roles = new List<string>() { "roles" } } + /// ); + /// + public WithRawResponseTask DeleteAsync( + string id, + DeleteGroupRolesRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, request, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Guardian/Enrollments/EnrollmentsClient.cs b/src/Auth0.ManagementApi/Guardian/Enrollments/EnrollmentsClient.cs index 9eb41c8ac..fe7a2a051 100644 --- a/src/Auth0.ManagementApi/Guardian/Enrollments/EnrollmentsClient.cs +++ b/src/Auth0.ManagementApi/Guardian/Enrollments/EnrollmentsClient.cs @@ -21,6 +21,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -34,6 +37,7 @@ private async Task< Method = HttpMethod.Post, Path = "guardian/enrollments/ticket", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -55,7 +59,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -69,7 +73,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -82,13 +92,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -98,7 +148,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,6 +165,9 @@ private async Task> GetAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -124,6 +183,7 @@ private async Task> GetAsy "guardian/enrollments/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -143,7 +203,7 @@ private async Task> GetAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -157,7 +217,13 @@ private async Task> GetAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -170,11 +236,41 @@ private async Task> GetAsy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -184,59 +280,26 @@ private async Task> GetAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Create a [multi-factor authentication (MFA) enrollment ticket](https://auth0.com/docs/secure/multi-factor-authentication/auth0-guardian/create-custom-enrollment-tickets), and optionally send an email with the created ticket to a given user. Enrollment tickets can specify which factor users must enroll with or allow existing MFA users to enroll in additional factors. - /// - /// - /// await client.Guardian.Enrollments.CreateTicketAsync( - /// new CreateGuardianEnrollmentTicketRequestContent { UserId = "user_id" } - /// ); - /// - public WithRawResponseTask CreateTicketAsync( - CreateGuardianEnrollmentTicketRequestContent request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask( - CreateTicketAsyncCore(request, options, cancellationToken) - ); - } - - /// - /// Retrieve details, such as status and type, for a specific multi-factor authentication enrollment registered to a user account. - /// - /// - /// await client.Guardian.Enrollments.GetAsync("id"); - /// - public WithRawResponseTask GetAsync( - string id, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask( - GetAsyncCore(id, options, cancellationToken) - ); - } - - /// - /// Remove a specific multi-factor authentication (MFA) enrollment from a user's account. This allows the user to re-enroll with MFA. For more information, review [Reset User Multi-Factor Authentication and Recovery Codes](https://auth0.com/docs/secure/multi-factor-authentication/reset-user-mfa). - /// - /// - /// await client.Guardian.Enrollments.DeleteAsync("id"); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -252,6 +315,7 @@ public async Task DeleteAsync( "guardian/enrollments/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -260,7 +324,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -271,11 +340,41 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -285,8 +384,65 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Create a [multi-factor authentication (MFA) enrollment ticket](https://auth0.com/docs/secure/multi-factor-authentication/auth0-guardian/create-custom-enrollment-tickets), and optionally send an email with the created ticket to a given user. Enrollment tickets can specify which factor users must enroll with or allow existing MFA users to enroll in additional factors. + /// + /// + /// await client.Guardian.Enrollments.CreateTicketAsync( + /// new CreateGuardianEnrollmentTicketRequestContent { UserId = "user_id" } + /// ); + /// + public WithRawResponseTask CreateTicketAsync( + CreateGuardianEnrollmentTicketRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + CreateTicketAsyncCore(request, options, cancellationToken) + ); + } + + /// + /// Retrieve details, such as status and type, for a specific multi-factor authentication enrollment registered to a user account. + /// + /// + /// await client.Guardian.Enrollments.GetAsync("id"); + /// + public WithRawResponseTask GetAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + GetAsyncCore(id, options, cancellationToken) + ); + } + + /// + /// Remove a specific multi-factor authentication (MFA) enrollment from a user's account. This allows the user to re-enroll with MFA. For more information, review [Reset User Multi-Factor Authentication and Recovery Codes](https://auth0.com/docs/secure/multi-factor-authentication/reset-user-mfa). + /// + /// + /// await client.Guardian.Enrollments.DeleteAsync("id"); + /// + public WithRawResponseTask DeleteAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Guardian/Enrollments/IEnrollmentsClient.cs b/src/Auth0.ManagementApi/Guardian/Enrollments/IEnrollmentsClient.cs index 467420125..450ce7639 100644 --- a/src/Auth0.ManagementApi/Guardian/Enrollments/IEnrollmentsClient.cs +++ b/src/Auth0.ManagementApi/Guardian/Enrollments/IEnrollmentsClient.cs @@ -25,7 +25,7 @@ WithRawResponseTask GetAsync( /// /// Remove a specific multi-factor authentication (MFA) enrollment from a user's account. This allows the user to re-enroll with MFA. For more information, review [Reset User Multi-Factor Authentication and Recovery Codes](https://auth0.com/docs/secure/multi-factor-authentication/reset-user-mfa). /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Guardian/Factors/Duo/Settings/SettingsClient.cs b/src/Auth0.ManagementApi/Guardian/Factors/Duo/Settings/SettingsClient.cs index fc342d18b..1872a437c 100644 --- a/src/Auth0.ManagementApi/Guardian/Factors/Duo/Settings/SettingsClient.cs +++ b/src/Auth0.ManagementApi/Guardian/Factors/Duo/Settings/SettingsClient.cs @@ -18,6 +18,9 @@ private async Task> CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -30,6 +33,7 @@ private async Task> { Method = HttpMethod.Get, Path = "guardian/factors/duo/settings", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -50,7 +54,7 @@ private async Task> return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -64,7 +68,13 @@ private async Task> "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -77,11 +87,41 @@ private async Task> switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -91,7 +131,13 @@ private async Task> throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -102,6 +148,9 @@ private async Task> CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -115,6 +164,7 @@ private async Task> Method = HttpMethod.Put, Path = "guardian/factors/duo/settings", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -136,7 +186,7 @@ private async Task> return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -150,7 +200,13 @@ private async Task> "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -163,11 +219,41 @@ private async Task> switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -177,7 +263,13 @@ private async Task> throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -190,6 +282,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -203,6 +298,7 @@ private async Task< Method = HttpMethodExtensions.Patch, Path = "guardian/factors/duo/settings", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -224,7 +320,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -238,7 +334,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -251,11 +353,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -265,7 +397,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Guardian/Factors/FactorsClient.cs b/src/Auth0.ManagementApi/Guardian/Factors/FactorsClient.cs index 065c229d3..5d4ee2cd5 100644 --- a/src/Auth0.ManagementApi/Guardian/Factors/FactorsClient.cs +++ b/src/Auth0.ManagementApi/Guardian/Factors/FactorsClient.cs @@ -32,6 +32,9 @@ private async Task>> ListAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -44,6 +47,7 @@ private async Task>> ListAsyncCore( { Method = HttpMethod.Get, Path = "guardian/factors", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -63,7 +67,7 @@ private async Task>> ListAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -77,7 +81,13 @@ private async Task>> ListAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -90,11 +100,41 @@ private async Task>> ListAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -104,7 +144,13 @@ private async Task>> ListAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -116,6 +162,9 @@ private async Task> SetAsyncCo CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -132,6 +181,7 @@ private async Task> SetAsyncCo ValueConvert.ToPathParameterString(name) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -152,7 +202,7 @@ private async Task> SetAsyncCo return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -166,7 +216,13 @@ private async Task> SetAsyncCo "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -179,11 +235,41 @@ private async Task> SetAsyncCo switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -193,7 +279,13 @@ private async Task> SetAsyncCo throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Guardian/Factors/Phone/PhoneClient.cs b/src/Auth0.ManagementApi/Guardian/Factors/Phone/PhoneClient.cs index 87f8a6f00..abfaafc00 100644 --- a/src/Auth0.ManagementApi/Guardian/Factors/Phone/PhoneClient.cs +++ b/src/Auth0.ManagementApi/Guardian/Factors/Phone/PhoneClient.cs @@ -20,6 +20,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -32,6 +35,7 @@ private async Task< { Method = HttpMethod.Get, Path = "guardian/factors/phone/message-types", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -52,7 +56,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -66,7 +70,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -79,11 +89,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -93,7 +133,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -106,6 +152,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -119,6 +168,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/phone/message-types", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -140,7 +190,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -154,7 +204,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -167,13 +223,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -183,7 +279,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -195,6 +297,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -207,6 +312,7 @@ private async Task< { Method = HttpMethod.Get, Path = "guardian/factors/phone/providers/twilio", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -227,7 +333,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -241,7 +347,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -254,11 +366,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -268,7 +410,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -281,6 +429,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -294,6 +445,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/phone/providers/twilio", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -315,7 +467,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -329,7 +481,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -342,11 +500,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -356,7 +544,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -368,6 +562,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -380,6 +577,7 @@ private async Task< { Method = HttpMethod.Get, Path = "guardian/factors/phone/selected-provider", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -400,7 +598,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -414,7 +612,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -427,11 +631,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -441,7 +675,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -454,6 +694,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -467,6 +710,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/phone/selected-provider", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -488,7 +732,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -502,7 +746,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -515,11 +765,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -529,7 +809,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -541,6 +827,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -553,6 +842,7 @@ private async Task< { Method = HttpMethod.Get, Path = "guardian/factors/phone/templates", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -573,7 +863,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -587,7 +877,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -600,11 +896,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -614,7 +940,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -627,6 +959,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -640,6 +975,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/phone/templates", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -661,7 +997,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -675,7 +1011,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -688,11 +1030,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -702,7 +1074,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Guardian/Factors/PushNotification/PushNotificationClient.cs b/src/Auth0.ManagementApi/Guardian/Factors/PushNotification/PushNotificationClient.cs index e5da74c4b..b86536f8d 100644 --- a/src/Auth0.ManagementApi/Guardian/Factors/PushNotification/PushNotificationClient.cs +++ b/src/Auth0.ManagementApi/Guardian/Factors/PushNotification/PushNotificationClient.cs @@ -20,6 +20,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -32,6 +35,7 @@ private async Task< { Method = HttpMethod.Get, Path = "guardian/factors/push-notification/providers/apns", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -52,7 +56,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -66,7 +70,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -79,11 +89,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -93,7 +133,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -106,6 +152,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -119,6 +168,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/push-notification/providers/apns", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -140,7 +190,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -154,7 +204,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -167,11 +223,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -181,7 +267,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -194,6 +286,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -207,6 +302,7 @@ private async Task< Method = HttpMethodExtensions.Patch, Path = "guardian/factors/push-notification/providers/apns", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -228,7 +324,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -242,7 +338,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -255,11 +357,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -269,7 +401,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -280,6 +418,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -293,6 +434,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/push-notification/providers/fcm", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -313,7 +455,7 @@ private async Task< return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -327,7 +469,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -340,11 +488,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -354,7 +532,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -365,6 +549,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -378,6 +565,7 @@ private async Task< Method = HttpMethodExtensions.Patch, Path = "guardian/factors/push-notification/providers/fcm", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -398,7 +586,7 @@ private async Task< return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -412,7 +600,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -425,11 +619,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -439,7 +663,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -450,6 +680,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -463,6 +696,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/push-notification/providers/fcmv1", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -483,7 +717,7 @@ private async Task< return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -497,7 +731,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -510,11 +750,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -524,7 +794,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -535,6 +811,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -548,6 +827,7 @@ private async Task< Method = HttpMethodExtensions.Patch, Path = "guardian/factors/push-notification/providers/fcmv1", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -568,7 +848,7 @@ private async Task< return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -582,7 +862,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -595,11 +881,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -609,7 +925,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -621,6 +943,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -633,6 +958,7 @@ private async Task< { Method = HttpMethod.Get, Path = "guardian/factors/push-notification/providers/sns", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -653,7 +979,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -667,7 +993,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -680,11 +1012,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -694,7 +1056,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -707,6 +1075,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -720,6 +1091,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/push-notification/providers/sns", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -741,7 +1113,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -755,7 +1127,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -768,11 +1146,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -782,7 +1190,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -795,6 +1209,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -808,6 +1225,7 @@ private async Task< Method = HttpMethodExtensions.Patch, Path = "guardian/factors/push-notification/providers/sns", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -829,7 +1247,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -843,7 +1261,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -856,11 +1280,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -870,7 +1324,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -882,6 +1342,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -894,6 +1357,7 @@ private async Task< { Method = HttpMethod.Get, Path = "guardian/factors/push-notification/selected-provider", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -914,7 +1378,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -928,7 +1392,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -941,11 +1411,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -955,7 +1455,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -968,6 +1474,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -981,6 +1490,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/push-notification/selected-provider", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -1002,7 +1512,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -1016,7 +1526,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -1029,11 +1545,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -1043,7 +1589,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Guardian/Factors/Sms/ISmsClient.cs b/src/Auth0.ManagementApi/Guardian/Factors/Sms/ISmsClient.cs index a891d0615..398d6f657 100644 --- a/src/Auth0.ManagementApi/Guardian/Factors/Sms/ISmsClient.cs +++ b/src/Auth0.ManagementApi/Guardian/Factors/Sms/ISmsClient.cs @@ -51,7 +51,7 @@ WithRawResponseTask SetProviderAsy /// /// Previous function: Retrieve details of SMS enrollment and verification templates configured for your tenant. /// - WithRawResponseTask GetTemplatesAsync( + WithRawResponseTask GetTemplatesAsync( RequestOptions? options = null, CancellationToken cancellationToken = default ); diff --git a/src/Auth0.ManagementApi/Guardian/Factors/Sms/SmsClient.cs b/src/Auth0.ManagementApi/Guardian/Factors/Sms/SmsClient.cs index cdeb73fc3..932fe8a3c 100644 --- a/src/Auth0.ManagementApi/Guardian/Factors/Sms/SmsClient.cs +++ b/src/Auth0.ManagementApi/Guardian/Factors/Sms/SmsClient.cs @@ -20,6 +20,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -32,6 +35,7 @@ private async Task< { Method = HttpMethod.Get, Path = "guardian/factors/sms/providers/twilio", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -52,7 +56,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -66,7 +70,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -79,11 +89,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -93,7 +133,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -106,6 +152,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -119,6 +168,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/sms/providers/twilio", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -140,7 +190,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -154,7 +204,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -167,11 +223,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -181,7 +267,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -193,6 +285,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -205,6 +300,7 @@ private async Task< { Method = HttpMethod.Get, Path = "guardian/factors/sms/selected-provider", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -225,7 +321,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -239,7 +335,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -252,11 +354,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -266,7 +398,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -279,6 +417,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -292,6 +433,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/sms/selected-provider", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -313,7 +455,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -327,7 +469,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -340,11 +488,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -354,18 +532,27 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } private async Task< - WithRawResponse + WithRawResponse > GetTemplatesAsyncCore( RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -378,6 +565,7 @@ private async Task< { Method = HttpMethod.Get, Path = "guardian/factors/sms/templates", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -392,13 +580,13 @@ private async Task< try { var responseData = - JsonUtils.Deserialize( + JsonUtils.Deserialize( responseBody )!; - return new WithRawResponse() + return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -412,7 +600,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -425,11 +619,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -439,7 +663,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -452,6 +682,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -465,6 +698,7 @@ private async Task< Method = HttpMethod.Put, Path = "guardian/factors/sms/templates", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -486,7 +720,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -500,7 +734,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -513,11 +753,41 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -527,7 +797,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -621,12 +897,12 @@ public WithRawResponseTask SetProv /// /// await client.Guardian.Factors.Sms.GetTemplatesAsync(); /// - public WithRawResponseTask GetTemplatesAsync( + public WithRawResponseTask GetTemplatesAsync( RequestOptions? options = null, CancellationToken cancellationToken = default ) { - return new WithRawResponseTask( + return new WithRawResponseTask( GetTemplatesAsyncCore(options, cancellationToken) ); } diff --git a/src/Auth0.ManagementApi/Guardian/Policies/PoliciesClient.cs b/src/Auth0.ManagementApi/Guardian/Policies/PoliciesClient.cs index 0e7c3072d..6f48718f9 100644 --- a/src/Auth0.ManagementApi/Guardian/Policies/PoliciesClient.cs +++ b/src/Auth0.ManagementApi/Guardian/Policies/PoliciesClient.cs @@ -18,6 +18,9 @@ private async Task>> ListAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -30,6 +33,7 @@ private async Task>> ListAsyncCore( { Method = HttpMethod.Get, Path = "guardian/policies", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -47,7 +51,7 @@ private async Task>> ListAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -61,7 +65,13 @@ private async Task>> ListAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -74,11 +84,41 @@ private async Task>> ListAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -88,7 +128,13 @@ private async Task>> ListAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -99,6 +145,9 @@ private async Task>> SetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -112,6 +161,7 @@ private async Task>> SetAsyncCore( Method = HttpMethod.Put, Path = "guardian/policies", Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -129,7 +179,7 @@ private async Task>> SetAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -143,7 +193,13 @@ private async Task>> SetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -156,11 +212,41 @@ private async Task>> SetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -170,7 +256,13 @@ private async Task>> SetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Hooks/HooksClient.cs b/src/Auth0.ManagementApi/Hooks/HooksClient.cs index 9de44ff2d..9807817f4 100644 --- a/src/Auth0.ManagementApi/Hooks/HooksClient.cs +++ b/src/Auth0.ManagementApi/Hooks/HooksClient.cs @@ -82,7 +82,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -96,7 +96,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,15 +115,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -127,7 +183,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -138,6 +200,9 @@ private async Task> CreateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -151,6 +216,7 @@ private async Task> CreateAsyncCore( Method = HttpMethod.Post, Path = "hooks", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -169,7 +235,7 @@ private async Task> CreateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -183,7 +249,13 @@ private async Task> CreateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -196,15 +268,65 @@ private async Task> CreateAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -214,7 +336,13 @@ private async Task> CreateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -260,7 +388,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -274,7 +402,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -287,15 +421,65 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -305,7 +489,126 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format("hooks/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -317,6 +620,9 @@ private async Task> UpdateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -330,6 +636,7 @@ private async Task> UpdateAsyncCore( Method = HttpMethodExtensions.Patch, Path = string.Format("hooks/{0}", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -348,7 +655,7 @@ private async Task> UpdateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -362,7 +669,13 @@ private async Task> UpdateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -375,17 +688,77 @@ private async Task> UpdateAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -395,7 +768,13 @@ private async Task> UpdateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -498,62 +877,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Hooks.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format("hooks/{0}", ValueConvert.ToPathParameterString(id)), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Hooks/IHooksClient.cs b/src/Auth0.ManagementApi/Hooks/IHooksClient.cs index 70a4ac086..107f84d04 100644 --- a/src/Auth0.ManagementApi/Hooks/IHooksClient.cs +++ b/src/Auth0.ManagementApi/Hooks/IHooksClient.cs @@ -38,7 +38,7 @@ WithRawResponseTask GetAsync( /// /// Delete a hook. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Hooks/Secrets/ISecretsClient.cs b/src/Auth0.ManagementApi/Hooks/Secrets/ISecretsClient.cs index 8f5a686f4..264f89df8 100644 --- a/src/Auth0.ManagementApi/Hooks/Secrets/ISecretsClient.cs +++ b/src/Auth0.ManagementApi/Hooks/Secrets/ISecretsClient.cs @@ -16,7 +16,7 @@ WithRawResponseTask> GetAsync( /// /// Add one or more secrets to an existing hook. Accepts an object of key-value pairs, where the key is the name of the secret. A hook can have a maximum of 20 secrets. /// - Task CreateAsync( + WithRawResponseTask CreateAsync( string id, Dictionary request, RequestOptions? options = null, @@ -26,7 +26,7 @@ Task CreateAsync( /// /// Delete one or more existing secrets for a given hook. Accepts an array of secret names to delete. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, IEnumerable request, RequestOptions? options = null, @@ -36,7 +36,7 @@ Task DeleteAsync( /// /// Update one or more existing secrets for an existing hook. Accepts an object of key-value pairs, where the key is the name of the existing secret. /// - Task UpdateAsync( + WithRawResponseTask UpdateAsync( string id, Dictionary request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Hooks/Secrets/SecretsClient.cs b/src/Auth0.ManagementApi/Hooks/Secrets/SecretsClient.cs index ee1700d1f..1a28b8166 100644 --- a/src/Auth0.ManagementApi/Hooks/Secrets/SecretsClient.cs +++ b/src/Auth0.ManagementApi/Hooks/Secrets/SecretsClient.cs @@ -19,6 +19,9 @@ private async Task>> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -34,6 +37,7 @@ private async Task>> GetAsyncCore( "hooks/{0}/secrets", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -51,7 +55,7 @@ private async Task>> GetAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -65,7 +69,13 @@ private async Task>> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -78,15 +88,65 @@ private async Task>> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -96,44 +156,27 @@ private async Task>> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Retrieve a hook's secrets by the ID of the hook. - /// - /// - /// await client.Hooks.Secrets.GetAsync("id"); - /// - public WithRawResponseTask> GetAsync( - string id, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask>( - GetAsyncCore(id, options, cancellationToken) - ); - } - - /// - /// Add one or more secrets to an existing hook. Accepts an object of key-value pairs, where the key is the name of the secret. A hook can have a maximum of 20 secrets. - /// - /// - /// await client.Hooks.Secrets.CreateAsync( - /// "id", - /// new Dictionary<string, string>() { { "key", "value" } } - /// ); - /// - public async Task CreateAsync( + private async Task CreateAsyncCore( string id, Dictionary request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -150,6 +193,7 @@ public async Task CreateAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -158,7 +202,12 @@ public async Task CreateAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -169,15 +218,65 @@ public async Task CreateAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -187,24 +286,27 @@ public async Task CreateAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Delete one or more existing secrets for a given hook. Accepts an array of secret names to delete. - /// - /// - /// await client.Hooks.Secrets.DeleteAsync("id", new List<string>() { "string" }); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, IEnumerable request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -221,6 +323,7 @@ public async Task DeleteAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -229,7 +332,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -240,13 +348,53 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -256,27 +404,27 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Update one or more existing secrets for an existing hook. Accepts an object of key-value pairs, where the key is the name of the existing secret. - /// - /// - /// await client.Hooks.Secrets.UpdateAsync( - /// "id", - /// new Dictionary<string, string>() { { "key", "value" } } - /// ); - /// - public async Task UpdateAsync( + private async Task UpdateAsyncCore( string id, Dictionary request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -293,6 +441,7 @@ public async Task UpdateAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -301,7 +450,12 @@ public async Task UpdateAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -312,17 +466,77 @@ public async Task UpdateAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -332,8 +546,85 @@ public async Task UpdateAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Retrieve a hook's secrets by the ID of the hook. + /// + /// + /// await client.Hooks.Secrets.GetAsync("id"); + /// + public WithRawResponseTask> GetAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask>( + GetAsyncCore(id, options, cancellationToken) + ); + } + + /// + /// Add one or more secrets to an existing hook. Accepts an object of key-value pairs, where the key is the name of the secret. A hook can have a maximum of 20 secrets. + /// + /// + /// await client.Hooks.Secrets.CreateAsync( + /// "id", + /// new Dictionary<string, string>() { { "key", "value" } } + /// ); + /// + public WithRawResponseTask CreateAsync( + string id, + Dictionary request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(CreateAsyncCore(id, request, options, cancellationToken)); + } + + /// + /// Delete one or more existing secrets for a given hook. Accepts an array of secret names to delete. + /// + /// + /// await client.Hooks.Secrets.DeleteAsync("id", new List<string>() { "string" }); + /// + public WithRawResponseTask DeleteAsync( + string id, + IEnumerable request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, request, options, cancellationToken)); + } + + /// + /// Update one or more existing secrets for an existing hook. Accepts an object of key-value pairs, where the key is the name of the existing secret. + /// + /// + /// await client.Hooks.Secrets.UpdateAsync( + /// "id", + /// new Dictionary<string, string>() { { "key", "value" } } + /// ); + /// + public WithRawResponseTask UpdateAsync( + string id, + Dictionary request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(UpdateAsyncCore(id, request, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Jobs/Errors/ErrorsClient.cs b/src/Auth0.ManagementApi/Jobs/Errors/ErrorsClient.cs index 49cd06aff..3ba2ab4ed 100644 --- a/src/Auth0.ManagementApi/Jobs/Errors/ErrorsClient.cs +++ b/src/Auth0.ManagementApi/Jobs/Errors/ErrorsClient.cs @@ -13,12 +13,15 @@ internal ErrorsClient(RawClient client) _client = client; } - private async Task> GetAsyncCore( + private async Task> GetAsyncCore( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -31,6 +34,7 @@ private async Task> GetAsyncCore( { Method = HttpMethod.Get, Path = string.Format("jobs/{0}/errors", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -44,11 +48,11 @@ private async Task> GetAsyncCore( .ConfigureAwait(false); try { - var responseData = JsonUtils.Deserialize(responseBody)!; - return new WithRawResponse() + var responseData = JsonUtils.Deserialize(responseBody)!; + return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -62,7 +66,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -75,15 +85,65 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -93,7 +153,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -104,13 +170,13 @@ private async Task> GetAsyncCore( /// /// await client.Jobs.Errors.GetAsync("id"); /// - public WithRawResponseTask GetAsync( + public WithRawResponseTask GetAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - return new WithRawResponseTask( + return new WithRawResponseTask( GetAsyncCore(id, options, cancellationToken) ); } diff --git a/src/Auth0.ManagementApi/Jobs/Errors/IErrorsClient.cs b/src/Auth0.ManagementApi/Jobs/Errors/IErrorsClient.cs index afa37be7d..54436e136 100644 --- a/src/Auth0.ManagementApi/Jobs/Errors/IErrorsClient.cs +++ b/src/Auth0.ManagementApi/Jobs/Errors/IErrorsClient.cs @@ -7,7 +7,7 @@ public partial interface IErrorsClient /// /// Retrieve error details of a failed job. /// - WithRawResponseTask GetAsync( + WithRawResponseTask GetAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Jobs/JobsClient.cs b/src/Auth0.ManagementApi/Jobs/JobsClient.cs index d2305a47c..a33514f6c 100644 --- a/src/Auth0.ManagementApi/Jobs/JobsClient.cs +++ b/src/Auth0.ManagementApi/Jobs/JobsClient.cs @@ -31,6 +31,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -43,6 +46,7 @@ private async Task> GetAsyncCore( { Method = HttpMethod.Get, Path = string.Format("jobs/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -60,7 +64,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -74,7 +78,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -87,15 +97,65 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -105,7 +165,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Jobs/UsersExports/UsersExportsClient.cs b/src/Auth0.ManagementApi/Jobs/UsersExports/UsersExportsClient.cs index 9b670ae17..a57b7e33a 100644 --- a/src/Auth0.ManagementApi/Jobs/UsersExports/UsersExportsClient.cs +++ b/src/Auth0.ManagementApi/Jobs/UsersExports/UsersExportsClient.cs @@ -19,6 +19,9 @@ private async Task> CreateAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -32,6 +35,7 @@ private async Task> CreateAsyn Method = HttpMethod.Post, Path = "jobs/users-exports", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -52,7 +56,7 @@ private async Task> CreateAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -66,7 +70,13 @@ private async Task> CreateAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -79,13 +89,53 @@ private async Task> CreateAsyn switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -95,7 +145,13 @@ private async Task> CreateAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Jobs/UsersImports/UsersImportsClient.cs b/src/Auth0.ManagementApi/Jobs/UsersImports/UsersImportsClient.cs index 9645b7277..e770e6868 100644 --- a/src/Auth0.ManagementApi/Jobs/UsersImports/UsersImportsClient.cs +++ b/src/Auth0.ManagementApi/Jobs/UsersImports/UsersImportsClient.cs @@ -19,6 +19,9 @@ private async Task> CreateAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -29,6 +32,7 @@ private async Task> CreateAsyn { Method = HttpMethod.Post, Path = "jobs/users-imports", + QueryString = _queryString, Headers = _headers, Options = options, }; @@ -53,7 +57,7 @@ private async Task> CreateAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -67,7 +71,13 @@ private async Task> CreateAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -80,17 +90,77 @@ private async Task> CreateAsyn switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 413: - throw new ContentTooLargeError(JsonUtils.Deserialize(responseBody)); + throw new ContentTooLargeError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 500: - throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + throw new InternalServerError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -100,7 +170,13 @@ private async Task> CreateAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Jobs/VerificationEmail/VerificationEmailClient.cs b/src/Auth0.ManagementApi/Jobs/VerificationEmail/VerificationEmailClient.cs index e404305f7..fe00909a5 100644 --- a/src/Auth0.ManagementApi/Jobs/VerificationEmail/VerificationEmailClient.cs +++ b/src/Auth0.ManagementApi/Jobs/VerificationEmail/VerificationEmailClient.cs @@ -19,6 +19,9 @@ private async Task> Crea CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -32,6 +35,7 @@ private async Task> Crea Method = HttpMethod.Post, Path = "jobs/verification-email", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -52,7 +56,7 @@ private async Task> Crea return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -66,7 +70,13 @@ private async Task> Crea "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -79,13 +89,53 @@ private async Task> Crea switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -95,7 +145,13 @@ private async Task> Crea throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Keys/CustomSigning/CustomSigningClient.cs b/src/Auth0.ManagementApi/Keys/CustomSigning/CustomSigningClient.cs index d25439285..40cc7d5b5 100644 --- a/src/Auth0.ManagementApi/Keys/CustomSigning/CustomSigningClient.cs +++ b/src/Auth0.ManagementApi/Keys/CustomSigning/CustomSigningClient.cs @@ -18,6 +18,9 @@ private async Task> GetAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -30,6 +33,7 @@ private async Task> GetAsyn { Method = HttpMethod.Get, Path = "keys/custom-signing", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -49,7 +53,7 @@ private async Task> GetAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -63,7 +67,13 @@ private async Task> GetAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -76,13 +86,53 @@ private async Task> GetAsyn switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -92,7 +142,13 @@ private async Task> GetAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -103,6 +159,9 @@ private async Task> SetAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -116,6 +175,7 @@ private async Task> SetAsyn Method = HttpMethod.Put, Path = "keys/custom-signing", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -136,7 +196,7 @@ private async Task> SetAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -150,7 +210,13 @@ private async Task> SetAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -163,13 +229,53 @@ private async Task> SetAsyn switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -179,7 +285,113 @@ private async Task> SetAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = "keys/custom-signing", + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -231,58 +443,11 @@ public WithRawResponseTask SetAsync( /// /// await client.Keys.CustomSigning.DeleteAsync(); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = "keys/custom-signing", - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/Keys/CustomSigning/ICustomSigningClient.cs b/src/Auth0.ManagementApi/Keys/CustomSigning/ICustomSigningClient.cs index 82f4d0528..35736cffa 100644 --- a/src/Auth0.ManagementApi/Keys/CustomSigning/ICustomSigningClient.cs +++ b/src/Auth0.ManagementApi/Keys/CustomSigning/ICustomSigningClient.cs @@ -24,5 +24,8 @@ WithRawResponseTask SetAsync( /// /// Delete entire jwks representation of custom signing keys. /// - Task DeleteAsync(RequestOptions? options = null, CancellationToken cancellationToken = default); + WithRawResponseTask DeleteAsync( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); } diff --git a/src/Auth0.ManagementApi/Keys/Encryption/EncryptionClient.cs b/src/Auth0.ManagementApi/Keys/Encryption/EncryptionClient.cs index b11a9de1d..975c51e07 100644 --- a/src/Auth0.ManagementApi/Keys/Encryption/EncryptionClient.cs +++ b/src/Auth0.ManagementApi/Keys/Encryption/EncryptionClient.cs @@ -77,7 +77,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -91,7 +91,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -104,13 +110,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -120,7 +166,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -131,6 +183,9 @@ private async Task> CreateAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -144,6 +199,7 @@ private async Task> CreateAs Method = HttpMethod.Post, Path = "keys/encryption", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -164,7 +220,7 @@ private async Task> CreateAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -178,7 +234,13 @@ private async Task> CreateAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -191,15 +253,165 @@ private async Task> CreateAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task RekeyAsyncCore( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Post, + Path = "keys/encryption/rekey", + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -209,7 +421,13 @@ private async Task> CreateAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -220,6 +438,9 @@ private async Task> GetAsyncCor CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -235,6 +456,7 @@ private async Task> GetAsyncCor "keys/encryption/{0}", ValueConvert.ToPathParameterString(kid) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -254,7 +476,7 @@ private async Task> GetAsyncCor return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -268,7 +490,13 @@ private async Task> GetAsyncCor "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -281,15 +509,65 @@ private async Task> GetAsyncCor switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -299,7 +577,13 @@ private async Task> GetAsyncCor throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -311,6 +595,9 @@ private async Task> ImportAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -327,6 +614,7 @@ private async Task> ImportAs ValueConvert.ToPathParameterString(kid) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -347,7 +635,7 @@ private async Task> ImportAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -361,7 +649,13 @@ private async Task> ImportAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -374,15 +668,65 @@ private async Task> ImportAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -392,7 +736,129 @@ private async Task> ImportAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string kid, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "keys/encryption/{0}", + ValueConvert.ToPathParameterString(kid) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -405,6 +871,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -420,6 +889,7 @@ private async Task< "keys/encryption/{0}/wrapping-key", ValueConvert.ToPathParameterString(kid) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -440,7 +910,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -454,7 +924,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -467,15 +943,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -485,7 +1011,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -562,59 +1094,12 @@ public WithRawResponseTask CreateAsync( /// /// await client.Keys.Encryption.RekeyAsync(); /// - public async Task RekeyAsync( + public WithRawResponseTask RekeyAsync( RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Post, - Path = "keys/encryption/rekey", - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(RekeyAsyncCore(options, cancellationToken)); } /// @@ -661,65 +1146,13 @@ public WithRawResponseTask ImportAsync( /// /// await client.Keys.Encryption.DeleteAsync("kid"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string kid, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "keys/encryption/{0}", - ValueConvert.ToPathParameterString(kid) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(kid, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Keys/Encryption/IEncryptionClient.cs b/src/Auth0.ManagementApi/Keys/Encryption/IEncryptionClient.cs index eaba81844..3239c1034 100644 --- a/src/Auth0.ManagementApi/Keys/Encryption/IEncryptionClient.cs +++ b/src/Auth0.ManagementApi/Keys/Encryption/IEncryptionClient.cs @@ -26,7 +26,10 @@ WithRawResponseTask CreateAsync( /// /// Perform rekeying operation on the key hierarchy. /// - Task RekeyAsync(RequestOptions? options = null, CancellationToken cancellationToken = default); + WithRawResponseTask RekeyAsync( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); /// /// Retrieve details of the encryption key with the given ID. @@ -50,7 +53,7 @@ WithRawResponseTask ImportAsync( /// /// Delete the custom provided encryption key with the given ID and move back to using native encryption key. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string kid, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Keys/Signing/SigningClient.cs b/src/Auth0.ManagementApi/Keys/Signing/SigningClient.cs index f9aaf9cb1..93af9b45a 100644 --- a/src/Auth0.ManagementApi/Keys/Signing/SigningClient.cs +++ b/src/Auth0.ManagementApi/Keys/Signing/SigningClient.cs @@ -18,6 +18,9 @@ private async Task>> ListAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -30,6 +33,7 @@ private async Task>> ListAsyncCore( { Method = HttpMethod.Get, Path = "keys/signing", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -47,7 +51,7 @@ private async Task>> ListAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -61,7 +65,13 @@ private async Task>> ListAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -74,13 +84,53 @@ private async Task>> ListAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -90,7 +140,13 @@ private async Task>> ListAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -100,6 +156,9 @@ private async Task> RotateAsyn CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -112,6 +171,7 @@ private async Task> RotateAsyn { Method = HttpMethod.Post, Path = "keys/signing/rotate", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -131,7 +191,7 @@ private async Task> RotateAsyn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -145,7 +205,13 @@ private async Task> RotateAsyn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -158,11 +224,41 @@ private async Task> RotateAsyn switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -172,7 +268,13 @@ private async Task> RotateAsyn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -183,6 +285,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -198,6 +303,7 @@ private async Task> GetAsyncCore( "keys/signing/{0}", ValueConvert.ToPathParameterString(kid) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -217,7 +323,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -231,7 +337,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -244,15 +356,65 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -262,7 +424,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -273,6 +441,9 @@ private async Task> RevokeAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -288,6 +459,7 @@ private async Task> RevokeAsy "keys/signing/{0}/revoke", ValueConvert.ToPathParameterString(kid) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -307,7 +479,7 @@ private async Task> RevokeAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -321,7 +493,13 @@ private async Task> RevokeAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -334,13 +512,53 @@ private async Task> RevokeAsy switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -350,7 +568,13 @@ private async Task> RevokeAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/LogStreams/ILogStreamsClient.cs b/src/Auth0.ManagementApi/LogStreams/ILogStreamsClient.cs index b55e2b0e5..f24ecc4ea 100644 --- a/src/Auth0.ManagementApi/LogStreams/ILogStreamsClient.cs +++ b/src/Auth0.ManagementApi/LogStreams/ILogStreamsClient.cs @@ -448,7 +448,7 @@ WithRawResponseTask GetAsync( /// /// Delete a log stream. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/LogStreams/LogStreamsClient.cs b/src/Auth0.ManagementApi/LogStreams/LogStreamsClient.cs index 597fa9da2..7d2681be7 100644 --- a/src/Auth0.ManagementApi/LogStreams/LogStreamsClient.cs +++ b/src/Auth0.ManagementApi/LogStreams/LogStreamsClient.cs @@ -17,6 +17,9 @@ private async Task>> ListAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -29,6 +32,7 @@ private async Task>> ListAs { Method = HttpMethod.Get, Path = "log-streams", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -48,7 +52,7 @@ private async Task>> ListAs return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -62,7 +66,13 @@ private async Task>> ListAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -75,13 +85,53 @@ private async Task>> ListAs switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -91,7 +141,13 @@ private async Task>> ListAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -102,6 +158,9 @@ private async Task> CreateAsyncC CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -115,6 +174,7 @@ private async Task> CreateAsyncC Method = HttpMethod.Post, Path = "log-streams", Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -134,7 +194,7 @@ private async Task> CreateAsyncC return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -148,7 +208,13 @@ private async Task> CreateAsyncC "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -161,15 +227,65 @@ private async Task> CreateAsyncC switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -179,7 +295,13 @@ private async Task> CreateAsyncC throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -190,6 +312,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -202,6 +327,7 @@ private async Task> GetAsyncCore( { Method = HttpMethod.Get, Path = string.Format("log-streams/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -221,7 +347,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -235,7 +361,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -248,13 +380,178 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format("log-streams/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -264,7 +561,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -276,6 +579,9 @@ private async Task> UpdateAsyncC CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -289,6 +595,7 @@ private async Task> UpdateAsyncC Method = HttpMethodExtensions.Patch, Path = string.Format("log-streams/{0}", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -309,7 +616,7 @@ private async Task> UpdateAsyncC return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -323,7 +630,13 @@ private async Task> UpdateAsyncC "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -336,13 +649,53 @@ private async Task> UpdateAsyncC switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -352,7 +705,13 @@ private async Task> UpdateAsyncC throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -836,64 +1195,13 @@ public WithRawResponseTask GetAsync( /// /// await client.LogStreams.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format("log-streams/{0}", ValueConvert.ToPathParameterString(id)), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Logs/LogsClient.cs b/src/Auth0.ManagementApi/Logs/LogsClient.cs index 5a022ee90..3908df81c 100644 --- a/src/Auth0.ManagementApi/Logs/LogsClient.cs +++ b/src/Auth0.ManagementApi/Logs/LogsClient.cs @@ -107,7 +107,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -121,7 +121,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -134,13 +140,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -150,7 +196,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -161,6 +213,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -173,6 +228,7 @@ private async Task> GetAsyncCore( { Method = HttpMethod.Get, Path = string.Format("logs/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -190,7 +246,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -204,7 +260,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -217,15 +279,65 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -235,7 +347,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/NetworkAcls/INetworkAclsClient.cs b/src/Auth0.ManagementApi/NetworkAcls/INetworkAclsClient.cs index 2ecbe96b1..5901cde11 100644 --- a/src/Auth0.ManagementApi/NetworkAcls/INetworkAclsClient.cs +++ b/src/Auth0.ManagementApi/NetworkAcls/INetworkAclsClient.cs @@ -16,7 +16,7 @@ Task> ListAsync( /// /// Create a new access control list for your client. /// - Task CreateAsync( + WithRawResponseTask CreateAsync( CreateNetworkAclRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -44,7 +44,7 @@ WithRawResponseTask SetAsync( /// /// Delete existing access control list for your client. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/NetworkAcls/NetworkAclsClient.cs b/src/Auth0.ManagementApi/NetworkAcls/NetworkAclsClient.cs index b9334af37..c0a343a6b 100644 --- a/src/Auth0.ManagementApi/NetworkAcls/NetworkAclsClient.cs +++ b/src/Auth0.ManagementApi/NetworkAcls/NetworkAclsClient.cs @@ -76,7 +76,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -90,7 +90,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -103,13 +109,192 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task CreateAsyncCore( + CreateNetworkAclRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Post, + Path = "network-acls", + Body = request, + QueryString = _queryString, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 409: + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 500: + throw new InternalServerError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -119,7 +304,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -130,6 +321,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -145,6 +339,7 @@ private async Task> GetAsyncCore( "network-acls/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -164,7 +359,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -178,7 +373,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -191,13 +392,53 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -207,7 +448,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -219,6 +466,9 @@ private async Task> SetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -235,6 +485,7 @@ private async Task> SetAsyncCore( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -255,7 +506,7 @@ private async Task> SetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -269,7 +520,13 @@ private async Task> SetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -282,15 +539,65 @@ private async Task> SetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -300,7 +607,141 @@ private async Task> SetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "network-acls/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -312,6 +753,9 @@ private async Task> UpdateAsync CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -328,6 +772,7 @@ private async Task> UpdateAsync ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -348,7 +793,7 @@ private async Task> UpdateAsync return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -362,7 +807,13 @@ private async Task> UpdateAsync "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -375,15 +826,65 @@ private async Task> UpdateAsync switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -393,7 +894,13 @@ private async Task> UpdateAsync throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -462,68 +969,13 @@ await ListInternalAsync(request, options, cancellationToken).WithRawResponse(), /// } /// ); /// - public async Task CreateAsync( + public WithRawResponseTask CreateAsync( CreateNetworkAclRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Post, - Path = "network-acls", - Body = request, - Headers = _headers, - ContentType = "application/json", - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - case 500: - throw new InternalServerError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(CreateAsyncCore(request, options, cancellationToken)); } /// @@ -579,67 +1031,13 @@ public WithRawResponseTask SetAsync( /// /// await client.NetworkAcls.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "network-acls/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Organizations/ClientGrants/ClientGrantsClient.cs b/src/Auth0.ManagementApi/Organizations/ClientGrants/ClientGrantsClient.cs index 6a6373bed..f311df820 100644 --- a/src/Auth0.ManagementApi/Organizations/ClientGrants/ClientGrantsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/ClientGrants/ClientGrantsClient.cs @@ -82,7 +82,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -96,7 +96,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,13 +115,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -125,7 +171,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -139,6 +191,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -155,6 +210,7 @@ private async Task< ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -176,7 +232,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -190,7 +246,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -203,17 +265,77 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -223,7 +345,143 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + string grantId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "organizations/{0}/client-grants/{1}", + ValueConvert.ToPathParameterString(id), + ValueConvert.ToPathParameterString(grantId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -299,68 +557,13 @@ public WithRawResponseTask Crea /// /// await client.Organizations.ClientGrants.DeleteAsync("id", "grant_id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, string grantId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "organizations/{0}/client-grants/{1}", - ValueConvert.ToPathParameterString(id), - ValueConvert.ToPathParameterString(grantId) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, grantId, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/Organizations/ClientGrants/IClientGrantsClient.cs b/src/Auth0.ManagementApi/Organizations/ClientGrants/IClientGrantsClient.cs index 6eb7860e6..ef4584a03 100644 --- a/src/Auth0.ManagementApi/Organizations/ClientGrants/IClientGrantsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/ClientGrants/IClientGrantsClient.cs @@ -19,7 +19,7 @@ WithRawResponseTask CreateAsync CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, string grantId, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Organizations/Connections/ConnectionsClient.cs b/src/Auth0.ManagementApi/Organizations/Connections/ConnectionsClient.cs index 8c1dbbc18..b3f055759 100644 --- a/src/Auth0.ManagementApi/Organizations/Connections/ConnectionsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Connections/ConnectionsClient.cs @@ -80,7 +80,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -94,7 +94,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -107,13 +113,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -123,7 +169,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -137,6 +189,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -153,6 +208,7 @@ private async Task< ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -174,7 +230,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -188,7 +244,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -201,17 +263,77 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -221,7 +343,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -233,6 +361,9 @@ private async Task> CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -249,6 +380,7 @@ private async Task> ValueConvert.ToPathParameterString(id), ValueConvert.ToPathParameterString(connectionId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -269,7 +401,7 @@ private async Task> return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -283,7 +415,13 @@ private async Task> "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -296,13 +434,159 @@ private async Task> switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + string connectionId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "organizations/{0}/connections/{1}", + ValueConvert.ToPathParameterString(id), + ValueConvert.ToPathParameterString(connectionId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -312,7 +596,13 @@ private async Task> throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -327,6 +617,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -344,6 +637,7 @@ private async Task< ValueConvert.ToPathParameterString(connectionId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -365,7 +659,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -379,7 +673,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -392,13 +692,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -408,7 +748,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -497,65 +843,16 @@ public WithRawResponseTask GetAsync /// /// await client.Organizations.Connections.DeleteAsync("id", "connection_id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, string connectionId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "organizations/{0}/connections/{1}", - ValueConvert.ToPathParameterString(id), - ValueConvert.ToPathParameterString(connectionId) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask( + DeleteAsyncCore(id, connectionId, options, cancellationToken) + ); } /// diff --git a/src/Auth0.ManagementApi/Organizations/Connections/IConnectionsClient.cs b/src/Auth0.ManagementApi/Organizations/Connections/IConnectionsClient.cs index 8851587eb..cae21784a 100644 --- a/src/Auth0.ManagementApi/Organizations/Connections/IConnectionsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Connections/IConnectionsClient.cs @@ -26,7 +26,7 @@ WithRawResponseTask GetAsync( CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, string connectionId, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Organizations/DiscoveryDomains/DiscoveryDomainsClient.cs b/src/Auth0.ManagementApi/Organizations/DiscoveryDomains/DiscoveryDomainsClient.cs index ed442be47..04b14c6af 100644 --- a/src/Auth0.ManagementApi/Organizations/DiscoveryDomains/DiscoveryDomainsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/DiscoveryDomains/DiscoveryDomainsClient.cs @@ -79,7 +79,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -93,7 +93,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -106,15 +112,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -124,7 +180,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -138,6 +200,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -154,6 +219,7 @@ private async Task< ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -175,7 +241,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -189,7 +255,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -202,17 +274,77 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -222,7 +354,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -236,6 +374,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -252,6 +393,7 @@ private async Task< ValueConvert.ToPathParameterString(id), ValueConvert.ToPathParameterString(discoveryDomain) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -272,7 +414,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -286,7 +428,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -299,15 +447,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -317,7 +515,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -329,6 +533,9 @@ private async Task() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -379,7 +587,13 @@ private async Task(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -410,7 +674,131 @@ private async Task DeleteAsyncCore( + string id, + string discoveryDomainId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "organizations/{0}/discovery-domains/{1}", + ValueConvert.ToPathParameterString(id), + ValueConvert.ToPathParameterString(discoveryDomainId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -425,6 +813,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -442,6 +833,7 @@ private async Task< ValueConvert.ToPathParameterString(discoveryDomainId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -463,7 +855,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -477,7 +869,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -490,9 +888,29 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -502,7 +920,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -618,67 +1042,16 @@ public WithRawResponseTask GetAsy /// /// await client.Organizations.DiscoveryDomains.DeleteAsync("id", "discovery_domain_id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, string discoveryDomainId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "organizations/{0}/discovery-domains/{1}", - ValueConvert.ToPathParameterString(id), - ValueConvert.ToPathParameterString(discoveryDomainId) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask( + DeleteAsyncCore(id, discoveryDomainId, options, cancellationToken) + ); } /// diff --git a/src/Auth0.ManagementApi/Organizations/DiscoveryDomains/IDiscoveryDomainsClient.cs b/src/Auth0.ManagementApi/Organizations/DiscoveryDomains/IDiscoveryDomainsClient.cs index ee89effd0..5ebbebb64 100644 --- a/src/Auth0.ManagementApi/Organizations/DiscoveryDomains/IDiscoveryDomainsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/DiscoveryDomains/IDiscoveryDomainsClient.cs @@ -51,7 +51,7 @@ WithRawResponseTask GetAsync( /// /// Remove a discovery domain from an organization. This action cannot be undone. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, string discoveryDomainId, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Organizations/EnabledConnections/EnabledConnectionsClient.cs b/src/Auth0.ManagementApi/Organizations/EnabledConnections/EnabledConnectionsClient.cs index 6169b54ed..0f44d11a5 100644 --- a/src/Auth0.ManagementApi/Organizations/EnabledConnections/EnabledConnectionsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/EnabledConnections/EnabledConnectionsClient.cs @@ -82,7 +82,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -96,7 +96,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,15 +115,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -127,7 +183,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -139,6 +201,9 @@ private async Task> Ad CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -155,6 +220,7 @@ private async Task> Ad ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -175,7 +241,7 @@ private async Task> Ad return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -189,7 +255,13 @@ private async Task> Ad "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -202,15 +274,65 @@ private async Task> Ad switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -220,7 +342,13 @@ private async Task> Ad throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -232,6 +360,9 @@ private async Task> Ge CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -248,6 +379,7 @@ private async Task> Ge ValueConvert.ToPathParameterString(id), ValueConvert.ToPathParameterString(connectionId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -267,7 +399,7 @@ private async Task> Ge return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -281,7 +413,13 @@ private async Task> Ge "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -294,13 +432,183 @@ private async Task> Ge switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + string connectionId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "organizations/{0}/enabled_connections/{1}", + ValueConvert.ToPathParameterString(id), + ValueConvert.ToPathParameterString(connectionId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -310,7 +618,13 @@ private async Task> Ge throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -325,6 +639,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -342,6 +659,7 @@ private async Task< ValueConvert.ToPathParameterString(connectionId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -363,7 +681,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -377,7 +695,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -390,15 +714,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -408,7 +782,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -512,69 +892,16 @@ public WithRawResponseTask GetAsync( /// /// await client.Organizations.EnabledConnections.DeleteAsync("id", "connectionId"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, string connectionId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "organizations/{0}/enabled_connections/{1}", - ValueConvert.ToPathParameterString(id), - ValueConvert.ToPathParameterString(connectionId) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask( + DeleteAsyncCore(id, connectionId, options, cancellationToken) + ); } /// diff --git a/src/Auth0.ManagementApi/Organizations/EnabledConnections/IEnabledConnectionsClient.cs b/src/Auth0.ManagementApi/Organizations/EnabledConnections/IEnabledConnectionsClient.cs index b8151e249..f6658330c 100644 --- a/src/Auth0.ManagementApi/Organizations/EnabledConnections/IEnabledConnectionsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/EnabledConnections/IEnabledConnectionsClient.cs @@ -42,7 +42,7 @@ WithRawResponseTask GetAsync( /// /// **Note**: This action does not remove the connection from your tenant. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, string connectionId, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Organizations/Groups/GroupsClient.cs b/src/Auth0.ManagementApi/Organizations/Groups/GroupsClient.cs index 8f2d7916c..d894f68aa 100644 --- a/src/Auth0.ManagementApi/Organizations/Groups/GroupsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Groups/GroupsClient.cs @@ -80,7 +80,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -94,7 +94,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -107,15 +113,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -125,7 +181,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Organizations/Groups/Roles/IRolesClient.cs b/src/Auth0.ManagementApi/Organizations/Groups/Roles/IRolesClient.cs index c9ff8d153..5637fc3b4 100644 --- a/src/Auth0.ManagementApi/Organizations/Groups/Roles/IRolesClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Groups/Roles/IRolesClient.cs @@ -19,7 +19,7 @@ Task> ListAsync( /// /// Assign one or more roles to a specified group in the context of an organization. /// - Task CreateAsync( + WithRawResponseTask CreateAsync( string organizationId, string groupId, CreateOrganizationGroupRolesRequestContent request, @@ -30,7 +30,7 @@ Task CreateAsync( /// /// Unassign one or more roles from a specified group in the context of an organization. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string organizationId, string groupId, DeleteOrganizationGroupRolesRequestContent request, diff --git a/src/Auth0.ManagementApi/Organizations/Groups/Roles/RolesClient.cs b/src/Auth0.ManagementApi/Organizations/Groups/Roles/RolesClient.cs index 3696ca37c..29a2f14be 100644 --- a/src/Auth0.ManagementApi/Organizations/Groups/Roles/RolesClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Groups/Roles/RolesClient.cs @@ -80,7 +80,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -94,7 +94,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -107,15 +113,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -125,75 +181,18 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Lists the roles assigned to the specified group in the context of an organization. - /// - /// - /// await client.Organizations.Groups.Roles.ListAsync( - /// "organization_id", - /// "group_id", - /// new ListOrganizationGroupRolesRequestParameters { From = "from", Take = 1 } - /// ); - /// - public async Task> ListAsync( - string organizationId, - string groupId, - ListOrganizationGroupRolesRequestParameters request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - if (request is not null) - { - request = request with { }; - } - var pager = await CursorPager< - ListOrganizationGroupRolesRequestParameters, - RequestOptions?, - ListOrganizationGroupRolesResponseContent, - string?, - Role - > - .CreateInstanceAsync( - request, - options, - async (request, options, cancellationToken) => - await ListInternalAsync( - organizationId, - groupId, - request, - options, - cancellationToken - ) - .WithRawResponse(), - (request, cursor) => - { - request.From = cursor; - }, - response => response.Next, - response => response.Roles?.ToList(), - cancellationToken - ) - .ConfigureAwait(false); - return pager; - } - - /// - /// Assign one or more roles to a specified group in the context of an organization. - /// - /// - /// await client.Organizations.Groups.Roles.CreateAsync( - /// "organization_id", - /// "group_id", - /// new CreateOrganizationGroupRolesRequestContent { Roles = new List<string>() { "roles" } } - /// ); - /// - public async Task CreateAsync( + private async Task CreateAsyncCore( string organizationId, string groupId, CreateOrganizationGroupRolesRequestContent request, @@ -201,6 +200,9 @@ public async Task CreateAsync( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -218,6 +220,7 @@ public async Task CreateAsync( ValueConvert.ToPathParameterString(groupId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -227,7 +230,12 @@ public async Task CreateAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -238,17 +246,77 @@ public async Task CreateAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -258,22 +326,18 @@ public async Task CreateAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Unassign one or more roles from a specified group in the context of an organization. - /// - /// - /// await client.Organizations.Groups.Roles.DeleteAsync( - /// "organization_id", - /// "group_id", - /// new DeleteOrganizationGroupRolesRequestContent { Roles = new List<string>() { "roles" } } - /// ); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string organizationId, string groupId, DeleteOrganizationGroupRolesRequestContent request, @@ -281,6 +345,9 @@ public async Task DeleteAsync( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -298,6 +365,7 @@ public async Task DeleteAsync( ValueConvert.ToPathParameterString(groupId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -307,7 +375,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -318,15 +391,65 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -336,8 +459,113 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Lists the roles assigned to the specified group in the context of an organization. + /// + /// + /// await client.Organizations.Groups.Roles.ListAsync( + /// "organization_id", + /// "group_id", + /// new ListOrganizationGroupRolesRequestParameters { From = "from", Take = 1 } + /// ); + /// + public async Task> ListAsync( + string organizationId, + string groupId, + ListOrganizationGroupRolesRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + if (request is not null) + { + request = request with { }; + } + var pager = await CursorPager< + ListOrganizationGroupRolesRequestParameters, + RequestOptions?, + ListOrganizationGroupRolesResponseContent, + string?, + Role + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await ListInternalAsync( + organizationId, + groupId, + request, + options, + cancellationToken + ) + .WithRawResponse(), + (request, cursor) => + { + request.From = cursor; + }, + response => response.Next, + response => response.Roles?.ToList(), + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } + + /// + /// Assign one or more roles to a specified group in the context of an organization. + /// + /// + /// await client.Organizations.Groups.Roles.CreateAsync( + /// "organization_id", + /// "group_id", + /// new CreateOrganizationGroupRolesRequestContent { Roles = new List<string>() { "roles" } } + /// ); + /// + public WithRawResponseTask CreateAsync( + string organizationId, + string groupId, + CreateOrganizationGroupRolesRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + CreateAsyncCore(organizationId, groupId, request, options, cancellationToken) + ); + } + + /// + /// Unassign one or more roles from a specified group in the context of an organization. + /// + /// + /// await client.Organizations.Groups.Roles.DeleteAsync( + /// "organization_id", + /// "group_id", + /// new DeleteOrganizationGroupRolesRequestContent { Roles = new List<string>() { "roles" } } + /// ); + /// + public WithRawResponseTask DeleteAsync( + string organizationId, + string groupId, + DeleteOrganizationGroupRolesRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + DeleteAsyncCore(organizationId, groupId, request, options, cancellationToken) + ); + } } diff --git a/src/Auth0.ManagementApi/Organizations/IOrganizationsClient.cs b/src/Auth0.ManagementApi/Organizations/IOrganizationsClient.cs index 459edcef0..38546c218 100644 --- a/src/Auth0.ManagementApi/Organizations/IOrganizationsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/IOrganizationsClient.cs @@ -12,6 +12,7 @@ public partial interface IOrganizationsClient public IInvitationsClient Invitations { get; } public Auth0.ManagementApi.Organizations.IMembersClient Members { get; } public Auth0.ManagementApi.Organizations.IGroupsClient Groups { get; } + public Auth0.ManagementApi.Organizations.Roles.IRolesClient Roles { get; } /// /// Retrieve detailed list of all Organizations available in your tenant. For more information, see Auth0 Organizations. @@ -70,7 +71,7 @@ WithRawResponseTask GetAsync( /// /// **Note**: Members are automatically disassociated from an Organization when it is deleted. However, this action does **not** delete these users from your tenant. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Organizations/Invitations/IInvitationsClient.cs b/src/Auth0.ManagementApi/Organizations/Invitations/IInvitationsClient.cs index 653b70739..2c87baeab 100644 --- a/src/Auth0.ManagementApi/Organizations/Invitations/IInvitationsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Invitations/IInvitationsClient.cs @@ -33,7 +33,7 @@ WithRawResponseTask GetAsync( CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, string invitationId, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Organizations/Invitations/InvitationsClient.cs b/src/Auth0.ManagementApi/Organizations/Invitations/InvitationsClient.cs index 03bff51c1..f8b6ab868 100644 --- a/src/Auth0.ManagementApi/Organizations/Invitations/InvitationsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Invitations/InvitationsClient.cs @@ -88,7 +88,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -102,7 +102,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -115,15 +121,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -133,7 +189,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -147,6 +209,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -163,6 +228,7 @@ private async Task< ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -184,7 +250,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -198,7 +264,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -211,15 +283,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -229,7 +351,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -286,7 +414,7 @@ private async Task> Ge return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -300,7 +428,13 @@ private async Task> Ge "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -313,15 +447,183 @@ private async Task> Ge switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + string invitationId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "organizations/{0}/invitations/{1}", + ValueConvert.ToPathParameterString(id), + ValueConvert.ToPathParameterString(invitationId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -331,7 +633,13 @@ private async Task> Ge throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -438,66 +746,15 @@ public WithRawResponseTask GetAsync( /// /// await client.Organizations.Invitations.DeleteAsync("id", "invitation_id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, string invitationId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "organizations/{0}/invitations/{1}", - ValueConvert.ToPathParameterString(id), - ValueConvert.ToPathParameterString(invitationId) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask( + DeleteAsyncCore(id, invitationId, options, cancellationToken) + ); } } diff --git a/src/Auth0.ManagementApi/Organizations/Members/EffectiveRoles/EffectiveRolesClient.cs b/src/Auth0.ManagementApi/Organizations/Members/EffectiveRoles/EffectiveRolesClient.cs index e271cc863..67a867bf4 100644 --- a/src/Auth0.ManagementApi/Organizations/Members/EffectiveRoles/EffectiveRolesClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Members/EffectiveRoles/EffectiveRolesClient.cs @@ -87,7 +87,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -101,7 +101,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -114,15 +120,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -132,7 +188,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Organizations/Members/EffectiveRoles/Sources/Groups/GroupsClient.cs b/src/Auth0.ManagementApi/Organizations/Members/EffectiveRoles/Sources/Groups/GroupsClient.cs index 699743e35..d8d1f416f 100644 --- a/src/Auth0.ManagementApi/Organizations/Members/EffectiveRoles/Sources/Groups/GroupsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Members/EffectiveRoles/Sources/Groups/GroupsClient.cs @@ -82,7 +82,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -96,7 +96,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,15 +115,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -127,7 +183,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Organizations/Members/IMembersClient.cs b/src/Auth0.ManagementApi/Organizations/Members/IMembersClient.cs index 21b97438b..860c152d6 100644 --- a/src/Auth0.ManagementApi/Organizations/Members/IMembersClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Members/IMembersClient.cs @@ -38,14 +38,14 @@ Task> ListAsync( /// /// To add a user to an Organization through this action, the user must already exist in your tenant. If a user does not yet exist, you can [invite them to create an account](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members), manually create them through the Auth0 Dashboard, or use the Management API. /// - Task CreateAsync( + WithRawResponseTask CreateAsync( string id, CreateOrganizationMemberRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, DeleteOrganizationMembersRequestContent request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Organizations/Members/MembersClient.cs b/src/Auth0.ManagementApi/Organizations/Members/MembersClient.cs index 6a3c3d233..68154550c 100644 --- a/src/Auth0.ManagementApi/Organizations/Members/MembersClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Members/MembersClient.cs @@ -106,7 +106,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -120,7 +120,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -133,15 +139,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -151,95 +207,27 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// List organization members. - /// This endpoint is subject to eventual consistency. New users may not be immediately included in the response and deleted users may not be immediately removed from it. - /// - /// - Use the `fields` parameter to optionally define the specific member details retrieved. If `fields` is left blank, all fields (except roles) are returned. - /// - Member roles are not sent by default. Use `fields=roles` to retrieve the roles assigned to each listed member. To use this parameter, you must include the `read:organization_member_roles` scope in the token. - /// - /// This endpoint supports two types of pagination: - /// - /// - Offset pagination - /// - Checkpoint pagination - /// - /// Checkpoint pagination must be used if you need to retrieve more than 1000 organization members. - /// - /// **Checkpoint Pagination** - /// - /// To search by checkpoint, use the following parameters: - from: Optional id from which to start selection. - take: The total amount of entries to retrieve when using the from parameter. Defaults to 50. Note: The first time you call this endpoint using Checkpoint Pagination, you should omit the `from` parameter. If there are more results, a `next` value will be included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, this indicates there are no more pages remaining. - /// - /// - /// await client.Organizations.Members.ListAsync( - /// "id", - /// new ListOrganizationMembersRequestParameters - /// { - /// From = "from", - /// Take = 1, - /// Fields = "fields", - /// IncludeFields = true, - /// } - /// ); - /// - public async Task> ListAsync( - string id, - ListOrganizationMembersRequestParameters request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - if (request is not null) - { - request = request with { }; - } - var pager = await CursorPager< - ListOrganizationMembersRequestParameters, - RequestOptions?, - ListOrganizationMembersPaginatedResponseContent, - string?, - OrganizationMember - > - .CreateInstanceAsync( - request, - options, - async (request, options, cancellationToken) => - await ListInternalAsync(id, request, options, cancellationToken) - .WithRawResponse(), - (request, cursor) => - { - request.From = cursor; - }, - response => response.Next, - response => response.Members?.ToList(), - cancellationToken - ) - .ConfigureAwait(false); - return pager; - } - - /// - /// Set one or more existing users as members of a specific [Organization](https://auth0.com/docs/manage-users/organizations). - /// - /// To add a user to an Organization through this action, the user must already exist in your tenant. If a user does not yet exist, you can [invite them to create an account](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members), manually create them through the Auth0 Dashboard, or use the Management API. - /// - /// - /// await client.Organizations.Members.CreateAsync( - /// "id", - /// new CreateOrganizationMemberRequestContent { Members = new List<string>() { "members" } } - /// ); - /// - public async Task CreateAsync( + private async Task CreateAsyncCore( string id, CreateOrganizationMemberRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -256,6 +244,7 @@ public async Task CreateAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -265,7 +254,12 @@ public async Task CreateAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -276,13 +270,53 @@ public async Task CreateAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -292,24 +326,27 @@ public async Task CreateAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// await client.Organizations.Members.DeleteAsync( - /// "id", - /// new DeleteOrganizationMembersRequestContent { Members = new List<string>() { "members" } } - /// ); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, DeleteOrganizationMembersRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -326,6 +363,7 @@ public async Task DeleteAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -335,7 +373,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -346,13 +389,53 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -362,8 +445,117 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// List organization members. + /// This endpoint is subject to eventual consistency. New users may not be immediately included in the response and deleted users may not be immediately removed from it. + /// + /// - Use the `fields` parameter to optionally define the specific member details retrieved. If `fields` is left blank, all fields (except roles) are returned. + /// - Member roles are not sent by default. Use `fields=roles` to retrieve the roles assigned to each listed member. To use this parameter, you must include the `read:organization_member_roles` scope in the token. + /// + /// This endpoint supports two types of pagination: + /// + /// - Offset pagination + /// - Checkpoint pagination + /// + /// Checkpoint pagination must be used if you need to retrieve more than 1000 organization members. + /// + /// **Checkpoint Pagination** + /// + /// To search by checkpoint, use the following parameters: - from: Optional id from which to start selection. - take: The total amount of entries to retrieve when using the from parameter. Defaults to 50. Note: The first time you call this endpoint using Checkpoint Pagination, you should omit the `from` parameter. If there are more results, a `next` value will be included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, this indicates there are no more pages remaining. + /// + /// + /// await client.Organizations.Members.ListAsync( + /// "id", + /// new ListOrganizationMembersRequestParameters + /// { + /// From = "from", + /// Take = 1, + /// Fields = "fields", + /// IncludeFields = true, + /// } + /// ); + /// + public async Task> ListAsync( + string id, + ListOrganizationMembersRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + if (request is not null) + { + request = request with { }; + } + var pager = await CursorPager< + ListOrganizationMembersRequestParameters, + RequestOptions?, + ListOrganizationMembersPaginatedResponseContent, + string?, + OrganizationMember + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await ListInternalAsync(id, request, options, cancellationToken) + .WithRawResponse(), + (request, cursor) => + { + request.From = cursor; + }, + response => response.Next, + response => response.Members?.ToList(), + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } + + /// + /// Set one or more existing users as members of a specific [Organization](https://auth0.com/docs/manage-users/organizations). + /// + /// To add a user to an Organization through this action, the user must already exist in your tenant. If a user does not yet exist, you can [invite them to create an account](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members), manually create them through the Auth0 Dashboard, or use the Management API. + /// + /// + /// await client.Organizations.Members.CreateAsync( + /// "id", + /// new CreateOrganizationMemberRequestContent { Members = new List<string>() { "members" } } + /// ); + /// + public WithRawResponseTask CreateAsync( + string id, + CreateOrganizationMemberRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(CreateAsyncCore(id, request, options, cancellationToken)); + } + + /// + /// await client.Organizations.Members.DeleteAsync( + /// "id", + /// new DeleteOrganizationMembersRequestContent { Members = new List<string>() { "members" } } + /// ); + /// + public WithRawResponseTask DeleteAsync( + string id, + DeleteOrganizationMembersRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, request, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Organizations/Members/Roles/IRolesClient.cs b/src/Auth0.ManagementApi/Organizations/Members/Roles/IRolesClient.cs index de515b06c..aa234f02b 100644 --- a/src/Auth0.ManagementApi/Organizations/Members/Roles/IRolesClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Members/Roles/IRolesClient.cs @@ -23,7 +23,7 @@ Task> ListAsync( /// /// 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. /// - Task AssignAsync( + WithRawResponseTask AssignAsync( string id, string userId, AssignOrganizationMemberRolesRequestContent request, @@ -36,7 +36,7 @@ Task AssignAsync( /// /// 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. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, string userId, DeleteOrganizationMemberRolesRequestContent request, diff --git a/src/Auth0.ManagementApi/Organizations/Members/Roles/RolesClient.cs b/src/Auth0.ManagementApi/Organizations/Members/Roles/RolesClient.cs index a16cf68fe..bed43dbf9 100644 --- a/src/Auth0.ManagementApi/Organizations/Members/Roles/RolesClient.cs +++ b/src/Auth0.ManagementApi/Organizations/Members/Roles/RolesClient.cs @@ -87,7 +87,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -101,7 +101,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -114,15 +120,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -132,78 +188,18 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Retrieve detailed list of roles assigned to a given user within the context of a specific Organization. - /// - /// Users can be members of multiple Organizations with unique roles assigned for each membership. This action only returns the roles associated with the specified Organization; any roles assigned to the user within other Organizations are not included. - /// - /// - /// await client.Organizations.Members.Roles.ListAsync( - /// "id", - /// "user_id", - /// new ListOrganizationMemberRolesRequestParameters - /// { - /// Page = 1, - /// PerPage = 1, - /// IncludeTotals = true, - /// } - /// ); - /// - public async Task> ListAsync( - string id, - string userId, - ListOrganizationMemberRolesRequestParameters request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - request = request with { }; - var pager = await OffsetPager< - ListOrganizationMemberRolesRequestParameters, - RequestOptions?, - ListOrganizationMemberRolesOffsetPaginatedResponseContent, - int?, - int?, - Role - > - .CreateInstanceAsync( - request, - options, - async (request, options, cancellationToken) => - await ListInternalAsync(id, userId, request, options, cancellationToken) - .WithRawResponse(), - request => request.Page.GetValueOrDefault(0), - (request, offset) => - { - request.Page = offset; - }, - null, - response => response.Roles?.ToList(), - null, - cancellationToken - ) - .ConfigureAwait(false); - return pager; - } - - /// - /// Assign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) 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. - /// - /// - /// await client.Organizations.Members.Roles.AssignAsync( - /// "id", - /// "user_id", - /// new AssignOrganizationMemberRolesRequestContent { Roles = new List<string>() { "roles" } } - /// ); - /// - public async Task AssignAsync( + private async Task AssignAsyncCore( string id, string userId, AssignOrganizationMemberRolesRequestContent request, @@ -211,6 +207,9 @@ public async Task AssignAsync( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -228,6 +227,7 @@ public async Task AssignAsync( ValueConvert.ToPathParameterString(userId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -237,7 +237,12 @@ public async Task AssignAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -248,15 +253,65 @@ public async Task AssignAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -266,24 +321,18 @@ public async Task AssignAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Remove one or more Organization-specific [roles](https://auth0.com/docs/manage-users/access-control/rbac) 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. - /// - /// - /// await client.Organizations.Members.Roles.DeleteAsync( - /// "id", - /// "user_id", - /// new DeleteOrganizationMemberRolesRequestContent { Roles = new List<string>() { "roles" } } - /// ); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, string userId, DeleteOrganizationMemberRolesRequestContent request, @@ -291,6 +340,9 @@ public async Task DeleteAsync( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -308,6 +360,7 @@ public async Task DeleteAsync( ValueConvert.ToPathParameterString(userId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -317,7 +370,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -328,13 +386,53 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -344,8 +442,118 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Retrieve detailed list of roles assigned to a given user within the context of a specific Organization. + /// + /// Users can be members of multiple Organizations with unique roles assigned for each membership. This action only returns the roles associated with the specified Organization; any roles assigned to the user within other Organizations are not included. + /// + /// + /// await client.Organizations.Members.Roles.ListAsync( + /// "id", + /// "user_id", + /// new ListOrganizationMemberRolesRequestParameters + /// { + /// Page = 1, + /// PerPage = 1, + /// IncludeTotals = true, + /// } + /// ); + /// + public async Task> ListAsync( + string id, + string userId, + ListOrganizationMemberRolesRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + request = request with { }; + var pager = await OffsetPager< + ListOrganizationMemberRolesRequestParameters, + RequestOptions?, + ListOrganizationMemberRolesOffsetPaginatedResponseContent, + int?, + int?, + Role + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await ListInternalAsync(id, userId, request, options, cancellationToken) + .WithRawResponse(), + request => request.Page.GetValueOrDefault(0), + (request, offset) => + { + request.Page = offset; + }, + null, + response => response.Roles?.ToList(), + null, + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } + + /// + /// Assign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) 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. + /// + /// + /// await client.Organizations.Members.Roles.AssignAsync( + /// "id", + /// "user_id", + /// new AssignOrganizationMemberRolesRequestContent { Roles = new List<string>() { "roles" } } + /// ); + /// + public WithRawResponseTask AssignAsync( + string id, + string userId, + AssignOrganizationMemberRolesRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + AssignAsyncCore(id, userId, request, options, cancellationToken) + ); + } + + /// + /// Remove one or more Organization-specific [roles](https://auth0.com/docs/manage-users/access-control/rbac) 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. + /// + /// + /// await client.Organizations.Members.Roles.DeleteAsync( + /// "id", + /// "user_id", + /// new DeleteOrganizationMemberRolesRequestContent { Roles = new List<string>() { "roles" } } + /// ); + /// + public WithRawResponseTask DeleteAsync( + string id, + string userId, + DeleteOrganizationMemberRolesRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + DeleteAsyncCore(id, userId, request, options, cancellationToken) + ); + } } diff --git a/src/Auth0.ManagementApi/Organizations/OrganizationsClient.cs b/src/Auth0.ManagementApi/Organizations/OrganizationsClient.cs index ff51385d5..e0166c962 100644 --- a/src/Auth0.ManagementApi/Organizations/OrganizationsClient.cs +++ b/src/Auth0.ManagementApi/Organizations/OrganizationsClient.cs @@ -18,6 +18,7 @@ internal OrganizationsClient(RawClient client) Invitations = new InvitationsClient(_client); Members = new Auth0.ManagementApi.Organizations.MembersClient(_client); Groups = new Auth0.ManagementApi.Organizations.GroupsClient(_client); + Roles = new Auth0.ManagementApi.Organizations.Roles.RolesClient(_client); } public Auth0.ManagementApi.Organizations.IClientGrantsClient ClientGrants { get; } @@ -34,6 +35,8 @@ internal OrganizationsClient(RawClient client) public Auth0.ManagementApi.Organizations.IGroupsClient Groups { get; } + public Auth0.ManagementApi.Organizations.Roles.IRolesClient Roles { get; } + /// /// Retrieve detailed list of all Organizations available in your tenant. For more information, see Auth0 Organizations. /// @@ -110,7 +113,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -124,7 +127,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -137,13 +146,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -153,7 +202,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -164,6 +219,9 @@ private async Task> CreateAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -177,6 +235,7 @@ private async Task> CreateAsy Method = HttpMethod.Post, Path = "organizations", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -197,7 +256,7 @@ private async Task> CreateAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -211,7 +270,13 @@ private async Task> CreateAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -224,15 +289,65 @@ private async Task> CreateAsy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -242,7 +357,13 @@ private async Task> CreateAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -253,6 +374,9 @@ private async Task> GetByN CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -268,6 +392,7 @@ private async Task> GetByN "organizations/name/{0}", ValueConvert.ToPathParameterString(name) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -287,7 +412,7 @@ private async Task> GetByN return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -301,7 +426,13 @@ private async Task> GetByN "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -314,15 +445,65 @@ private async Task> GetByN switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -332,7 +513,13 @@ private async Task> GetByN throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -343,6 +530,9 @@ private async Task> GetAsyncCore CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -358,6 +548,7 @@ private async Task> GetAsyncCore "organizations/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -377,7 +568,7 @@ private async Task> GetAsyncCore return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -391,7 +582,13 @@ private async Task> GetAsyncCore "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -404,15 +601,193 @@ private async Task> GetAsyncCore switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "organizations/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -422,7 +797,13 @@ private async Task> GetAsyncCore throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -434,6 +815,9 @@ private async Task> UpdateAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -450,6 +834,7 @@ private async Task> UpdateAsy ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -470,7 +855,7 @@ private async Task> UpdateAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -484,7 +869,13 @@ private async Task> UpdateAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -497,13 +888,53 @@ private async Task> UpdateAsy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -513,7 +944,13 @@ private async Task> UpdateAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -640,67 +1077,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Organizations.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "organizations/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Organizations/Requests/CreateOrganizationRequestContent.cs b/src/Auth0.ManagementApi/Organizations/Requests/CreateOrganizationRequestContent.cs index f83d6c79d..baabc61c5 100644 --- a/src/Auth0.ManagementApi/Organizations/Requests/CreateOrganizationRequestContent.cs +++ b/src/Auth0.ManagementApi/Organizations/Requests/CreateOrganizationRequestContent.cs @@ -38,6 +38,10 @@ public record CreateOrganizationRequestContent [JsonPropertyName("token_quota")] public CreateTokenQuota? TokenQuota { get; set; } + [Optional] + [JsonPropertyName("third_party_client_access")] + public OrganizationThirdPartyClientAccessEnum? ThirdPartyClientAccess { get; set; } + /// public override string ToString() { diff --git a/src/Auth0.ManagementApi/Organizations/Requests/UpdateOrganizationRequestContent.cs b/src/Auth0.ManagementApi/Organizations/Requests/UpdateOrganizationRequestContent.cs index f0dccdaa5..7289ebde4 100644 --- a/src/Auth0.ManagementApi/Organizations/Requests/UpdateOrganizationRequestContent.cs +++ b/src/Auth0.ManagementApi/Organizations/Requests/UpdateOrganizationRequestContent.cs @@ -32,6 +32,10 @@ public record UpdateOrganizationRequestContent [JsonPropertyName("token_quota")] public Optional TokenQuota { get; set; } + [Optional] + [JsonPropertyName("third_party_client_access")] + public OrganizationThirdPartyClientAccessEnum? ThirdPartyClientAccess { get; set; } + /// public override string ToString() { diff --git a/src/Auth0.ManagementApi/Organizations/Roles/IRolesClient.cs b/src/Auth0.ManagementApi/Organizations/Roles/IRolesClient.cs new file mode 100644 index 000000000..053c843a9 --- /dev/null +++ b/src/Auth0.ManagementApi/Organizations/Roles/IRolesClient.cs @@ -0,0 +1,6 @@ +namespace Auth0.ManagementApi.Organizations.Roles; + +public partial interface IRolesClient +{ + public IMembersClient Members { get; } +} diff --git a/src/Auth0.ManagementApi/Organizations/Roles/Members/IMembersClient.cs b/src/Auth0.ManagementApi/Organizations/Roles/Members/IMembersClient.cs new file mode 100644 index 000000000..f592efaab --- /dev/null +++ b/src/Auth0.ManagementApi/Organizations/Roles/Members/IMembersClient.cs @@ -0,0 +1,18 @@ +using Auth0.ManagementApi; +using Auth0.ManagementApi.Core; + +namespace Auth0.ManagementApi.Organizations.Roles; + +public partial interface IMembersClient +{ + /// + /// List the organization members assigned a specific role within the context of an organization. + /// + Task> ListAsync( + string id, + string roleId, + ListOrganizationRoleMembersRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/Auth0.ManagementApi/Organizations/Roles/Members/MembersClient.cs b/src/Auth0.ManagementApi/Organizations/Roles/Members/MembersClient.cs new file mode 100644 index 000000000..d0138cc35 --- /dev/null +++ b/src/Auth0.ManagementApi/Organizations/Roles/Members/MembersClient.cs @@ -0,0 +1,253 @@ +using Auth0.ManagementApi; +using Auth0.ManagementApi.Core; +using global::System.Text.Json; + +namespace Auth0.ManagementApi.Organizations.Roles; + +public partial class MembersClient : IMembersClient +{ + private readonly RawClient _client; + + internal MembersClient(RawClient client) + { + _client = client; + } + + /// + /// List the organization members assigned a specific role within the context of an organization. + /// + private WithRawResponseTask ListInternalAsync( + string id, + string roleId, + ListOrganizationRoleMembersRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + ListInternalAsyncCore(id, roleId, request, options, cancellationToken) + ); + } + + private async Task< + WithRawResponse + > ListInternalAsyncCore( + string id, + string roleId, + ListOrganizationRoleMembersRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 4) + .Add("from", request.From.IsDefined ? request.From.Value : null) + .Add("take", request.Take.IsDefined ? request.Take.Value : null) + .Add("fields", request.Fields.IsDefined ? request.Fields.Value : null) + .Add( + "include_fields", + request.IncludeFields.IsDefined ? request.IncludeFields.Value : null + ) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Get, + Path = string.Format( + "organizations/{0}/roles/{1}/members", + ValueConvert.ToPathParameterString(id), + ValueConvert.ToPathParameterString(roleId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = + JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new ManagementApiException( + "Failed to deserialize response", + response.StatusCode, + null, + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + /// + /// List the organization members assigned a specific role within the context of an organization. + /// + /// + /// await client.Organizations.Roles.Members.ListAsync( + /// "id", + /// "role_id", + /// new ListOrganizationRoleMembersRequestParameters + /// { + /// From = "from", + /// Take = 1, + /// Fields = "fields", + /// IncludeFields = true, + /// } + /// ); + /// + public async Task> ListAsync( + string id, + string roleId, + ListOrganizationRoleMembersRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + if (request is not null) + { + request = request with { }; + } + var pager = await CursorPager< + ListOrganizationRoleMembersRequestParameters, + RequestOptions?, + ListOrganizationRoleMembersResponseContent, + string?, + RoleMember + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await ListInternalAsync(id, roleId, request, options, cancellationToken) + .WithRawResponse(), + (request, cursor) => + { + request.From = cursor; + }, + response => response.Next, + response => response.Members?.ToList(), + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } +} diff --git a/src/Auth0.ManagementApi/Organizations/Roles/Members/Requests/ListOrganizationRoleMembersRequestParameters.cs b/src/Auth0.ManagementApi/Organizations/Roles/Members/Requests/ListOrganizationRoleMembersRequestParameters.cs new file mode 100644 index 000000000..426e3cdde --- /dev/null +++ b/src/Auth0.ManagementApi/Organizations/Roles/Members/Requests/ListOrganizationRoleMembersRequestParameters.cs @@ -0,0 +1,38 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi.Organizations.Roles; + +[Serializable] +public record ListOrganizationRoleMembersRequestParameters +{ + /// + /// Optional Id from which to start selection. + /// + [JsonIgnore] + public Optional From { get; set; } + + /// + /// Number of results per page. Defaults to 50. Values above the maximum permitted size are capped. + /// + [JsonIgnore] + public Optional Take { get; set; } = 50; + + /// + /// Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. + /// + [JsonIgnore] + public Optional Fields { get; set; } + + /// + /// Whether specified fields are to be included (true) or excluded (false). Defaults to true. + /// + [JsonIgnore] + public Optional IncludeFields { get; set; } = true; + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Organizations/Roles/RolesClient.cs b/src/Auth0.ManagementApi/Organizations/Roles/RolesClient.cs new file mode 100644 index 000000000..bede1ad3b --- /dev/null +++ b/src/Auth0.ManagementApi/Organizations/Roles/RolesClient.cs @@ -0,0 +1,16 @@ +using Auth0.ManagementApi.Core; + +namespace Auth0.ManagementApi.Organizations.Roles; + +public partial class RolesClient : IRolesClient +{ + private readonly RawClient _client; + + internal RolesClient(RawClient client) + { + _client = client; + Members = new MembersClient(_client); + } + + public IMembersClient Members { get; } +} diff --git a/src/Auth0.ManagementApi/Prompts/CustomText/CustomTextClient.cs b/src/Auth0.ManagementApi/Prompts/CustomText/CustomTextClient.cs index 1c2cb76f1..9310ff839 100644 --- a/src/Auth0.ManagementApi/Prompts/CustomText/CustomTextClient.cs +++ b/src/Auth0.ManagementApi/Prompts/CustomText/CustomTextClient.cs @@ -20,6 +20,9 @@ internal CustomTextClient(RawClient client) CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -36,6 +39,7 @@ internal CustomTextClient(RawClient client) ValueConvert.ToPathParameterString(prompt), ValueConvert.ToPathParameterString(language) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -55,7 +59,7 @@ internal CustomTextClient(RawClient client) return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -69,7 +73,13 @@ internal CustomTextClient(RawClient client) "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -82,15 +92,65 @@ internal CustomTextClient(RawClient client) switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -100,40 +160,18 @@ internal CustomTextClient(RawClient client) throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Retrieve custom text for a specific prompt and language. - /// - /// - /// await client.Prompts.CustomText.GetAsync(PromptGroupNameEnum.Login, PromptLanguageEnum.Am); - /// - public WithRawResponseTask> GetAsync( - PromptGroupNameEnum prompt, - PromptLanguageEnum language, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask>( - GetAsyncCore(prompt, language, options, cancellationToken) - ); - } - - /// - /// Set custom text for a specific prompt. Existing texts will be overwritten. - /// - /// - /// await client.Prompts.CustomText.SetAsync( - /// PromptGroupNameEnum.Login, - /// PromptLanguageEnum.Am, - /// new Dictionary<string, object?>() { { "key", "value" } } - /// ); - /// - public async Task SetAsync( + private async Task SetAsyncCore( PromptGroupNameEnum prompt, PromptLanguageEnum language, Dictionary request, @@ -141,6 +179,9 @@ public async Task SetAsync( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -158,6 +199,7 @@ public async Task SetAsync( ValueConvert.ToPathParameterString(language) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -166,7 +208,12 @@ public async Task SetAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -177,13 +224,53 @@ public async Task SetAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -193,8 +280,55 @@ public async Task SetAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Retrieve custom text for a specific prompt and language. + /// + /// + /// await client.Prompts.CustomText.GetAsync(PromptGroupNameEnum.Login, PromptLanguageEnum.Am); + /// + public WithRawResponseTask> GetAsync( + PromptGroupNameEnum prompt, + PromptLanguageEnum language, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask>( + GetAsyncCore(prompt, language, options, cancellationToken) + ); + } + + /// + /// Set custom text for a specific prompt. Existing texts will be overwritten. + /// + /// + /// await client.Prompts.CustomText.SetAsync( + /// PromptGroupNameEnum.Login, + /// PromptLanguageEnum.Am, + /// new Dictionary<string, object?>() { { "key", "value" } } + /// ); + /// + public WithRawResponseTask SetAsync( + PromptGroupNameEnum prompt, + PromptLanguageEnum language, + Dictionary request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + SetAsyncCore(prompt, language, request, options, cancellationToken) + ); + } } diff --git a/src/Auth0.ManagementApi/Prompts/CustomText/ICustomTextClient.cs b/src/Auth0.ManagementApi/Prompts/CustomText/ICustomTextClient.cs index f3c517f5d..24c91edc7 100644 --- a/src/Auth0.ManagementApi/Prompts/CustomText/ICustomTextClient.cs +++ b/src/Auth0.ManagementApi/Prompts/CustomText/ICustomTextClient.cs @@ -17,7 +17,7 @@ public partial interface ICustomTextClient /// /// Set custom text for a specific prompt. Existing texts will be overwritten. /// - Task SetAsync( + WithRawResponseTask SetAsync( PromptGroupNameEnum prompt, PromptLanguageEnum language, Dictionary request, diff --git a/src/Auth0.ManagementApi/Prompts/Partials/IPartialsClient.cs b/src/Auth0.ManagementApi/Prompts/Partials/IPartialsClient.cs index b412b6f56..788a87bb5 100644 --- a/src/Auth0.ManagementApi/Prompts/Partials/IPartialsClient.cs +++ b/src/Auth0.ManagementApi/Prompts/Partials/IPartialsClient.cs @@ -16,7 +16,7 @@ public partial interface IPartialsClient /// /// Set template partials for a prompt /// - Task SetAsync( + WithRawResponseTask SetAsync( PartialGroupsEnum prompt, Dictionary request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Prompts/Partials/PartialsClient.cs b/src/Auth0.ManagementApi/Prompts/Partials/PartialsClient.cs index 44c699bc7..f0cb05fcf 100644 --- a/src/Auth0.ManagementApi/Prompts/Partials/PartialsClient.cs +++ b/src/Auth0.ManagementApi/Prompts/Partials/PartialsClient.cs @@ -19,6 +19,9 @@ internal PartialsClient(RawClient client) CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -34,6 +37,7 @@ internal PartialsClient(RawClient client) "prompts/{0}/partials", ValueConvert.ToPathParameterString(prompt) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -53,7 +57,7 @@ internal PartialsClient(RawClient client) return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -67,7 +71,13 @@ internal PartialsClient(RawClient client) "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -80,15 +90,65 @@ internal PartialsClient(RawClient client) switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -98,44 +158,27 @@ internal PartialsClient(RawClient client) throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Get template partials for a prompt - /// - /// - /// await client.Prompts.Partials.GetAsync(PartialGroupsEnum.Login); - /// - public WithRawResponseTask> GetAsync( - PartialGroupsEnum prompt, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask>( - GetAsyncCore(prompt, options, cancellationToken) - ); - } - - /// - /// Set template partials for a prompt - /// - /// - /// await client.Prompts.Partials.SetAsync( - /// PartialGroupsEnum.Login, - /// new Dictionary<string, object?>() { { "key", "value" } } - /// ); - /// - public async Task SetAsync( + private async Task SetAsyncCore( PartialGroupsEnum prompt, Dictionary request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -152,6 +195,7 @@ public async Task SetAsync( ValueConvert.ToPathParameterString(prompt) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -160,7 +204,12 @@ public async Task SetAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -171,13 +220,53 @@ public async Task SetAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -187,8 +276,50 @@ public async Task SetAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Get template partials for a prompt + /// + /// + /// await client.Prompts.Partials.GetAsync(PartialGroupsEnum.Login); + /// + public WithRawResponseTask> GetAsync( + PartialGroupsEnum prompt, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask>( + GetAsyncCore(prompt, options, cancellationToken) + ); + } + + /// + /// Set template partials for a prompt + /// + /// + /// await client.Prompts.Partials.SetAsync( + /// PartialGroupsEnum.Login, + /// new Dictionary<string, object?>() { { "key", "value" } } + /// ); + /// + public WithRawResponseTask SetAsync( + PartialGroupsEnum prompt, + Dictionary request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(SetAsyncCore(prompt, request, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Prompts/PromptsClient.cs b/src/Auth0.ManagementApi/Prompts/PromptsClient.cs index cf956a3bf..ce2432957 100644 --- a/src/Auth0.ManagementApi/Prompts/PromptsClient.cs +++ b/src/Auth0.ManagementApi/Prompts/PromptsClient.cs @@ -27,6 +27,9 @@ private async Task> GetSettingsAsync CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -39,6 +42,7 @@ private async Task> GetSettingsAsync { Method = HttpMethod.Get, Path = "prompts", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -56,7 +60,7 @@ private async Task> GetSettingsAsync return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -70,7 +74,13 @@ private async Task> GetSettingsAsync "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -83,11 +93,41 @@ private async Task> GetSettingsAsync switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -97,7 +137,13 @@ private async Task> GetSettingsAsync throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -108,6 +154,9 @@ private async Task> UpdateSetting CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -121,6 +170,7 @@ private async Task> UpdateSetting Method = HttpMethodExtensions.Patch, Path = "prompts", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -141,7 +191,7 @@ private async Task> UpdateSetting return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -155,7 +205,13 @@ private async Task> UpdateSetting "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -168,13 +224,53 @@ private async Task> UpdateSetting switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -184,7 +280,13 @@ private async Task> UpdateSetting throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Prompts/Rendering/RenderingClient.cs b/src/Auth0.ManagementApi/Prompts/Rendering/RenderingClient.cs index 4d723ee55..64e0deb63 100644 --- a/src/Auth0.ManagementApi/Prompts/Rendering/RenderingClient.cs +++ b/src/Auth0.ManagementApi/Prompts/Rendering/RenderingClient.cs @@ -87,7 +87,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -101,7 +101,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -114,15 +120,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 402: - throw new PaymentRequiredError(JsonUtils.Deserialize(responseBody)); + throw new PaymentRequiredError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -132,7 +188,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -143,6 +205,9 @@ private async Task> BulkUpdateAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -156,6 +221,7 @@ private async Task> BulkUpdateAsy Method = HttpMethodExtensions.Patch, Path = "prompts/rendering", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -176,7 +242,7 @@ private async Task> BulkUpdateAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -190,7 +256,13 @@ private async Task> BulkUpdateAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -203,15 +275,65 @@ private async Task> BulkUpdateAsy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 402: - throw new PaymentRequiredError(JsonUtils.Deserialize(responseBody)); + throw new PaymentRequiredError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -221,7 +343,13 @@ private async Task> BulkUpdateAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -233,6 +361,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -249,6 +380,7 @@ private async Task> GetAsyncCore( ValueConvert.ToPathParameterString(prompt), ValueConvert.ToPathParameterString(screen) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -266,7 +398,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -280,7 +412,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -293,17 +431,77 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 402: - throw new PaymentRequiredError(JsonUtils.Deserialize(responseBody)); + throw new PaymentRequiredError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -313,7 +511,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -326,6 +530,9 @@ private async Task> UpdateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -343,6 +550,7 @@ private async Task> UpdateAsyncCore( ValueConvert.ToPathParameterString(screen) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -361,7 +569,7 @@ private async Task> UpdateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -375,7 +583,13 @@ private async Task> UpdateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -388,15 +602,65 @@ private async Task> UpdateAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 402: - throw new PaymentRequiredError(JsonUtils.Deserialize(responseBody)); + throw new PaymentRequiredError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -406,7 +670,13 @@ private async Task> UpdateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/RateLimitPolicies/IRateLimitPoliciesClient.cs b/src/Auth0.ManagementApi/RateLimitPolicies/IRateLimitPoliciesClient.cs index de5f94ed5..ae2790c03 100644 --- a/src/Auth0.ManagementApi/RateLimitPolicies/IRateLimitPoliciesClient.cs +++ b/src/Auth0.ManagementApi/RateLimitPolicies/IRateLimitPoliciesClient.cs @@ -22,7 +22,7 @@ WithRawResponseTask GetAsync( CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/RateLimitPolicies/RateLimitPoliciesClient.cs b/src/Auth0.ManagementApi/RateLimitPolicies/RateLimitPoliciesClient.cs index 8888ee424..81238106c 100644 --- a/src/Auth0.ManagementApi/RateLimitPolicies/RateLimitPoliciesClient.cs +++ b/src/Auth0.ManagementApi/RateLimitPolicies/RateLimitPoliciesClient.cs @@ -75,7 +75,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -89,7 +89,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -102,13 +108,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -118,7 +164,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -129,6 +181,9 @@ private async Task> Create CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -142,6 +197,7 @@ private async Task> Create Method = HttpMethod.Post, Path = "rate-limit-policies", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -162,7 +218,7 @@ private async Task> Create return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -176,7 +232,13 @@ private async Task> Create "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -189,15 +251,65 @@ private async Task> Create switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -207,7 +319,13 @@ private async Task> Create throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -218,6 +336,9 @@ private async Task> GetAsyncC CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -233,6 +354,7 @@ private async Task> GetAsyncC "rate-limit-policies/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -252,7 +374,7 @@ private async Task> GetAsyncC return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -266,7 +388,13 @@ private async Task> GetAsyncC "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -279,13 +407,169 @@ private async Task> GetAsyncC switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "rate-limit-policies/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -295,7 +579,13 @@ private async Task> GetAsyncC throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -307,6 +597,9 @@ private async Task> Update CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -323,6 +616,7 @@ private async Task> Update ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -343,7 +637,7 @@ private async Task> Update return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -357,7 +651,13 @@ private async Task> Update "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -370,15 +670,65 @@ private async Task> Update switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -388,7 +738,13 @@ private async Task> Update throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -481,65 +837,13 @@ public WithRawResponseTask GetAsync( /// /// await client.RateLimitPolicies.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "rate-limit-policies/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/RefreshTokens/IRefreshTokensClient.cs b/src/Auth0.ManagementApi/RefreshTokens/IRefreshTokensClient.cs index bc6ceb294..05615d306 100644 --- a/src/Auth0.ManagementApi/RefreshTokens/IRefreshTokensClient.cs +++ b/src/Auth0.ManagementApi/RefreshTokens/IRefreshTokensClient.cs @@ -16,7 +16,7 @@ Task> ListAsync( /// /// Revoke refresh tokens in bulk by ID list, user, user+client, or user+client+audience. /// - Task RevokeAsync( + WithRawResponseTask RevokeAsync( RevokeRefreshTokensRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -34,7 +34,7 @@ WithRawResponseTask GetAsync( /// /// Delete a refresh token by its ID. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/RefreshTokens/RefreshTokensClient.cs b/src/Auth0.ManagementApi/RefreshTokens/RefreshTokensClient.cs index 105549286..005b09572 100644 --- a/src/Auth0.ManagementApi/RefreshTokens/RefreshTokensClient.cs +++ b/src/Auth0.ManagementApi/RefreshTokens/RefreshTokensClient.cs @@ -78,7 +78,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -92,7 +92,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -105,15 +111,180 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task RevokeAsyncCore( + RevokeRefreshTokensRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Post, + Path = "refresh-tokens/revoke", + Body = request, + QueryString = _queryString, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -123,7 +294,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -134,6 +311,9 @@ private async Task> GetAsyncCore CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -149,6 +329,7 @@ private async Task> GetAsyncCore "refresh-tokens/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -168,7 +349,7 @@ private async Task> GetAsyncCore return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -182,7 +363,13 @@ private async Task> GetAsyncCore "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -195,15 +382,181 @@ private async Task> GetAsyncCore switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "refresh-tokens/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -213,7 +566,13 @@ private async Task> GetAsyncCore throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -225,6 +584,9 @@ private async Task> UpdateAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -241,6 +603,7 @@ private async Task> UpdateAsy ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -261,7 +624,7 @@ private async Task> UpdateAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -275,7 +638,13 @@ private async Task> UpdateAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -288,15 +657,65 @@ private async Task> UpdateAsy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -306,7 +725,13 @@ private async Task> UpdateAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -367,64 +792,13 @@ await ListInternalAsync(request, options, cancellationToken).WithRawResponse(), /// /// await client.RefreshTokens.RevokeAsync(new RevokeRefreshTokensRequestContent()); /// - public async Task RevokeAsync( + public WithRawResponseTask RevokeAsync( RevokeRefreshTokensRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Post, - Path = "refresh-tokens/revoke", - Body = request, - Headers = _headers, - ContentType = "application/json", - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(RevokeAsyncCore(request, options, cancellationToken)); } /// @@ -450,65 +824,13 @@ public WithRawResponseTask GetAsync( /// /// await client.RefreshTokens.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "refresh-tokens/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/ResourceServers/IResourceServersClient.cs b/src/Auth0.ManagementApi/ResourceServers/IResourceServersClient.cs index 8577ed01c..250865d37 100644 --- a/src/Auth0.ManagementApi/ResourceServers/IResourceServersClient.cs +++ b/src/Auth0.ManagementApi/ResourceServers/IResourceServersClient.cs @@ -35,7 +35,7 @@ WithRawResponseTask GetAsync( /// /// Delete an existing API by ID. For more information, read API Settings. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/ResourceServers/ResourceServersClient.cs b/src/Auth0.ManagementApi/ResourceServers/ResourceServersClient.cs index 7d92e028b..10dc27d94 100644 --- a/src/Auth0.ManagementApi/ResourceServers/ResourceServersClient.cs +++ b/src/Auth0.ManagementApi/ResourceServers/ResourceServersClient.cs @@ -81,7 +81,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -95,7 +95,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -108,13 +114,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -124,7 +170,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -135,6 +187,9 @@ private async Task> CreateA CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -148,6 +203,7 @@ private async Task> CreateA Method = HttpMethod.Post, Path = "resource-servers", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -168,7 +224,7 @@ private async Task> CreateA return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -182,7 +238,13 @@ private async Task> CreateA "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -195,15 +257,65 @@ private async Task> CreateA switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -213,7 +325,13 @@ private async Task> CreateA throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -267,7 +385,7 @@ private async Task> GetAsyncCo return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -281,7 +399,13 @@ private async Task> GetAsyncCo "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -294,15 +418,65 @@ private async Task> GetAsyncCo switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -312,7 +486,129 @@ private async Task> GetAsyncCo throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "resource-servers/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -324,6 +620,9 @@ private async Task> UpdateA CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -340,6 +639,7 @@ private async Task> UpdateA ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -360,7 +660,7 @@ private async Task> UpdateA return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -374,7 +674,13 @@ private async Task> UpdateA "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -387,15 +693,65 @@ private async Task> UpdateA switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -405,7 +761,13 @@ private async Task> UpdateA throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -505,65 +867,13 @@ public WithRawResponseTask GetAsync( /// /// await client.ResourceServers.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "resource-servers/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/RiskAssessments/Settings/NewDevice/NewDeviceClient.cs b/src/Auth0.ManagementApi/RiskAssessments/Settings/NewDevice/NewDeviceClient.cs index 166e4a241..ed54d67dd 100644 --- a/src/Auth0.ManagementApi/RiskAssessments/Settings/NewDevice/NewDeviceClient.cs +++ b/src/Auth0.ManagementApi/RiskAssessments/Settings/NewDevice/NewDeviceClient.cs @@ -17,6 +17,9 @@ private async Task< WithRawResponse > GetAsyncCore(RequestOptions? options = null, CancellationToken cancellationToken = default) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -29,6 +32,7 @@ private async Task< { Method = HttpMethod.Get, Path = "risk-assessments/settings/new-device", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -49,7 +53,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -63,7 +67,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -76,13 +86,53 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -92,7 +142,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -105,6 +161,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -118,6 +177,7 @@ private async Task< Method = HttpMethodExtensions.Patch, Path = "risk-assessments/settings/new-device", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -139,7 +199,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -153,7 +213,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -166,15 +232,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -184,7 +300,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/RiskAssessments/Settings/SettingsClient.cs b/src/Auth0.ManagementApi/RiskAssessments/Settings/SettingsClient.cs index 5b29d8f5f..580611ffd 100644 --- a/src/Auth0.ManagementApi/RiskAssessments/Settings/SettingsClient.cs +++ b/src/Auth0.ManagementApi/RiskAssessments/Settings/SettingsClient.cs @@ -22,6 +22,9 @@ private async Task> G CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -34,6 +37,7 @@ private async Task> G { Method = HttpMethod.Get, Path = "risk-assessments/settings", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -53,7 +57,7 @@ private async Task> G return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -67,7 +71,13 @@ private async Task> G "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -80,13 +90,53 @@ private async Task> G switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -96,7 +146,13 @@ private async Task> G throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,6 +165,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -122,6 +181,7 @@ private async Task< Method = HttpMethodExtensions.Patch, Path = "risk-assessments/settings", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -143,7 +203,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -157,7 +217,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -170,15 +236,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -188,7 +304,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Roles/Groups/GroupsClient.cs b/src/Auth0.ManagementApi/Roles/Groups/GroupsClient.cs index 8d0ff73bf..55ef0e7e6 100644 --- a/src/Auth0.ManagementApi/Roles/Groups/GroupsClient.cs +++ b/src/Auth0.ManagementApi/Roles/Groups/GroupsClient.cs @@ -75,7 +75,7 @@ private async Task> GetInternalAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -89,7 +89,13 @@ private async Task> GetInternalAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -102,15 +108,65 @@ private async Task> GetInternalAs switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -120,69 +176,27 @@ private async Task> GetInternalAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Lists the groups to which the specified role is assigned. - /// - /// - /// await client.Roles.Groups.GetAsync("id", new ListRoleGroupsParameters { From = "from", Take = 1 }); - /// - public async Task> GetAsync( - string id, - ListRoleGroupsParameters request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - if (request is not null) - { - request = request with { }; - } - var pager = await CursorPager< - ListRoleGroupsParameters, - RequestOptions?, - ListRoleGroupsResponseContent, - string?, - Group - > - .CreateInstanceAsync( - request, - options, - async (request, options, cancellationToken) => - await GetInternalAsync(id, request, options, cancellationToken) - .WithRawResponse(), - (request, cursor) => - { - request.From = cursor; - }, - response => response.Next, - response => response.Groups?.ToList(), - cancellationToken - ) - .ConfigureAwait(false); - return pager; - } - - /// - /// Assign one or more groups to a specified role. - /// - /// - /// await client.Roles.Groups.CreateAsync( - /// "id", - /// new AssignRoleGroupsRequestContent { Groups = new List<string>() { "groups" } } - /// ); - /// - public async Task CreateAsync( + private async Task CreateAsyncCore( string id, AssignRoleGroupsRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -199,6 +213,7 @@ public async Task CreateAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -208,7 +223,12 @@ public async Task CreateAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -219,15 +239,65 @@ public async Task CreateAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -237,27 +307,27 @@ public async Task CreateAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Unassign one or more groups from a specified role. - /// - /// - /// await client.Roles.Groups.DeleteAsync( - /// "id", - /// new DeleteRoleGroupsRequestContent { Groups = new List<string>() { "groups" } } - /// ); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, DeleteRoleGroupsRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -274,6 +344,7 @@ public async Task DeleteAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -283,7 +354,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -294,15 +370,65 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -312,8 +438,94 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Lists the groups to which the specified role is assigned. + /// + /// + /// await client.Roles.Groups.GetAsync("id", new ListRoleGroupsParameters { From = "from", Take = 1 }); + /// + public async Task> GetAsync( + string id, + ListRoleGroupsParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + if (request is not null) + { + request = request with { }; + } + var pager = await CursorPager< + ListRoleGroupsParameters, + RequestOptions?, + ListRoleGroupsResponseContent, + string?, + Group + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await GetInternalAsync(id, request, options, cancellationToken) + .WithRawResponse(), + (request, cursor) => + { + request.From = cursor; + }, + response => response.Next, + response => response.Groups?.ToList(), + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } + + /// + /// Assign one or more groups to a specified role. + /// + /// + /// await client.Roles.Groups.CreateAsync( + /// "id", + /// new AssignRoleGroupsRequestContent { Groups = new List<string>() { "groups" } } + /// ); + /// + public WithRawResponseTask CreateAsync( + string id, + AssignRoleGroupsRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(CreateAsyncCore(id, request, options, cancellationToken)); + } + + /// + /// Unassign one or more groups from a specified role. + /// + /// + /// await client.Roles.Groups.DeleteAsync( + /// "id", + /// new DeleteRoleGroupsRequestContent { Groups = new List<string>() { "groups" } } + /// ); + /// + public WithRawResponseTask DeleteAsync( + string id, + DeleteRoleGroupsRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, request, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Roles/Groups/IGroupsClient.cs b/src/Auth0.ManagementApi/Roles/Groups/IGroupsClient.cs index 282cd7af9..27ca2f126 100644 --- a/src/Auth0.ManagementApi/Roles/Groups/IGroupsClient.cs +++ b/src/Auth0.ManagementApi/Roles/Groups/IGroupsClient.cs @@ -18,7 +18,7 @@ Task> GetAsync( /// /// Assign one or more groups to a specified role. /// - Task CreateAsync( + WithRawResponseTask CreateAsync( string id, AssignRoleGroupsRequestContent request, RequestOptions? options = null, @@ -28,7 +28,7 @@ Task CreateAsync( /// /// Unassign one or more groups from a specified role. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, DeleteRoleGroupsRequestContent request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Roles/IRolesClient.cs b/src/Auth0.ManagementApi/Roles/IRolesClient.cs index 205929def..6a64e2caf 100644 --- a/src/Auth0.ManagementApi/Roles/IRolesClient.cs +++ b/src/Auth0.ManagementApi/Roles/IRolesClient.cs @@ -42,7 +42,7 @@ WithRawResponseTask GetAsync( /// /// Delete a specific [user role](https://auth0.com/docs/manage-users/access-control/rbac) from your tenant. Once deleted, it is removed from any user who was previously assigned that role. This action cannot be undone. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Roles/Permissions/IPermissionsClient.cs b/src/Auth0.ManagementApi/Roles/Permissions/IPermissionsClient.cs index 8e0fbd025..6fb8c7f1f 100644 --- a/src/Auth0.ManagementApi/Roles/Permissions/IPermissionsClient.cs +++ b/src/Auth0.ManagementApi/Roles/Permissions/IPermissionsClient.cs @@ -18,7 +18,7 @@ Task> ListAsync( /// /// Add one or more [permissions](https://auth0.com/docs/manage-users/access-control/configure-core-rbac/manage-permissions) to a specified user role. /// - Task AddAsync( + WithRawResponseTask AddAsync( string id, AddRolePermissionsRequestContent request, RequestOptions? options = null, @@ -28,7 +28,7 @@ Task AddAsync( /// /// Remove one or more [permissions](https://auth0.com/docs/manage-users/access-control/configure-core-rbac/manage-permissions) from a specified user role. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, DeleteRolePermissionsRequestContent request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Roles/Permissions/PermissionsClient.cs b/src/Auth0.ManagementApi/Roles/Permissions/PermissionsClient.cs index d2e68606c..5b0aba25e 100644 --- a/src/Auth0.ManagementApi/Roles/Permissions/PermissionsClient.cs +++ b/src/Auth0.ManagementApi/Roles/Permissions/PermissionsClient.cs @@ -82,7 +82,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -96,7 +96,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,15 +115,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -127,87 +183,27 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Retrieve detailed list (name, description, resource server) of permissions granted by a specified user role. - /// - /// - /// await client.Roles.Permissions.ListAsync( - /// "id", - /// new ListRolePermissionsRequestParameters - /// { - /// PerPage = 1, - /// Page = 1, - /// IncludeTotals = true, - /// } - /// ); - /// - public async Task> ListAsync( - string id, - ListRolePermissionsRequestParameters request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - request = request with { }; - var pager = await OffsetPager< - ListRolePermissionsRequestParameters, - RequestOptions?, - ListRolePermissionsOffsetPaginatedResponseContent, - int?, - int?, - PermissionsResponsePayload - > - .CreateInstanceAsync( - request, - options, - async (request, options, cancellationToken) => - await ListInternalAsync(id, request, options, cancellationToken) - .WithRawResponse(), - request => request.Page.GetValueOrDefault(0), - (request, offset) => - { - request.Page = offset; - }, - null, - response => response.Permissions?.ToList(), - null, - cancellationToken - ) - .ConfigureAwait(false); - return pager; - } - - /// - /// Add one or more [permissions](https://auth0.com/docs/manage-users/access-control/configure-core-rbac/manage-permissions) to a specified user role. - /// - /// - /// await client.Roles.Permissions.AddAsync( - /// "id", - /// new AddRolePermissionsRequestContent - /// { - /// Permissions = new List<PermissionRequestPayload>() - /// { - /// new PermissionRequestPayload - /// { - /// ResourceServerIdentifier = "resource_server_identifier", - /// PermissionName = "permission_name", - /// }, - /// }, - /// } - /// ); - /// - public async Task AddAsync( + private async Task AddAsyncCore( string id, AddRolePermissionsRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -224,6 +220,7 @@ public async Task AddAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -233,7 +230,12 @@ public async Task AddAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -244,15 +246,65 @@ public async Task AddAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -262,37 +314,27 @@ public async Task AddAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Remove one or more [permissions](https://auth0.com/docs/manage-users/access-control/configure-core-rbac/manage-permissions) from a specified user role. - /// - /// - /// await client.Roles.Permissions.DeleteAsync( - /// "id", - /// new DeleteRolePermissionsRequestContent - /// { - /// Permissions = new List<PermissionRequestPayload>() - /// { - /// new PermissionRequestPayload - /// { - /// ResourceServerIdentifier = "resource_server_identifier", - /// PermissionName = "permission_name", - /// }, - /// }, - /// } - /// ); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, DeleteRolePermissionsRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -309,6 +351,7 @@ public async Task DeleteAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -318,7 +361,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -329,13 +377,53 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -345,8 +433,122 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Retrieve detailed list (name, description, resource server) of permissions granted by a specified user role. + /// + /// + /// await client.Roles.Permissions.ListAsync( + /// "id", + /// new ListRolePermissionsRequestParameters + /// { + /// PerPage = 1, + /// Page = 1, + /// IncludeTotals = true, + /// } + /// ); + /// + public async Task> ListAsync( + string id, + ListRolePermissionsRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + request = request with { }; + var pager = await OffsetPager< + ListRolePermissionsRequestParameters, + RequestOptions?, + ListRolePermissionsOffsetPaginatedResponseContent, + int?, + int?, + PermissionsResponsePayload + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await ListInternalAsync(id, request, options, cancellationToken) + .WithRawResponse(), + request => request.Page.GetValueOrDefault(0), + (request, offset) => + { + request.Page = offset; + }, + null, + response => response.Permissions?.ToList(), + null, + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } + + /// + /// Add one or more [permissions](https://auth0.com/docs/manage-users/access-control/configure-core-rbac/manage-permissions) to a specified user role. + /// + /// + /// await client.Roles.Permissions.AddAsync( + /// "id", + /// new AddRolePermissionsRequestContent + /// { + /// Permissions = new List<PermissionRequestPayload>() + /// { + /// new PermissionRequestPayload + /// { + /// ResourceServerIdentifier = "resource_server_identifier", + /// PermissionName = "permission_name", + /// }, + /// }, + /// } + /// ); + /// + public WithRawResponseTask AddAsync( + string id, + AddRolePermissionsRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(AddAsyncCore(id, request, options, cancellationToken)); + } + + /// + /// Remove one or more [permissions](https://auth0.com/docs/manage-users/access-control/configure-core-rbac/manage-permissions) from a specified user role. + /// + /// + /// await client.Roles.Permissions.DeleteAsync( + /// "id", + /// new DeleteRolePermissionsRequestContent + /// { + /// Permissions = new List<PermissionRequestPayload>() + /// { + /// new PermissionRequestPayload + /// { + /// ResourceServerIdentifier = "resource_server_identifier", + /// PermissionName = "permission_name", + /// }, + /// }, + /// } + /// ); + /// + public WithRawResponseTask DeleteAsync( + string id, + DeleteRolePermissionsRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, request, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Roles/RolesClient.cs b/src/Auth0.ManagementApi/Roles/RolesClient.cs index d0d305abc..564954a81 100644 --- a/src/Auth0.ManagementApi/Roles/RolesClient.cs +++ b/src/Auth0.ManagementApi/Roles/RolesClient.cs @@ -87,7 +87,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -101,7 +101,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -114,13 +120,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -130,7 +176,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -141,6 +193,9 @@ private async Task> CreateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -154,6 +209,7 @@ private async Task> CreateAsyncCore( Method = HttpMethod.Post, Path = "roles", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -172,7 +228,7 @@ private async Task> CreateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -186,7 +242,13 @@ private async Task> CreateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -199,15 +261,65 @@ private async Task> CreateAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -217,7 +329,13 @@ private async Task> CreateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -228,6 +346,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -240,6 +361,7 @@ private async Task> GetAsyncCore( { Method = HttpMethod.Get, Path = string.Format("roles/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -257,7 +379,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -271,7 +393,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -284,15 +412,190 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format("roles/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -302,7 +605,13 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -314,6 +623,9 @@ private async Task> UpdateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -327,6 +639,7 @@ private async Task> UpdateAsyncCore( Method = HttpMethodExtensions.Patch, Path = string.Format("roles/{0}", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -345,7 +658,7 @@ private async Task> UpdateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -359,7 +672,13 @@ private async Task> UpdateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -372,13 +691,53 @@ private async Task> UpdateAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -388,7 +747,13 @@ private async Task> UpdateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -485,64 +850,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Roles.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format("roles/{0}", ValueConvert.ToPathParameterString(id)), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/Roles/Users/IUsersClient.cs b/src/Auth0.ManagementApi/Roles/Users/IUsersClient.cs index ac51c4ecf..dcf8e922b 100644 --- a/src/Auth0.ManagementApi/Roles/Users/IUsersClient.cs +++ b/src/Auth0.ManagementApi/Roles/Users/IUsersClient.cs @@ -36,7 +36,7 @@ Task> ListAsync( /// /// **Note**: New roles cannot be created through this action. /// - Task AssignAsync( + WithRawResponseTask AssignAsync( string id, AssignRoleUsersRequestContent request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Roles/Users/UsersClient.cs b/src/Auth0.ManagementApi/Roles/Users/UsersClient.cs index ee708c73b..42bb64360 100644 --- a/src/Auth0.ManagementApi/Roles/Users/UsersClient.cs +++ b/src/Auth0.ManagementApi/Roles/Users/UsersClient.cs @@ -90,7 +90,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -104,7 +104,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -117,15 +123,193 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task AssignAsyncCore( + string id, + AssignRoleUsersRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Post, + Path = string.Format("roles/{0}/users", ValueConvert.ToPathParameterString(id)), + Body = request, + QueryString = _queryString, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -135,7 +319,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -212,66 +402,13 @@ await ListInternalAsync(id, request, options, cancellationToken) /// new AssignRoleUsersRequestContent { Users = new List<string>() { "users" } } /// ); /// - public async Task AssignAsync( + public WithRawResponseTask AssignAsync( string id, AssignRoleUsersRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Post, - Path = string.Format("roles/{0}/users", ValueConvert.ToPathParameterString(id)), - Body = request, - Headers = _headers, - ContentType = "application/json", - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(AssignAsyncCore(id, request, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/Rules/IRulesClient.cs b/src/Auth0.ManagementApi/Rules/IRulesClient.cs index bc632bb69..2365d75d2 100644 --- a/src/Auth0.ManagementApi/Rules/IRulesClient.cs +++ b/src/Auth0.ManagementApi/Rules/IRulesClient.cs @@ -37,7 +37,7 @@ WithRawResponseTask GetAsync( /// /// Delete a rule. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Rules/RulesClient.cs b/src/Auth0.ManagementApi/Rules/RulesClient.cs index 74474a686..3ede89cb4 100644 --- a/src/Auth0.ManagementApi/Rules/RulesClient.cs +++ b/src/Auth0.ManagementApi/Rules/RulesClient.cs @@ -81,7 +81,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -95,7 +95,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -108,15 +114,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -126,7 +182,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -137,6 +199,9 @@ private async Task> CreateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -150,6 +215,7 @@ private async Task> CreateAsyncCore( Method = HttpMethod.Post, Path = "rules", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -168,7 +234,7 @@ private async Task> CreateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -182,7 +248,13 @@ private async Task> CreateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -195,15 +267,65 @@ private async Task> CreateAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -213,7 +335,13 @@ private async Task> CreateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -263,7 +391,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -277,7 +405,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -290,15 +424,65 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -308,7 +492,126 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format("rules/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -320,6 +623,9 @@ private async Task> UpdateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -333,6 +639,7 @@ private async Task> UpdateAsyncCore( Method = HttpMethodExtensions.Patch, Path = string.Format("rules/{0}", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -351,7 +658,7 @@ private async Task> UpdateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -365,7 +672,13 @@ private async Task> UpdateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -378,17 +691,77 @@ private async Task> UpdateAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -398,7 +771,13 @@ private async Task> UpdateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -499,62 +878,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Rules.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format("rules/{0}", ValueConvert.ToPathParameterString(id)), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/RulesConfigs/IRulesConfigsClient.cs b/src/Auth0.ManagementApi/RulesConfigs/IRulesConfigsClient.cs index 223a5e579..e69a68170 100644 --- a/src/Auth0.ManagementApi/RulesConfigs/IRulesConfigsClient.cs +++ b/src/Auth0.ManagementApi/RulesConfigs/IRulesConfigsClient.cs @@ -25,7 +25,7 @@ WithRawResponseTask SetAsync( /// /// Delete a rules config variable identified by its key. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string key, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/RulesConfigs/RulesConfigsClient.cs b/src/Auth0.ManagementApi/RulesConfigs/RulesConfigsClient.cs index 4f18989d8..2a94c8265 100644 --- a/src/Auth0.ManagementApi/RulesConfigs/RulesConfigsClient.cs +++ b/src/Auth0.ManagementApi/RulesConfigs/RulesConfigsClient.cs @@ -17,6 +17,9 @@ private async Task>> ListAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -29,6 +32,7 @@ private async Task>> ListAsyncCore( { Method = HttpMethod.Get, Path = "rules-configs", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -46,7 +50,7 @@ private async Task>> ListAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -60,7 +64,13 @@ private async Task>> ListAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -73,11 +83,41 @@ private async Task>> ListAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -87,7 +127,13 @@ private async Task>> ListAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -99,6 +145,9 @@ private async Task> SetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -115,6 +164,7 @@ private async Task> SetAsyncCore( ValueConvert.ToPathParameterString(key) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -135,7 +185,7 @@ private async Task> SetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -149,7 +199,13 @@ private async Task> SetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -162,11 +218,41 @@ private async Task> SetAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -176,59 +262,26 @@ private async Task> SetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Retrieve rules config variable keys. - /// - /// Note: For security, config variable values cannot be retrieved outside rule execution. - /// - /// - /// await client.RulesConfigs.ListAsync(); - /// - public WithRawResponseTask> ListAsync( - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask>( - ListAsyncCore(options, cancellationToken) - ); - } - - /// - /// Sets a rules config variable. - /// - /// - /// await client.RulesConfigs.SetAsync("key", new SetRulesConfigRequestContent { Value = "value" }); - /// - public WithRawResponseTask SetAsync( - string key, - SetRulesConfigRequestContent request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask( - SetAsyncCore(key, request, options, cancellationToken) - ); - } - - /// - /// Delete a rules config variable identified by its key. - /// - /// - /// await client.RulesConfigs.DeleteAsync("key"); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string key, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -244,6 +297,7 @@ public async Task DeleteAsync( "rules-configs/{0}", ValueConvert.ToPathParameterString(key) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -252,7 +306,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -263,11 +322,41 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -277,8 +366,65 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Retrieve rules config variable keys. + /// + /// Note: For security, config variable values cannot be retrieved outside rule execution. + /// + /// + /// await client.RulesConfigs.ListAsync(); + /// + public WithRawResponseTask> ListAsync( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask>( + ListAsyncCore(options, cancellationToken) + ); + } + + /// + /// Sets a rules config variable. + /// + /// + /// await client.RulesConfigs.SetAsync("key", new SetRulesConfigRequestContent { Value = "value" }); + /// + public WithRawResponseTask SetAsync( + string key, + SetRulesConfigRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + SetAsyncCore(key, request, options, cancellationToken) + ); + } + + /// + /// Delete a rules config variable identified by its key. + /// + /// + /// await client.RulesConfigs.DeleteAsync("key"); + /// + public WithRawResponseTask DeleteAsync( + string key, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(key, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/SelfServiceProfiles/CustomText/CustomTextClient.cs b/src/Auth0.ManagementApi/SelfServiceProfiles/CustomText/CustomTextClient.cs index 1a35e3048..8eecffac8 100644 --- a/src/Auth0.ManagementApi/SelfServiceProfiles/CustomText/CustomTextClient.cs +++ b/src/Auth0.ManagementApi/SelfServiceProfiles/CustomText/CustomTextClient.cs @@ -21,6 +21,9 @@ private async Task>> ListAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -38,6 +41,7 @@ private async Task>> ListAsyncCore( ValueConvert.ToPathParameterString(language), ValueConvert.ToPathParameterString(page) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -55,7 +59,7 @@ private async Task>> ListAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -69,7 +73,13 @@ private async Task>> ListAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -82,13 +92,53 @@ private async Task>> ListAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -98,7 +148,13 @@ private async Task>> ListAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -112,6 +168,9 @@ private async Task>> SetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -130,6 +189,7 @@ private async Task>> SetAsyncCore( ValueConvert.ToPathParameterString(page) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -147,7 +207,7 @@ private async Task>> SetAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -161,7 +221,13 @@ private async Task>> SetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -174,13 +240,53 @@ private async Task>> SetAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -190,7 +296,13 @@ private async Task>> SetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/SelfServiceProfiles/ISelfServiceProfilesClient.cs b/src/Auth0.ManagementApi/SelfServiceProfiles/ISelfServiceProfilesClient.cs index 04105ae61..808870707 100644 --- a/src/Auth0.ManagementApi/SelfServiceProfiles/ISelfServiceProfilesClient.cs +++ b/src/Auth0.ManagementApi/SelfServiceProfiles/ISelfServiceProfilesClient.cs @@ -38,7 +38,7 @@ WithRawResponseTask GetAsync( /// /// Deletes a self-service profile by Id. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/SelfServiceProfiles/SelfServiceProfilesClient.cs b/src/Auth0.ManagementApi/SelfServiceProfiles/SelfServiceProfilesClient.cs index e216a058c..6da7b4305 100644 --- a/src/Auth0.ManagementApi/SelfServiceProfiles/SelfServiceProfilesClient.cs +++ b/src/Auth0.ManagementApi/SelfServiceProfiles/SelfServiceProfilesClient.cs @@ -83,7 +83,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -97,7 +97,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -110,13 +116,53 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 500: - throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + throw new InternalServerError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -126,7 +172,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -137,6 +189,9 @@ private async Task> Cre CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -150,6 +205,7 @@ private async Task> Cre Method = HttpMethod.Post, Path = "self-service-profiles", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -170,7 +226,7 @@ private async Task> Cre return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -184,7 +240,13 @@ private async Task> Cre "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -197,17 +259,77 @@ private async Task> Cre switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 500: - throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + throw new InternalServerError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -217,7 +339,13 @@ private async Task> Cre throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -228,6 +356,9 @@ private async Task> GetAsy CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -243,6 +374,7 @@ private async Task> GetAsy "self-service-profiles/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -262,7 +394,7 @@ private async Task> GetAsy return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -276,7 +408,13 @@ private async Task> GetAsy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -289,17 +427,205 @@ private async Task> GetAsy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 500: + throw new InternalServerError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "self-service-profiles/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 500: - throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + throw new InternalServerError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -309,7 +635,13 @@ private async Task> GetAsy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -321,6 +653,9 @@ private async Task> Upd CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -337,6 +672,7 @@ private async Task> Upd ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -357,7 +693,7 @@ private async Task> Upd return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -371,7 +707,13 @@ private async Task> Upd "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -384,17 +726,77 @@ private async Task> Upd switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 500: - throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + throw new InternalServerError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -404,7 +806,13 @@ private async Task> Upd throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -498,67 +906,13 @@ public WithRawResponseTask GetAsync( /// /// await client.SelfServiceProfiles.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "self-service-profiles/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - case 500: - throw new InternalServerError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/SelfServiceProfiles/SsoTicket/ISsoTicketClient.cs b/src/Auth0.ManagementApi/SelfServiceProfiles/SsoTicket/ISsoTicketClient.cs index 44e98193c..32f751499 100644 --- a/src/Auth0.ManagementApi/SelfServiceProfiles/SsoTicket/ISsoTicketClient.cs +++ b/src/Auth0.ManagementApi/SelfServiceProfiles/SsoTicket/ISsoTicketClient.cs @@ -18,7 +18,7 @@ WithRawResponseTask CreateAsyn /// Revokes a Self-Service Enterprise Configuration access ticket and invalidates associated sessions. The ticket will no longer be accepted to initiate a Self-Service Enterprise Configuration session. If any users have already started a session through this ticket, their session will be terminated. Clients should expect a `202 Accepted` response upon successful processing, indicating that the request has been acknowledged and that the revocation is underway but may not be fully completed at the time of response. If the specified ticket does not exist, a `202 Accepted` response is also returned, signaling that no further action is required. /// Clients should treat these `202` responses as an acknowledgment that the request has been accepted and is in progress, even if the ticket was not found. /// - Task RevokeAsync( + WithRawResponseTask RevokeAsync( string profileId, string id, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/SelfServiceProfiles/SsoTicket/SsoTicketClient.cs b/src/Auth0.ManagementApi/SelfServiceProfiles/SsoTicket/SsoTicketClient.cs index fe485a91f..9956a6597 100644 --- a/src/Auth0.ManagementApi/SelfServiceProfiles/SsoTicket/SsoTicketClient.cs +++ b/src/Auth0.ManagementApi/SelfServiceProfiles/SsoTicket/SsoTicketClient.cs @@ -22,6 +22,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -38,6 +41,7 @@ private async Task< ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -59,7 +63,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -73,7 +77,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -86,15 +96,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -104,46 +164,27 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Creates an access ticket to initiate the Self-Service Enterprise Configuration flow using a self-service profile. - /// - /// - /// await client.SelfServiceProfiles.SsoTicket.CreateAsync( - /// "id", - /// new CreateSelfServiceProfileSsoTicketRequestContent() - /// ); - /// - public WithRawResponseTask CreateAsync( - string id, - CreateSelfServiceProfileSsoTicketRequestContent request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask( - CreateAsyncCore(id, request, options, cancellationToken) - ); - } - - /// - /// Revokes a Self-Service Enterprise Configuration access ticket and invalidates associated sessions. The ticket will no longer be accepted to initiate a Self-Service Enterprise Configuration session. If any users have already started a session through this ticket, their session will be terminated. Clients should expect a `202 Accepted` response upon successful processing, indicating that the request has been acknowledged and that the revocation is underway but may not be fully completed at the time of response. If the specified ticket does not exist, a `202 Accepted` response is also returned, signaling that no further action is required. - /// Clients should treat these `202` responses as an acknowledgment that the request has been accepted and is in progress, even if the ticket was not found. - /// - /// - /// await client.SelfServiceProfiles.SsoTicket.RevokeAsync("profileId", "id"); - /// - public async Task RevokeAsync( + private async Task RevokeAsyncCore( string profileId, string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -160,6 +201,7 @@ public async Task RevokeAsync( ValueConvert.ToPathParameterString(profileId), ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -168,7 +210,12 @@ public async Task RevokeAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -179,11 +226,41 @@ public async Task RevokeAsync( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -193,8 +270,52 @@ public async Task RevokeAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Creates an access ticket to initiate the Self-Service Enterprise Configuration flow using a self-service profile. + /// + /// + /// await client.SelfServiceProfiles.SsoTicket.CreateAsync( + /// "id", + /// new CreateSelfServiceProfileSsoTicketRequestContent() + /// ); + /// + public WithRawResponseTask CreateAsync( + string id, + CreateSelfServiceProfileSsoTicketRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + CreateAsyncCore(id, request, options, cancellationToken) + ); + } + + /// + /// Revokes a Self-Service Enterprise Configuration access ticket and invalidates associated sessions. The ticket will no longer be accepted to initiate a Self-Service Enterprise Configuration session. If any users have already started a session through this ticket, their session will be terminated. Clients should expect a `202 Accepted` response upon successful processing, indicating that the request has been acknowledged and that the revocation is underway but may not be fully completed at the time of response. If the specified ticket does not exist, a `202 Accepted` response is also returned, signaling that no further action is required. + /// Clients should treat these `202` responses as an acknowledgment that the request has been accepted and is in progress, even if the ticket was not found. + /// + /// + /// await client.SelfServiceProfiles.SsoTicket.RevokeAsync("profileId", "id"); + /// + public WithRawResponseTask RevokeAsync( + string profileId, + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(RevokeAsyncCore(profileId, id, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Sessions/ISessionsClient.cs b/src/Auth0.ManagementApi/Sessions/ISessionsClient.cs index 2fc053bc4..7e1087f24 100644 --- a/src/Auth0.ManagementApi/Sessions/ISessionsClient.cs +++ b/src/Auth0.ManagementApi/Sessions/ISessionsClient.cs @@ -14,7 +14,7 @@ WithRawResponseTask GetAsync( /// /// Delete a session by ID. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -33,7 +33,7 @@ WithRawResponseTask UpdateAsync( /// /// Revokes a session by ID and all associated refresh tokens. /// - Task RevokeAsync( + WithRawResponseTask RevokeAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Sessions/SessionsClient.cs b/src/Auth0.ManagementApi/Sessions/SessionsClient.cs index 182fb93b7..21f978da0 100644 --- a/src/Auth0.ManagementApi/Sessions/SessionsClient.cs +++ b/src/Auth0.ManagementApi/Sessions/SessionsClient.cs @@ -18,6 +18,9 @@ private async Task> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -30,6 +33,7 @@ private async Task> GetAsyncCore( { Method = HttpMethod.Get, Path = string.Format("sessions/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -47,7 +51,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -61,7 +65,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -74,13 +84,53 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -90,7 +140,126 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format("sessions/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -102,6 +271,9 @@ private async Task> UpdateAsyncCor CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -115,6 +287,7 @@ private async Task> UpdateAsyncCor Method = HttpMethodExtensions.Patch, Path = string.Format("sessions/{0}", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -135,7 +308,7 @@ private async Task> UpdateAsyncCor return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -149,7 +322,13 @@ private async Task> UpdateAsyncCor "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -162,15 +341,65 @@ private async Task> UpdateAsyncCor switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -180,40 +409,26 @@ private async Task> UpdateAsyncCor throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Retrieve session information. - /// - /// - /// await client.Sessions.GetAsync("id"); - /// - public WithRawResponseTask GetAsync( - string id, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask( - GetAsyncCore(id, options, cancellationToken) - ); - } - - /// - /// Delete a session by ID. - /// - /// - /// await client.Sessions.DeleteAsync("id"); - /// - public async Task DeleteAsync( + private async Task RevokeAsyncCore( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -224,8 +439,12 @@ public async Task DeleteAsync( .SendRequestAsync( new JsonRequest { - Method = HttpMethod.Delete, - Path = string.Format("sessions/{0}", ValueConvert.ToPathParameterString(id)), + Method = HttpMethod.Post, + Path = string.Format( + "sessions/{0}/revoke", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -234,7 +453,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -245,13 +469,65 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -261,11 +537,49 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + /// + /// Retrieve session information. + /// + /// + /// await client.Sessions.GetAsync("id"); + /// + public WithRawResponseTask GetAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + GetAsyncCore(id, options, cancellationToken) + ); + } + + /// + /// Delete a session by ID. + /// + /// + /// await client.Sessions.DeleteAsync("id"); + /// + public WithRawResponseTask DeleteAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); + } + /// /// Update session information. /// @@ -290,66 +604,12 @@ public WithRawResponseTask UpdateAsync( /// /// await client.Sessions.RevokeAsync("id"); /// - public async Task RevokeAsync( + public WithRawResponseTask RevokeAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Post, - Path = string.Format( - "sessions/{0}/revoke", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(RevokeAsyncCore(id, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/Stats/StatsClient.cs b/src/Auth0.ManagementApi/Stats/StatsClient.cs index 8e229e4be..932b87b37 100644 --- a/src/Auth0.ManagementApi/Stats/StatsClient.cs +++ b/src/Auth0.ManagementApi/Stats/StatsClient.cs @@ -17,6 +17,9 @@ private async Task> GetActiveUsersCountAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -29,6 +32,7 @@ private async Task> GetActiveUsersCountAsyncCore( { Method = HttpMethod.Get, Path = "stats/active-users", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -46,7 +50,7 @@ private async Task> GetActiveUsersCountAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -60,7 +64,13 @@ private async Task> GetActiveUsersCountAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -73,11 +83,41 @@ private async Task> GetActiveUsersCountAsyncCore( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -87,7 +127,13 @@ private async Task> GetActiveUsersCountAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -133,7 +179,7 @@ private async Task>> GetDailyAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -147,7 +193,13 @@ private async Task>> GetDailyAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -160,13 +212,53 @@ private async Task>> GetDailyAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -176,7 +268,13 @@ private async Task>> GetDailyAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/SupplementalSignals/SupplementalSignalsClient.cs b/src/Auth0.ManagementApi/SupplementalSignals/SupplementalSignalsClient.cs index 12fa6e9d3..43067a792 100644 --- a/src/Auth0.ManagementApi/SupplementalSignals/SupplementalSignalsClient.cs +++ b/src/Auth0.ManagementApi/SupplementalSignals/SupplementalSignalsClient.cs @@ -17,6 +17,9 @@ private async Task> GetAs CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -29,6 +32,7 @@ private async Task> GetAs { Method = HttpMethod.Get, Path = "supplemental-signals", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -48,7 +52,7 @@ private async Task> GetAs return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -62,7 +66,13 @@ private async Task> GetAs "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -75,13 +85,53 @@ private async Task> GetAs switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -91,7 +141,13 @@ private async Task> GetAs throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -102,6 +158,9 @@ private async Task> Pat CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -115,6 +174,7 @@ private async Task> Pat Method = HttpMethodExtensions.Patch, Path = "supplemental-signals", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -135,7 +195,7 @@ private async Task> Pat return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -149,7 +209,13 @@ private async Task> Pat "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -162,13 +228,53 @@ private async Task> Pat switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -178,7 +284,13 @@ private async Task> Pat throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Tenants/Settings/SettingsClient.cs b/src/Auth0.ManagementApi/Tenants/Settings/SettingsClient.cs index 5d666b633..6bae474f2 100644 --- a/src/Auth0.ManagementApi/Tenants/Settings/SettingsClient.cs +++ b/src/Auth0.ManagementApi/Tenants/Settings/SettingsClient.cs @@ -59,7 +59,7 @@ private async Task> GetAsyncCo return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -73,7 +73,13 @@ private async Task> GetAsyncCo "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -86,13 +92,53 @@ private async Task> GetAsyncCo switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -102,7 +148,13 @@ private async Task> GetAsyncCo throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -113,6 +165,9 @@ private async Task> UpdateA CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -126,6 +181,7 @@ private async Task> UpdateA Method = HttpMethodExtensions.Patch, Path = "tenants/settings", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -146,7 +202,7 @@ private async Task> UpdateA return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -160,7 +216,13 @@ private async Task> UpdateA "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -173,13 +235,53 @@ private async Task> UpdateA switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -189,7 +291,13 @@ private async Task> UpdateA throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Tickets/TicketsClient.cs b/src/Auth0.ManagementApi/Tickets/TicketsClient.cs index e40dafb0e..19e2ae800 100644 --- a/src/Auth0.ManagementApi/Tickets/TicketsClient.cs +++ b/src/Auth0.ManagementApi/Tickets/TicketsClient.cs @@ -18,6 +18,9 @@ private async Task> VerifyEmai CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -31,6 +34,7 @@ private async Task> VerifyEmai Method = HttpMethod.Post, Path = "tickets/email-verification", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -51,7 +55,7 @@ private async Task> VerifyEmai return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -65,7 +69,13 @@ private async Task> VerifyEmai "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -78,15 +88,65 @@ private async Task> VerifyEmai switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -96,7 +156,13 @@ private async Task> VerifyEmai throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,6 +175,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -122,6 +191,7 @@ private async Task< Method = HttpMethod.Post, Path = "tickets/password-change", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -142,7 +212,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -156,7 +226,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -169,15 +245,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -187,7 +313,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/TokenExchangeProfiles/ITokenExchangeProfilesClient.cs b/src/Auth0.ManagementApi/TokenExchangeProfiles/ITokenExchangeProfilesClient.cs index 9ace913fb..740bdfc49 100644 --- a/src/Auth0.ManagementApi/TokenExchangeProfiles/ITokenExchangeProfilesClient.cs +++ b/src/Auth0.ManagementApi/TokenExchangeProfiles/ITokenExchangeProfilesClient.cs @@ -49,7 +49,7 @@ WithRawResponseTask GetAsync( /// /// By using this feature, you agree to the applicable Free Trial terms in [Okta's Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user's subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -60,7 +60,7 @@ Task DeleteAsync( /// /// By using this feature, you agree to the applicable Free Trial terms in [Okta's Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user's subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details. /// - Task UpdateAsync( + WithRawResponseTask UpdateAsync( string id, UpdateTokenExchangeProfileRequestContent request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/TokenExchangeProfiles/TokenExchangeProfilesClient.cs b/src/Auth0.ManagementApi/TokenExchangeProfiles/TokenExchangeProfilesClient.cs index 686a38c7d..c18b2bbfb 100644 --- a/src/Auth0.ManagementApi/TokenExchangeProfiles/TokenExchangeProfilesClient.cs +++ b/src/Auth0.ManagementApi/TokenExchangeProfiles/TokenExchangeProfilesClient.cs @@ -80,7 +80,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -94,7 +94,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -107,13 +113,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -123,7 +169,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -134,6 +186,9 @@ private async Task> C CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -147,6 +202,7 @@ private async Task> C Method = HttpMethod.Post, Path = "token-exchange-profiles", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -167,7 +223,7 @@ private async Task> C return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -181,7 +237,13 @@ private async Task> C "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -194,15 +256,65 @@ private async Task> C switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -212,7 +324,13 @@ private async Task> C throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -223,6 +341,9 @@ private async Task> GetA CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -238,6 +359,7 @@ private async Task> GetA "token-exchange-profiles/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -257,7 +379,7 @@ private async Task> GetA return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -271,7 +393,13 @@ private async Task> GetA "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -284,15 +412,65 @@ private async Task> GetA switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -302,7 +480,260 @@ private async Task> GetA throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "token-exchange-profiles/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task UpdateAsyncCore( + string id, + UpdateTokenExchangeProfileRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethodExtensions.Patch, + Path = string.Format( + "token-exchange-profiles/{0}", + ValueConvert.ToPathParameterString(id) + ), + Body = request, + QueryString = _queryString, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 409: + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -412,63 +843,13 @@ public WithRawResponseTask GetAsync( /// /// await client.TokenExchangeProfiles.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "token-exchange-profiles/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// @@ -482,71 +863,13 @@ public async Task DeleteAsync( /// new UpdateTokenExchangeProfileRequestContent() /// ); /// - public async Task UpdateAsync( + public WithRawResponseTask UpdateAsync( string id, UpdateTokenExchangeProfileRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethodExtensions.Patch, - Path = string.Format( - "token-exchange-profiles/{0}", - ValueConvert.ToPathParameterString(id) - ), - Body = request, - Headers = _headers, - ContentType = "application/json", - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(UpdateAsyncCore(id, request, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/Types/ClientTokenVaultPrivilegedAccessWithCredentialId.cs b/src/Auth0.ManagementApi/Types/ClientTokenVaultPrivilegedAccessWithCredentialId.cs index dfeb7e06c..486e8eae6 100644 --- a/src/Auth0.ManagementApi/Types/ClientTokenVaultPrivilegedAccessWithCredentialId.cs +++ b/src/Auth0.ManagementApi/Types/ClientTokenVaultPrivilegedAccessWithCredentialId.cs @@ -21,6 +21,10 @@ public record ClientTokenVaultPrivilegedAccessWithCredentialId : IJsonOnDeserial [JsonPropertyName("ip_allowlist")] public IEnumerable? IpAllowlist { get; set; } + [Optional] + [JsonPropertyName("grants")] + public IEnumerable? Grants { get; set; } + [JsonIgnore] public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/ClientTokenVaultPrivilegedAccessWithPublicKey.cs b/src/Auth0.ManagementApi/Types/ClientTokenVaultPrivilegedAccessWithPublicKey.cs index 454861919..6b14a7db6 100644 --- a/src/Auth0.ManagementApi/Types/ClientTokenVaultPrivilegedAccessWithPublicKey.cs +++ b/src/Auth0.ManagementApi/Types/ClientTokenVaultPrivilegedAccessWithPublicKey.cs @@ -22,6 +22,10 @@ public record ClientTokenVaultPrivilegedAccessWithPublicKey : IJsonOnDeserialize [JsonPropertyName("ip_allowlist")] public IEnumerable? IpAllowlist { get; set; } + [Optional] + [JsonPropertyName("grants")] + public IEnumerable? Grants { get; set; } + [JsonIgnore] public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/ConnectionPropertiesOptions.cs b/src/Auth0.ManagementApi/Types/ConnectionPropertiesOptions.cs index ce530079b..fdda884e0 100644 --- a/src/Auth0.ManagementApi/Types/ConnectionPropertiesOptions.cs +++ b/src/Auth0.ManagementApi/Types/ConnectionPropertiesOptions.cs @@ -186,6 +186,14 @@ public Optional DiscoveryUrl { get; set; } + + [Nullable, Optional] + [JsonPropertyName("oidc_metadata")] + public Optional OidcMetadata { get; set; } + [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/ConnectionsOidcMetadata.cs b/src/Auth0.ManagementApi/Types/ConnectionsOidcMetadata.cs new file mode 100644 index 000000000..bade48d3b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/ConnectionsOidcMetadata.cs @@ -0,0 +1,289 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Additional OIDC metadata to include in the discovery document. Only applicable when strategy=oidc, okta, or samlp. +/// +[Serializable] +public record ConnectionsOidcMetadata : IJsonOnDeserialized, IJsonOnSerializing +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [Optional] + [JsonPropertyName("issuer")] + public string? Issuer { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [Optional] + [JsonPropertyName("authorization_endpoint")] + public string? AuthorizationEndpoint { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + + /// + /// URL of the OPs Dynamic Client Registration Endpoint. RECOMMENDED but not REQUIRED. https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Registration + /// + [Optional] + [JsonPropertyName("registration_endpoint")] + public string? RegistrationEndpoint { get; set; } + + /// + /// A list of the OAuth 2.0 [RFC6749] scope values that this server supports. The server MUST support the openid scope value. Servers MAY choose not to advertise some supported scope values even when this parameter is used, although those defined in [OpenID.Core] SHOULD be listed, if supported. RECOMMENDED but not REQUIRED + /// + [Nullable, Optional] + [JsonPropertyName("scopes_supported")] + public Optional?> ScopesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 response_mode values that this OP supports. If omitted, the default for Dynamic OpenID Providers is ["query", "fragment"] + /// + [Optional] + [JsonPropertyName("response_modes_supported")] + public IEnumerable? ResponseModesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 response_type values that this OP supports. Dynamic OpenID Providers MUST support the code, id_token, and the token id_token Response Type values + /// + [Optional] + [JsonPropertyName("response_types_supported")] + public IEnumerable? ResponseTypesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 Grant Type values that this OP supports. Dynamic OpenID Providers MUST support the authorization_code and implicit Grant Type values and MAY support other Grant Types. If omitted, the default value is ["authorization_code", "implicit"]. + /// + [Optional] + [JsonPropertyName("grant_types_supported")] + public IEnumerable? GrantTypesSupported { get; set; } + + /// + /// A list of the Authentication Context Class References that this OP supports + /// + [Optional] + [JsonPropertyName("acr_values_supported")] + public IEnumerable? AcrValuesSupported { get; set; } + + /// + /// A list of the Subject Identifier types that this OP supports. Valid types include pairwise and public + /// + [Nullable, Optional] + [JsonPropertyName("subject_types_supported")] + public Optional?> SubjectTypesSupported { get; set; } + + /// + /// A list of the JWS signing algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT. The algorithm RS256 MUST be included. The value none MAY be supported, but MUST NOT be used unless the Response Type used returns no ID Token from the Authorization Endpoint (such as when using the Authorization Code Flow). https://datatracker.ietf.org/doc/html/rfc7518 + /// + [Optional] + [JsonPropertyName("id_token_signing_alg_values_supported")] + public IEnumerable? IdTokenSigningAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT + /// + [Optional] + [JsonPropertyName("id_token_encryption_alg_values_supported")] + public IEnumerable? IdTokenEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("id_token_encryption_enc_values_supported")] + public IEnumerable? IdTokenEncryptionEncValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS [JWS] signing algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. The value none MAY be included. + /// + [Optional] + [JsonPropertyName("userinfo_signing_alg_values_supported")] + public IEnumerable? UserinfoSigningAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE [JWE] encryption algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_alg_values_supported")] + public IEnumerable? UserinfoEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_enc_values_supported")] + public IEnumerable? UserinfoEncryptionEncValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for Request Objects, which are described in Section 6.1 of OpenID Connect Core 1.0 [OpenID.Core]. These algorithms are used both when the Request Object is passed by value (using the request parameter) and when it is passed by reference (using the request_uri parameter). Servers SHOULD support none and RS256. + /// + [Optional] + [JsonPropertyName("request_object_signing_alg_values_supported")] + public IEnumerable? RequestObjectSigningAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_alg_values_supported")] + public IEnumerable? RequestObjectEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_enc_values_supported")] + public IEnumerable? RequestObjectEncryptionEncValuesSupported { get; set; } + + /// + /// JSON array containing a list of Client Authentication methods supported by this Token Endpoint. The options are client_secret_post, client_secret_basic, client_secret_jwt, and private_key_jwt, as described in Section 9 of OpenID Connect Core 1.0 [OpenID.Core]. Other authentication methods MAY be defined by extensions. If omitted, the default is client_secret_basic -- the HTTP Basic Authentication Scheme specified in Section 2.3.1 of OAuth 2.0 [RFC6749]. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_methods_supported")] + public IEnumerable? TokenEndpointAuthMethodsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg_values_supported")] + public IEnumerable? TokenEndpointAuthSigningAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the display parameter values that the OpenID Provider supports. These values are described in Section 3.1.2.1 of OpenID Connect Core 1.0 [OpenID.Core] + /// + [Optional] + [JsonPropertyName("display_values_supported")] + public IEnumerable? DisplayValuesSupported { get; set; } + + /// + /// JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described in Section 5.6 of OpenID Connect Core 1.0 [OpenID.Core]. If omitted, the implementation supports only normal Claims. + /// + [Optional] + [JsonPropertyName("claim_types_supported")] + public IEnumerable? ClaimTypesSupported { get; set; } + + /// + /// JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list. + /// + [Optional] + [JsonPropertyName("claims_supported")] + public IEnumerable? ClaimsSupported { get; set; } + + /// + /// URL of a page containing human-readable information that developers might want or need to know when using the OpenID Provider. In particular, if the OpenID Provider does not support Dynamic Client Registration, then information on how to register Clients needs to be provided in this documentation. + /// + [Optional] + [JsonPropertyName("service_documentation")] + public string? ServiceDocumentation { get; set; } + + /// + /// Languages and scripts supported for values in Claims being returned, represented as a JSON array of BCP47 [RFC5646] language tag values. Not all languages and scripts are necessarily supported for all Claim values. + /// + [Optional] + [JsonPropertyName("claims_locales_supported")] + public IEnumerable? ClaimsLocalesSupported { get; set; } + + /// + /// Languages and scripts supported for the user interface, represented as a JSON array of BCP47 [RFC5646] language tag values. + /// + [Optional] + [JsonPropertyName("ui_locales_supported")] + public IEnumerable? UiLocalesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the claims parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("claims_parameter_supported")] + public bool? ClaimsParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_parameter_supported")] + public bool? RequestParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request_uri parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_uri_parameter_supported")] + public bool? RequestUriParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP requires use of the request_uri parameter. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("require_request_uri_registration")] + public bool? RequireRequestUriRegistration { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about the OPs requirements on how the Relying Party can use the data provided by the OP. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_policy_uri")] + public string? OpPolicyUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about OpenID Providers terms of service. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_tos_uri")] + public string? OpTosUri { get; set; } + + /// + /// URL of the identity provider's logout/end session endpoint. When configured as a static URL, users are redirected here after logging out from Auth0. Must use HTTPS scheme. + /// + [Optional] + [JsonPropertyName("end_session_endpoint")] + public string? EndSessionEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported for DPoP proof JWT signing. + /// + [Optional] + [JsonPropertyName("dpop_signing_alg_values_supported")] + public IEnumerable? DpopSigningAlgValuesSupported { get; set; } + + [JsonIgnore] + public AdditionalProperties AdditionalProperties { get; set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + void IJsonOnSerializing.OnSerializing() => + AdditionalProperties.CopyToExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/CreateOrganizationResponseContent.cs b/src/Auth0.ManagementApi/Types/CreateOrganizationResponseContent.cs index aa4a2d5ea..56a63c816 100644 --- a/src/Auth0.ManagementApi/Types/CreateOrganizationResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/CreateOrganizationResponseContent.cs @@ -43,6 +43,10 @@ public record CreateOrganizationResponseContent : IJsonOnDeserialized, IJsonOnSe [JsonPropertyName("token_quota")] public TokenQuota? TokenQuota { get; set; } + [Optional] + [JsonPropertyName("third_party_client_access")] + public OrganizationThirdPartyClientAccessEnum? ThirdPartyClientAccess { get; set; } + [Optional] [JsonPropertyName("enabled_connections")] public IEnumerable? EnabledConnections { get; set; } diff --git a/src/Auth0.ManagementApi/Types/DefaultMethodPhoneNumberIdentifierEnum.cs b/src/Auth0.ManagementApi/Types/DefaultMethodPhoneNumberIdentifierEnum.cs new file mode 100644 index 000000000..41353a1fd --- /dev/null +++ b/src/Auth0.ManagementApi/Types/DefaultMethodPhoneNumberIdentifierEnum.cs @@ -0,0 +1,120 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(DefaultMethodPhoneNumberIdentifierEnum.DefaultMethodPhoneNumberIdentifierEnumSerializer) +)] +[Serializable] +public readonly record struct DefaultMethodPhoneNumberIdentifierEnum : IStringEnum +{ + public static readonly DefaultMethodPhoneNumberIdentifierEnum Password = new(Values.Password); + + public static readonly DefaultMethodPhoneNumberIdentifierEnum PhoneOtp = new(Values.PhoneOtp); + + public DefaultMethodPhoneNumberIdentifierEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static DefaultMethodPhoneNumberIdentifierEnum FromCustom(string value) + { + return new DefaultMethodPhoneNumberIdentifierEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(DefaultMethodPhoneNumberIdentifierEnum value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(DefaultMethodPhoneNumberIdentifierEnum value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(DefaultMethodPhoneNumberIdentifierEnum value) => + value.Value; + + public static explicit operator DefaultMethodPhoneNumberIdentifierEnum(string value) => + new(value); + + internal class DefaultMethodPhoneNumberIdentifierEnumSerializer + : JsonConverter + { + public override DefaultMethodPhoneNumberIdentifierEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new DefaultMethodPhoneNumberIdentifierEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + DefaultMethodPhoneNumberIdentifierEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override DefaultMethodPhoneNumberIdentifierEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new DefaultMethodPhoneNumberIdentifierEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + DefaultMethodPhoneNumberIdentifierEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Password = "password"; + + public const string PhoneOtp = "phone_otp"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EmailAttribute.cs b/src/Auth0.ManagementApi/Types/EmailAttribute.cs index 8efbf7749..e1db00e1c 100644 --- a/src/Auth0.ManagementApi/Types/EmailAttribute.cs +++ b/src/Auth0.ManagementApi/Types/EmailAttribute.cs @@ -16,7 +16,7 @@ public record EmailAttribute : IJsonOnDeserialized [Optional] [JsonPropertyName("identifier")] - public ConnectionAttributeIdentifier? Identifier { get; set; } + public EmailAttributeIdentifier? Identifier { get; set; } /// /// Determines if the attribute is unique in a given connection diff --git a/src/Auth0.ManagementApi/Types/ConnectionAttributeIdentifier.cs b/src/Auth0.ManagementApi/Types/EmailAttributeIdentifier.cs similarity index 93% rename from src/Auth0.ManagementApi/Types/ConnectionAttributeIdentifier.cs rename to src/Auth0.ManagementApi/Types/EmailAttributeIdentifier.cs index 53c65ab8c..5dfccfc82 100644 --- a/src/Auth0.ManagementApi/Types/ConnectionAttributeIdentifier.cs +++ b/src/Auth0.ManagementApi/Types/EmailAttributeIdentifier.cs @@ -5,7 +5,7 @@ namespace Auth0.ManagementApi; [Serializable] -public record ConnectionAttributeIdentifier : IJsonOnDeserialized +public record EmailAttributeIdentifier : IJsonOnDeserialized { [JsonExtensionData] private readonly IDictionary _extensionData = diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreated.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreated.cs new file mode 100644 index 000000000..890f353a4 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreated.cs @@ -0,0 +1,37 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// SSE message for connection.created. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreated : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Opaque cursor representing position in the stream. Pass as the `from` query parameter to resume. + /// + [JsonPropertyName("offset")] + public required string Offset { get; set; } + + [JsonPropertyName("event")] + public required EventStreamCloudEventConnectionCreatedCloudEvent Event { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedCloudEvent.cs new file mode 100644 index 000000000..8455fd106 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedCloudEvent.cs @@ -0,0 +1,71 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Represents an event that occurs when a connection is created. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedCloudEvent : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("specversion")] + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } + + [JsonPropertyName("type")] + public required EventStreamCloudEventConnectionCreatedCloudEventTypeEnum Type { get; set; } + + /// + /// The source of the event. This will take the form 'urn:auth0:<tenant>.<domain>'. + /// + [JsonPropertyName("source")] + public required string Source { get; set; } + + /// + /// A unique identifier for the event. + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// An ISO-8601 timestamp indicating when the event physically occurred. + /// + [JsonPropertyName("time")] + public required DateTime Time { get; set; } + + [JsonPropertyName("data")] + public required EventStreamCloudEventConnectionCreatedData Data { get; set; } + + /// + /// The auth0 tenant ID to which the event is associated. + /// + [JsonPropertyName("a0tenant")] + public required string A0Tenant { get; set; } + + /// + /// The auth0 event stream ID of the stream the event was delivered on. + /// + [JsonPropertyName("a0stream")] + public required string A0Stream { get; set; } + + [Optional] + [JsonPropertyName("a0purpose")] + public EventStreamCloudEventA0PurposeEnum? A0Purpose { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedCloudEventTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedCloudEventTypeEnum.cs new file mode 100644 index 000000000..dc8ff57d2 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedCloudEventTypeEnum.cs @@ -0,0 +1,123 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedCloudEventTypeEnum.EventStreamCloudEventConnectionCreatedCloudEventTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedCloudEventTypeEnum : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedCloudEventTypeEnum ConnectionCreated = + new(Values.ConnectionCreated); + + public EventStreamCloudEventConnectionCreatedCloudEventTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedCloudEventTypeEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionCreatedCloudEventTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedCloudEventTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedCloudEventTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedCloudEventTypeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedCloudEventTypeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedCloudEventTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedCloudEventTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedCloudEventTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedCloudEventTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedCloudEventTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedCloudEventTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedCloudEventTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ConnectionCreated = "connection.created"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedData.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedData.cs new file mode 100644 index 000000000..dd4744e04 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedData.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// The event payload. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedData : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("object")] + public required EventStreamCloudEventConnectionCreatedObject Object { get; set; } + + [Optional] + [JsonPropertyName("context")] + public EventStreamCloudEventContext? Context { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject.cs new file mode 100644 index 000000000..7dceaefa8 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject.cs @@ -0,0 +1,675 @@ +// ReSharper disable NullableWarningSuppressionIsUsed +// ReSharper disable InconsistentNaming + +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// The event content. +/// +[JsonConverter(typeof(EventStreamCloudEventConnectionCreatedObject.JsonConverter))] +[Serializable] +public class EventStreamCloudEventConnectionCreatedObject +{ + private EventStreamCloudEventConnectionCreatedObject(string type, object? value) + { + Type = type; + Value = value; + } + + /// + /// Type discriminator + /// + [JsonIgnore] + public string Type { get; internal set; } + + /// + /// Union value + /// + [JsonIgnore] + public object? Value { get; internal set; } + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject0 value. + /// + public static EventStreamCloudEventConnectionCreatedObject FromEventStreamCloudEventConnectionCreatedObject0( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject0 value + ) => new("eventStreamCloudEventConnectionCreatedObject0", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject1 value. + /// + public static EventStreamCloudEventConnectionCreatedObject FromEventStreamCloudEventConnectionCreatedObject1( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject1 value + ) => new("eventStreamCloudEventConnectionCreatedObject1", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject2 value. + /// + public static EventStreamCloudEventConnectionCreatedObject FromEventStreamCloudEventConnectionCreatedObject2( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject2 value + ) => new("eventStreamCloudEventConnectionCreatedObject2", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject3 value. + /// + public static EventStreamCloudEventConnectionCreatedObject FromEventStreamCloudEventConnectionCreatedObject3( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject3 value + ) => new("eventStreamCloudEventConnectionCreatedObject3", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject4 value. + /// + public static EventStreamCloudEventConnectionCreatedObject FromEventStreamCloudEventConnectionCreatedObject4( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject4 value + ) => new("eventStreamCloudEventConnectionCreatedObject4", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject5 value. + /// + public static EventStreamCloudEventConnectionCreatedObject FromEventStreamCloudEventConnectionCreatedObject5( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject5 value + ) => new("eventStreamCloudEventConnectionCreatedObject5", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject6 value. + /// + public static EventStreamCloudEventConnectionCreatedObject FromEventStreamCloudEventConnectionCreatedObject6( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject6 value + ) => new("eventStreamCloudEventConnectionCreatedObject6", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject7 value. + /// + public static EventStreamCloudEventConnectionCreatedObject FromEventStreamCloudEventConnectionCreatedObject7( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject7 value + ) => new("eventStreamCloudEventConnectionCreatedObject7", value); + + /// + /// Returns true if is "eventStreamCloudEventConnectionCreatedObject0" + /// + public bool IsEventStreamCloudEventConnectionCreatedObject0() => + Type == "eventStreamCloudEventConnectionCreatedObject0"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionCreatedObject1" + /// + public bool IsEventStreamCloudEventConnectionCreatedObject1() => + Type == "eventStreamCloudEventConnectionCreatedObject1"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionCreatedObject2" + /// + public bool IsEventStreamCloudEventConnectionCreatedObject2() => + Type == "eventStreamCloudEventConnectionCreatedObject2"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionCreatedObject3" + /// + public bool IsEventStreamCloudEventConnectionCreatedObject3() => + Type == "eventStreamCloudEventConnectionCreatedObject3"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionCreatedObject4" + /// + public bool IsEventStreamCloudEventConnectionCreatedObject4() => + Type == "eventStreamCloudEventConnectionCreatedObject4"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionCreatedObject5" + /// + public bool IsEventStreamCloudEventConnectionCreatedObject5() => + Type == "eventStreamCloudEventConnectionCreatedObject5"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionCreatedObject6" + /// + public bool IsEventStreamCloudEventConnectionCreatedObject6() => + Type == "eventStreamCloudEventConnectionCreatedObject6"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionCreatedObject7" + /// + public bool IsEventStreamCloudEventConnectionCreatedObject7() => + Type == "eventStreamCloudEventConnectionCreatedObject7"; + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionCreatedObject0', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionCreatedObject0'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject0 AsEventStreamCloudEventConnectionCreatedObject0() => + IsEventStreamCloudEventConnectionCreatedObject0() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject0)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionCreatedObject0'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionCreatedObject1', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionCreatedObject1'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject1 AsEventStreamCloudEventConnectionCreatedObject1() => + IsEventStreamCloudEventConnectionCreatedObject1() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject1)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionCreatedObject1'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionCreatedObject2', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionCreatedObject2'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject2 AsEventStreamCloudEventConnectionCreatedObject2() => + IsEventStreamCloudEventConnectionCreatedObject2() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject2)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionCreatedObject2'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionCreatedObject3', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionCreatedObject3'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject3 AsEventStreamCloudEventConnectionCreatedObject3() => + IsEventStreamCloudEventConnectionCreatedObject3() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject3)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionCreatedObject3'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionCreatedObject4', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionCreatedObject4'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject4 AsEventStreamCloudEventConnectionCreatedObject4() => + IsEventStreamCloudEventConnectionCreatedObject4() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject4)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionCreatedObject4'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionCreatedObject5', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionCreatedObject5'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject5 AsEventStreamCloudEventConnectionCreatedObject5() => + IsEventStreamCloudEventConnectionCreatedObject5() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject5)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionCreatedObject5'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionCreatedObject6', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionCreatedObject6'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject6 AsEventStreamCloudEventConnectionCreatedObject6() => + IsEventStreamCloudEventConnectionCreatedObject6() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject6)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionCreatedObject6'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionCreatedObject7', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionCreatedObject7'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject7 AsEventStreamCloudEventConnectionCreatedObject7() => + IsEventStreamCloudEventConnectionCreatedObject7() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject7)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionCreatedObject7'" + ); + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionCreatedObject0( + out Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject0? value + ) + { + if (Type == "eventStreamCloudEventConnectionCreatedObject0") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject0)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionCreatedObject1( + out Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject1? value + ) + { + if (Type == "eventStreamCloudEventConnectionCreatedObject1") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject1)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionCreatedObject2( + out Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject2? value + ) + { + if (Type == "eventStreamCloudEventConnectionCreatedObject2") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject2)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionCreatedObject3( + out Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject3? value + ) + { + if (Type == "eventStreamCloudEventConnectionCreatedObject3") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject3)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionCreatedObject4( + out Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject4? value + ) + { + if (Type == "eventStreamCloudEventConnectionCreatedObject4") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject4)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionCreatedObject5( + out Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject5? value + ) + { + if (Type == "eventStreamCloudEventConnectionCreatedObject5") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject5)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionCreatedObject6( + out Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject6? value + ) + { + if (Type == "eventStreamCloudEventConnectionCreatedObject6") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject6)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionCreatedObject7( + out Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject7? value + ) + { + if (Type == "eventStreamCloudEventConnectionCreatedObject7") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject7)Value!; + return true; + } + value = null; + return false; + } + + public T Match( + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject0, + T + > onEventStreamCloudEventConnectionCreatedObject0, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject1, + T + > onEventStreamCloudEventConnectionCreatedObject1, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject2, + T + > onEventStreamCloudEventConnectionCreatedObject2, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject3, + T + > onEventStreamCloudEventConnectionCreatedObject3, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject4, + T + > onEventStreamCloudEventConnectionCreatedObject4, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject5, + T + > onEventStreamCloudEventConnectionCreatedObject5, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject6, + T + > onEventStreamCloudEventConnectionCreatedObject6, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject7, + T + > onEventStreamCloudEventConnectionCreatedObject7 + ) + { + return Type switch + { + "eventStreamCloudEventConnectionCreatedObject0" => + onEventStreamCloudEventConnectionCreatedObject0( + AsEventStreamCloudEventConnectionCreatedObject0() + ), + "eventStreamCloudEventConnectionCreatedObject1" => + onEventStreamCloudEventConnectionCreatedObject1( + AsEventStreamCloudEventConnectionCreatedObject1() + ), + "eventStreamCloudEventConnectionCreatedObject2" => + onEventStreamCloudEventConnectionCreatedObject2( + AsEventStreamCloudEventConnectionCreatedObject2() + ), + "eventStreamCloudEventConnectionCreatedObject3" => + onEventStreamCloudEventConnectionCreatedObject3( + AsEventStreamCloudEventConnectionCreatedObject3() + ), + "eventStreamCloudEventConnectionCreatedObject4" => + onEventStreamCloudEventConnectionCreatedObject4( + AsEventStreamCloudEventConnectionCreatedObject4() + ), + "eventStreamCloudEventConnectionCreatedObject5" => + onEventStreamCloudEventConnectionCreatedObject5( + AsEventStreamCloudEventConnectionCreatedObject5() + ), + "eventStreamCloudEventConnectionCreatedObject6" => + onEventStreamCloudEventConnectionCreatedObject6( + AsEventStreamCloudEventConnectionCreatedObject6() + ), + "eventStreamCloudEventConnectionCreatedObject7" => + onEventStreamCloudEventConnectionCreatedObject7( + AsEventStreamCloudEventConnectionCreatedObject7() + ), + _ => throw new ManagementException($"Unknown union type: {Type}"), + }; + } + + public void Visit( + global::System.Action onEventStreamCloudEventConnectionCreatedObject0, + global::System.Action onEventStreamCloudEventConnectionCreatedObject1, + global::System.Action onEventStreamCloudEventConnectionCreatedObject2, + global::System.Action onEventStreamCloudEventConnectionCreatedObject3, + global::System.Action onEventStreamCloudEventConnectionCreatedObject4, + global::System.Action onEventStreamCloudEventConnectionCreatedObject5, + global::System.Action onEventStreamCloudEventConnectionCreatedObject6, + global::System.Action onEventStreamCloudEventConnectionCreatedObject7 + ) + { + switch (Type) + { + case "eventStreamCloudEventConnectionCreatedObject0": + onEventStreamCloudEventConnectionCreatedObject0( + AsEventStreamCloudEventConnectionCreatedObject0() + ); + break; + case "eventStreamCloudEventConnectionCreatedObject1": + onEventStreamCloudEventConnectionCreatedObject1( + AsEventStreamCloudEventConnectionCreatedObject1() + ); + break; + case "eventStreamCloudEventConnectionCreatedObject2": + onEventStreamCloudEventConnectionCreatedObject2( + AsEventStreamCloudEventConnectionCreatedObject2() + ); + break; + case "eventStreamCloudEventConnectionCreatedObject3": + onEventStreamCloudEventConnectionCreatedObject3( + AsEventStreamCloudEventConnectionCreatedObject3() + ); + break; + case "eventStreamCloudEventConnectionCreatedObject4": + onEventStreamCloudEventConnectionCreatedObject4( + AsEventStreamCloudEventConnectionCreatedObject4() + ); + break; + case "eventStreamCloudEventConnectionCreatedObject5": + onEventStreamCloudEventConnectionCreatedObject5( + AsEventStreamCloudEventConnectionCreatedObject5() + ); + break; + case "eventStreamCloudEventConnectionCreatedObject6": + onEventStreamCloudEventConnectionCreatedObject6( + AsEventStreamCloudEventConnectionCreatedObject6() + ); + break; + case "eventStreamCloudEventConnectionCreatedObject7": + onEventStreamCloudEventConnectionCreatedObject7( + AsEventStreamCloudEventConnectionCreatedObject7() + ); + break; + default: + throw new ManagementException($"Unknown union type: {Type}"); + } + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Type.GetHashCode(); + if (Value != null) + { + hashCode = (hashCode * 397) ^ Value.GetHashCode(); + } + return hashCode; + } + } + + public override bool Equals(object? obj) + { + if (obj is null) + return false; + if (ReferenceEquals(this, obj)) + return true; + if (obj is not EventStreamCloudEventConnectionCreatedObject other) + return false; + + // Compare type discriminators + if (Type != other.Type) + return false; + + // Compare values using EqualityComparer for deep comparison + return System.Collections.Generic.EqualityComparer.Default.Equals( + Value, + other.Value + ); + } + + public override string ToString() => JsonUtils.Serialize(this); + + public static implicit operator EventStreamCloudEventConnectionCreatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject0 value + ) => new("eventStreamCloudEventConnectionCreatedObject0", value); + + public static implicit operator EventStreamCloudEventConnectionCreatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject1 value + ) => new("eventStreamCloudEventConnectionCreatedObject1", value); + + public static implicit operator EventStreamCloudEventConnectionCreatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject2 value + ) => new("eventStreamCloudEventConnectionCreatedObject2", value); + + public static implicit operator EventStreamCloudEventConnectionCreatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject3 value + ) => new("eventStreamCloudEventConnectionCreatedObject3", value); + + public static implicit operator EventStreamCloudEventConnectionCreatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject4 value + ) => new("eventStreamCloudEventConnectionCreatedObject4", value); + + public static implicit operator EventStreamCloudEventConnectionCreatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject5 value + ) => new("eventStreamCloudEventConnectionCreatedObject5", value); + + public static implicit operator EventStreamCloudEventConnectionCreatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject6 value + ) => new("eventStreamCloudEventConnectionCreatedObject6", value); + + public static implicit operator EventStreamCloudEventConnectionCreatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject7 value + ) => new("eventStreamCloudEventConnectionCreatedObject7", value); + + [Serializable] + internal sealed class JsonConverter + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject? Read( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + if (reader.TokenType == JsonTokenType.Null) + { + return null; + } + + if (reader.TokenType == JsonTokenType.StartObject) + { + var document = JsonDocument.ParseValue(ref reader); + + var types = new (string Key, System.Type Type)[] + { + ( + "eventStreamCloudEventConnectionCreatedObject0", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject0) + ), + ( + "eventStreamCloudEventConnectionCreatedObject1", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject1) + ), + ( + "eventStreamCloudEventConnectionCreatedObject2", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject2) + ), + ( + "eventStreamCloudEventConnectionCreatedObject3", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject3) + ), + ( + "eventStreamCloudEventConnectionCreatedObject4", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject4) + ), + ( + "eventStreamCloudEventConnectionCreatedObject5", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject5) + ), + ( + "eventStreamCloudEventConnectionCreatedObject6", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject6) + ), + ( + "eventStreamCloudEventConnectionCreatedObject7", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionCreatedObject7) + ), + }; + + foreach (var (key, type) in types) + { + try + { + var value = document.Deserialize(type, options); + if (value != null) + { + EventStreamCloudEventConnectionCreatedObject result = new(key, value); + return result; + } + } + catch (JsonException) + { + // Try next type; + } + } + } + + throw new JsonException( + $"Cannot deserialize JSON token {reader.TokenType} into EventStreamCloudEventConnectionCreatedObject" + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject value, + JsonSerializerOptions options + ) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + + value.Visit( + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options) + ); + } + + public override EventStreamCloudEventConnectionCreatedObject ReadAsPropertyName( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = reader.GetString()!; + EventStreamCloudEventConnectionCreatedObject result = new("string", stringValue); + return result; + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value?.ToString() ?? "null"); + } + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0.cs new file mode 100644 index 000000000..3711f909b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject0 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionCreatedObject0Authentication? Authentication { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionCreatedObject0Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionCreatedObject0ConnectedAccounts? ConnectedAccounts { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionCreatedObject0Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionCreatedObject0StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Authentication.cs new file mode 100644 index 000000000..a7f0be5e0 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject0Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0ConnectedAccounts.cs new file mode 100644 index 000000000..850ed517b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0ConnectedAccounts.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject0ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [Optional] + [JsonPropertyName("cross_app_access")] + public bool? CrossAppAccess { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Metadata.cs new file mode 100644 index 000000000..282c6673f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject0Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Options.cs new file mode 100644 index 000000000..af0438f68 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0Options.cs @@ -0,0 +1,180 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'oidc' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject0Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [Optional] + [JsonPropertyName("authorization_endpoint")] + public string? AuthorizationEndpoint { get; set; } + + /// + /// OAuth 2.0 client identifier issued by the identity provider during application registration. This value identifies your Auth0 connection to the identity provider. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + [Optional] + [JsonPropertyName("connection_settings")] + public EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettings? ConnectionSettings { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + [Optional] + [JsonPropertyName("dpop_signing_alg")] + public EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum? DpopSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionCreatedObject0OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// https url of the icon to be shown + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Indicates whether the identity provider supports session expiry via the id_token. If true, the system will use the session_expiry claim in the id_token to determine session expiry. + /// + [Optional] + [JsonPropertyName("id_token_session_expiry_supported")] + public bool? IdTokenSessionExpirySupported { get; set; } + + /// + /// List of algorithms allowed to verify the ID tokens. Applicable when strategy=oidc or okta. + /// + [Optional] + [JsonPropertyName("id_token_signed_response_algs")] + public IEnumerable? IdTokenSignedResponseAlgs { get; set; } + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [Optional] + [JsonPropertyName("issuer")] + public string? Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("oidc_metadata")] + public EventStreamCloudEventConnectionCreatedObject0OptionsOidcMetadata? OidcMetadata { get; set; } + + [Optional] + [JsonPropertyName("schema_version")] + public EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum? SchemaVersion { get; set; } + + /// + /// Space-separated list of OAuth 2.0 scopes requested during authorization. Must include 'openid' (required by OIDC spec). Common values: 'openid profile email'. Additional scopes depend on the identity provider. + /// + [Optional] + [JsonPropertyName("scope")] + public string? Scope { get; set; } + + /// + /// When true and type is 'back_channel', includes a cryptographic nonce in authorization requests to prevent replay attacks. The identity provider must include this nonce in the ID token for validation. + /// + [Optional] + [JsonPropertyName("send_back_channel_nonce")] + public bool? SendBackChannelNonce { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// Tenant domain + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_method")] + public EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum? TokenEndpointAuthMethod { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg")] + public EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum? TokenEndpointAuthSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_jwtca_aud_format")] + public EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum? TokenEndpointJwtcaAudFormat { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + [Optional] + [JsonPropertyName("attribute_map")] + public EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMap? AttributeMap { get; set; } + + /// + /// URL of the identity provider's OIDC Discovery endpoint (/.well-known/openid-configuration). When provided and oidc_metadata is empty, Auth0 automatically retrieves the provider's configuration including endpoints and supported features. + /// + [Optional] + [JsonPropertyName("discovery_url")] + public string? DiscoveryUrl { get; set; } + + [Optional] + [JsonPropertyName("type")] + public EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum? Type { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMap.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMap.cs new file mode 100644 index 000000000..65bdebcf9 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMap.cs @@ -0,0 +1,43 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for mapping claims from the identity provider to Auth0 user profile attributes. Allows customizing which IdP claims populate user fields and how they are transformed. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMap : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("attributes")] + public Dictionary? Attributes { get; set; } + + /// + /// Scopes to send to the IdP's Userinfo endpoint + /// + [Optional] + [JsonPropertyName("userinfo_scope")] + public string? UserinfoScope { get; set; } + + [Optional] + [JsonPropertyName("mapping_mode")] + public EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum? MappingMode { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum.cs new file mode 100644 index 000000000..c5535ff67 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum.EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum BindAll = + new(Values.BindAll); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum UseMap = + new(Values.UseMap); + + public EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BindAll = "bind_all"; + + public const string UseMap = "use_map"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettings.cs new file mode 100644 index 000000000..276f0c69d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettings.cs @@ -0,0 +1,33 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OAuth 2.0 PKCE (Proof Key for Code Exchange) settings. PKCE enhances security for public clients by preventing authorization code interception attacks. 'auto' (recommended) uses the strongest method supported by the IdP. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("pkce")] + public EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum? Pkce { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum.cs new file mode 100644 index 000000000..006050dd8 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum.cs @@ -0,0 +1,149 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum.EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum Auto = + new(Values.Auto); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum S256 = + new(Values.S256); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum Plain = + new(Values.Plain); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum Disabled = + new(Values.Disabled); + + public EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Auto = "auto"; + + public const string S256 = "S256"; + + public const string Plain = "plain"; + + public const string Disabled = "disabled"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum.cs new file mode 100644 index 000000000..4e50955fb --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum.cs @@ -0,0 +1,145 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum.EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum Es512 = + new(Values.Es512); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum Ed25519 = + new(Values.Ed25519); + + public EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Es512 = "ES512"; + + public const string Ed25519 = "Ed25519"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..8191c6bc6 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject0OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs new file mode 100644 index 000000000..3d6833811 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum.EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsOidcMetadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsOidcMetadata.cs new file mode 100644 index 000000000..433202fe3 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsOidcMetadata.cs @@ -0,0 +1,283 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OpenID Connect Provider Metadata as per https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject0OptionsOidcMetadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of the Authentication Context Class References that this OP supports + /// + [Optional] + [JsonPropertyName("acr_values_supported")] + public IEnumerable? AcrValuesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [JsonPropertyName("authorization_endpoint")] + public required string AuthorizationEndpoint { get; set; } + + /// + /// JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described in Section 5.6 of OpenID Connect Core 1.0 [OpenID.Core]. If omitted, the implementation supports only normal Claims. + /// + [Optional] + [JsonPropertyName("claim_types_supported")] + public IEnumerable? ClaimTypesSupported { get; set; } + + /// + /// Languages and scripts supported for values in Claims being returned, represented as a JSON array of BCP47 [RFC5646] language tag values. Not all languages and scripts are necessarily supported for all Claim values. + /// + [Optional] + [JsonPropertyName("claims_locales_supported")] + public IEnumerable? ClaimsLocalesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the claims parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("claims_parameter_supported")] + public bool? ClaimsParameterSupported { get; set; } + + /// + /// JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list. + /// + [Optional] + [JsonPropertyName("claims_supported")] + public IEnumerable? ClaimsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("display_values_supported")] + public IEnumerable? DisplayValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported for DPoP proof JWT signing. + /// + [Optional] + [JsonPropertyName("dpop_signing_alg_values_supported")] + public IEnumerable? DpopSigningAlgValuesSupported { get; set; } + + /// + /// URL of the identity provider's logout/end session endpoint. When configured as a static URL, users are redirected here after logging out from Auth0. Must use HTTPS scheme. + /// + [Optional] + [JsonPropertyName("end_session_endpoint")] + public string? EndSessionEndpoint { get; set; } + + /// + /// A list of the OAuth 2.0 Grant Type values that this OP supports. Dynamic OpenID Providers MUST support the authorization_code and implicit Grant Type values and MAY support other Grant Types. If omitted, the default value is ["authorization_code", "implicit"]. + /// + [Optional] + [JsonPropertyName("grant_types_supported")] + public IEnumerable? GrantTypesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT + /// + [Optional] + [JsonPropertyName("id_token_encryption_alg_values_supported")] + public IEnumerable? IdTokenEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("id_token_encryption_enc_values_supported")] + public IEnumerable? IdTokenEncryptionEncValuesSupported { get; set; } + + /// + /// A list of the JWS signing algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT. The algorithm RS256 MUST be included. The value none MAY be supported, but MUST NOT be used unless the Response Type used returns no ID Token from the Authorization Endpoint (such as when using the Authorization Code Flow). https://datatracker.ietf.org/doc/html/rfc7518 + /// + [JsonPropertyName("id_token_signing_alg_values_supported")] + public IEnumerable IdTokenSigningAlgValuesSupported { get; set; } = new List(); + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [JsonPropertyName("issuer")] + public required string Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [JsonPropertyName("jwks_uri")] + public required string JwksUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about the OPs requirements on how the Relying Party can use the data provided by the OP. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_policy_uri")] + public string? OpPolicyUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about OpenID Providers terms of service. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_tos_uri")] + public string? OpTosUri { get; set; } + + /// + /// URL of the OPs Dynamic Client Registration Endpoint. RECOMMENDED but not REQUIRED. https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Registration + /// + [Optional] + [JsonPropertyName("registration_endpoint")] + public string? RegistrationEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_alg_values_supported")] + public IEnumerable? RequestObjectEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_enc_values_supported")] + public IEnumerable? RequestObjectEncryptionEncValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for Request Objects, which are described in Section 6.1 of OpenID Connect Core 1.0 [OpenID.Core]. These algorithms are used both when the Request Object is passed by value (using the request parameter) and when it is passed by reference (using the request_uri parameter). Servers SHOULD support none and RS256. + /// + [Optional] + [JsonPropertyName("request_object_signing_alg_values_supported")] + public IEnumerable? RequestObjectSigningAlgValuesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_parameter_supported")] + public bool? RequestParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request_uri parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_uri_parameter_supported")] + public bool? RequestUriParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP requires use of the request_uri parameter. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("require_request_uri_registration")] + public bool? RequireRequestUriRegistration { get; set; } + + /// + /// A list of the OAuth 2.0 response_mode values that this OP supports. If omitted, the default for Dynamic OpenID Providers is ["query", "fragment"] + /// + [Optional] + [JsonPropertyName("response_modes_supported")] + public IEnumerable? ResponseModesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 response_type values that this OP supports. Dynamic OpenID Providers MUST support the code, id_token, and the token id_token Response Type values + /// + [Optional] + [JsonPropertyName("response_types_supported")] + public IEnumerable? ResponseTypesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 [RFC6749] scope values that this server supports. The server MUST support the openid scope value. Servers MAY choose not to advertise some supported scope values even when this parameter is used, although those defined in [OpenID.Core] SHOULD be listed, if supported. RECOMMENDED but not REQUIRED + /// + [Optional] + [JsonPropertyName("scopes_supported")] + public IEnumerable? ScopesSupported { get; set; } + + /// + /// URL of a page containing human-readable information that developers might want or need to know when using the OpenID Provider. In particular, if the OpenID Provider does not support Dynamic Client Registration, then information on how to register Clients needs to be provided in this documentation. + /// + [Optional] + [JsonPropertyName("service_documentation")] + public string? ServiceDocumentation { get; set; } + + /// + /// A list of the Subject Identifier types that this OP supports. Valid types include pairwise and public + /// + [Optional] + [JsonPropertyName("subject_types_supported")] + public IEnumerable? SubjectTypesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + /// + /// JSON array containing a list of Client Authentication methods supported by this Token Endpoint. The options are client_secret_post, client_secret_basic, client_secret_jwt, and private_key_jwt, as described in Section 9 of OpenID Connect Core 1.0 [OpenID.Core]. Other authentication methods MAY be defined by extensions. If omitted, the default is client_secret_basic -- the HTTP Basic Authentication Scheme specified in Section 2.3.1 of OAuth 2.0 [RFC6749]. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_methods_supported")] + public IEnumerable? TokenEndpointAuthMethodsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg_values_supported")] + public IEnumerable? TokenEndpointAuthSigningAlgValuesSupported { get; set; } + + /// + /// Languages and scripts supported for the user interface, represented as a JSON array of BCP47 [RFC5646] language tag values. + /// + [Optional] + [JsonPropertyName("ui_locales_supported")] + public IEnumerable? UiLocalesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE [JWE] encryption algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_alg_values_supported")] + public IEnumerable? UserinfoEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_enc_values_supported")] + public IEnumerable? UserinfoEncryptionEncValuesSupported { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWS [JWS] signing algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. The value none MAY be included. + /// + [Optional] + [JsonPropertyName("userinfo_signing_alg_values_supported")] + public IEnumerable? UserinfoSigningAlgValuesSupported { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum.cs new file mode 100644 index 000000000..600eb6032 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum.EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum Openid100 = + new(Values.Openid100); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum OidcV4 = + new(Values.OidcV4); + + public EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Openid100 = "openid-1.0.0"; + + public const string OidcV4 = "oidc-v4"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..07194f526 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum.cs new file mode 100644 index 000000000..64b36b9fb --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum.EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum ClientSecretPost = + new(Values.ClientSecretPost); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum PrivateKeyJwt = + new(Values.PrivateKeyJwt); + + public EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ClientSecretPost = "client_secret_post"; + + public const string PrivateKeyJwt = "private_key_jwt"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs new file mode 100644 index 000000000..9cc6a1f58 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum.EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs new file mode 100644 index 000000000..56322d482 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum.EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum Issuer = + new(Values.Issuer); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum TokenEndpoint = + new(Values.TokenEndpoint); + + public EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Issuer = "issuer"; + + public const string TokenEndpoint = "token_endpoint"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum.cs new file mode 100644 index 000000000..787ee7b5d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum.cs @@ -0,0 +1,131 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum.EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum BackChannel = + new(Values.BackChannel); + + public static readonly EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum FrontChannel = + new(Values.FrontChannel); + + public EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BackChannel = "back_channel"; + + public const string FrontChannel = "front_channel"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0StrategyEnum.cs new file mode 100644 index 000000000..5ba5bf701 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject0StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject0StrategyEnum.EventStreamCloudEventConnectionCreatedObject0StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject0StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject0StrategyEnum Oidc = new( + Values.Oidc + ); + + public EventStreamCloudEventConnectionCreatedObject0StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject0StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionCreatedObject0StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject0StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject0StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject0StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject0StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject0StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject0StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject0StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject0StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject0StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oidc = "oidc"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1.cs new file mode 100644 index 000000000..1ad49bd94 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject1 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionCreatedObject1Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionCreatedObject1ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionCreatedObject1Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionCreatedObject1Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionCreatedObject1StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Authentication.cs new file mode 100644 index 000000000..4a33e9fef --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject1Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1ConnectedAccounts.cs new file mode 100644 index 000000000..ce60916fb --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject1ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Metadata.cs new file mode 100644 index 000000000..021adc486 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject1Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Options.cs new file mode 100644 index 000000000..9dfb2efbd --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1Options.cs @@ -0,0 +1,180 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'okta' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject1Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [Optional] + [JsonPropertyName("authorization_endpoint")] + public string? AuthorizationEndpoint { get; set; } + + /// + /// OAuth 2.0 client identifier issued by the identity provider during application registration. This value identifies your Auth0 connection to the identity provider. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + [Optional] + [JsonPropertyName("connection_settings")] + public EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettings? ConnectionSettings { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + [Optional] + [JsonPropertyName("dpop_signing_alg")] + public EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum? DpopSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionCreatedObject1OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// https url of the icon to be shown + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Indicates whether the identity provider supports session expiry via the id_token. If true, the system will use the session_expiry claim in the id_token to determine session expiry. + /// + [Optional] + [JsonPropertyName("id_token_session_expiry_supported")] + public bool? IdTokenSessionExpirySupported { get; set; } + + /// + /// List of algorithms allowed to verify the ID tokens. Applicable when strategy=oidc or okta. + /// + [Optional] + [JsonPropertyName("id_token_signed_response_algs")] + public IEnumerable? IdTokenSignedResponseAlgs { get; set; } + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [Optional] + [JsonPropertyName("issuer")] + public string? Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("oidc_metadata")] + public EventStreamCloudEventConnectionCreatedObject1OptionsOidcMetadata? OidcMetadata { get; set; } + + [Optional] + [JsonPropertyName("schema_version")] + public EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum? SchemaVersion { get; set; } + + /// + /// Space-separated list of OAuth 2.0 scopes requested during authorization. Must include 'openid' (required by OIDC spec). Common values: 'openid profile email'. Additional scopes depend on the identity provider. + /// + [Optional] + [JsonPropertyName("scope")] + public string? Scope { get; set; } + + /// + /// When true and type is 'back_channel', includes a cryptographic nonce in authorization requests to prevent replay attacks. The identity provider must include this nonce in the ID token for validation. + /// + [Optional] + [JsonPropertyName("send_back_channel_nonce")] + public bool? SendBackChannelNonce { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// Tenant domain + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_method")] + public EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum? TokenEndpointAuthMethod { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg")] + public EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum? TokenEndpointAuthSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_jwtca_aud_format")] + public EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum? TokenEndpointJwtcaAudFormat { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + [Optional] + [JsonPropertyName("attribute_map")] + public EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMap? AttributeMap { get; set; } + + /// + /// Domain of the Okta organization (e.g., dev-123456.okta.com). Should be just the domain of the okta server with no scheme or trailing backslash. Discovery runs only when connection.options.oidc_metadata is empty and a domain is provided + /// + [Optional] + [JsonPropertyName("domain")] + public string? Domain { get; set; } + + [Optional] + [JsonPropertyName("type")] + public EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum? Type { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMap.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMap.cs new file mode 100644 index 000000000..ada89548b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMap.cs @@ -0,0 +1,43 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Mapping of claims received from the identity provider (IdP) +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMap : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("attributes")] + public Dictionary? Attributes { get; set; } + + /// + /// Scopes to send to the IdP's Userinfo endpoint + /// + [Optional] + [JsonPropertyName("userinfo_scope")] + public string? UserinfoScope { get; set; } + + [Optional] + [JsonPropertyName("mapping_mode")] + public EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum? MappingMode { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum.cs new file mode 100644 index 000000000..351aa566c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum.EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum BasicProfile = + new(Values.BasicProfile); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum UseMap = + new(Values.UseMap); + + public EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BasicProfile = "basic_profile"; + + public const string UseMap = "use_map"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettings.cs new file mode 100644 index 000000000..bc8912e19 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettings.cs @@ -0,0 +1,33 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OAuth 2.0 PKCE (Proof Key for Code Exchange) settings. PKCE enhances security for public clients by preventing authorization code interception attacks. 'auto' (recommended) uses the strongest method supported by the IdP. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("pkce")] + public EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum? Pkce { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum.cs new file mode 100644 index 000000000..2e3e9e098 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum.cs @@ -0,0 +1,149 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum.EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum Auto = + new(Values.Auto); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum S256 = + new(Values.S256); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum Plain = + new(Values.Plain); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum Disabled = + new(Values.Disabled); + + public EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Auto = "auto"; + + public const string S256 = "S256"; + + public const string Plain = "plain"; + + public const string Disabled = "disabled"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum.cs new file mode 100644 index 000000000..dfd221852 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum.cs @@ -0,0 +1,145 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum.EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum Es512 = + new(Values.Es512); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum Ed25519 = + new(Values.Ed25519); + + public EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Es512 = "ES512"; + + public const string Ed25519 = "Ed25519"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..fc9baa08e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject1OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs new file mode 100644 index 000000000..b590f281e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum.EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsOidcMetadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsOidcMetadata.cs new file mode 100644 index 000000000..abb0d12f5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsOidcMetadata.cs @@ -0,0 +1,283 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OpenID Connect Provider Metadata as per https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject1OptionsOidcMetadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of the Authentication Context Class References that this OP supports + /// + [Optional] + [JsonPropertyName("acr_values_supported")] + public IEnumerable? AcrValuesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [JsonPropertyName("authorization_endpoint")] + public required string AuthorizationEndpoint { get; set; } + + /// + /// JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described in Section 5.6 of OpenID Connect Core 1.0 [OpenID.Core]. If omitted, the implementation supports only normal Claims. + /// + [Optional] + [JsonPropertyName("claim_types_supported")] + public IEnumerable? ClaimTypesSupported { get; set; } + + /// + /// Languages and scripts supported for values in Claims being returned, represented as a JSON array of BCP47 [RFC5646] language tag values. Not all languages and scripts are necessarily supported for all Claim values. + /// + [Optional] + [JsonPropertyName("claims_locales_supported")] + public IEnumerable? ClaimsLocalesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the claims parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("claims_parameter_supported")] + public bool? ClaimsParameterSupported { get; set; } + + /// + /// JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list. + /// + [Optional] + [JsonPropertyName("claims_supported")] + public IEnumerable? ClaimsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("display_values_supported")] + public IEnumerable? DisplayValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported for DPoP proof JWT signing. + /// + [Optional] + [JsonPropertyName("dpop_signing_alg_values_supported")] + public IEnumerable? DpopSigningAlgValuesSupported { get; set; } + + /// + /// URL of the identity provider's logout/end session endpoint. When configured as a static URL, users are redirected here after logging out from Auth0. Must use HTTPS scheme. + /// + [Optional] + [JsonPropertyName("end_session_endpoint")] + public string? EndSessionEndpoint { get; set; } + + /// + /// A list of the OAuth 2.0 Grant Type values that this OP supports. Dynamic OpenID Providers MUST support the authorization_code and implicit Grant Type values and MAY support other Grant Types. If omitted, the default value is ["authorization_code", "implicit"]. + /// + [Optional] + [JsonPropertyName("grant_types_supported")] + public IEnumerable? GrantTypesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT + /// + [Optional] + [JsonPropertyName("id_token_encryption_alg_values_supported")] + public IEnumerable? IdTokenEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("id_token_encryption_enc_values_supported")] + public IEnumerable? IdTokenEncryptionEncValuesSupported { get; set; } + + /// + /// A list of the JWS signing algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT. The algorithm RS256 MUST be included. The value none MAY be supported, but MUST NOT be used unless the Response Type used returns no ID Token from the Authorization Endpoint (such as when using the Authorization Code Flow). https://datatracker.ietf.org/doc/html/rfc7518 + /// + [JsonPropertyName("id_token_signing_alg_values_supported")] + public IEnumerable IdTokenSigningAlgValuesSupported { get; set; } = new List(); + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [JsonPropertyName("issuer")] + public required string Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [JsonPropertyName("jwks_uri")] + public required string JwksUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about the OPs requirements on how the Relying Party can use the data provided by the OP. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_policy_uri")] + public string? OpPolicyUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about OpenID Providers terms of service. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_tos_uri")] + public string? OpTosUri { get; set; } + + /// + /// URL of the OPs Dynamic Client Registration Endpoint. RECOMMENDED but not REQUIRED. https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Registration + /// + [Optional] + [JsonPropertyName("registration_endpoint")] + public string? RegistrationEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_alg_values_supported")] + public IEnumerable? RequestObjectEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_enc_values_supported")] + public IEnumerable? RequestObjectEncryptionEncValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for Request Objects, which are described in Section 6.1 of OpenID Connect Core 1.0 [OpenID.Core]. These algorithms are used both when the Request Object is passed by value (using the request parameter) and when it is passed by reference (using the request_uri parameter). Servers SHOULD support none and RS256. + /// + [Optional] + [JsonPropertyName("request_object_signing_alg_values_supported")] + public IEnumerable? RequestObjectSigningAlgValuesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_parameter_supported")] + public bool? RequestParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request_uri parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_uri_parameter_supported")] + public bool? RequestUriParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP requires use of the request_uri parameter. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("require_request_uri_registration")] + public bool? RequireRequestUriRegistration { get; set; } + + /// + /// A list of the OAuth 2.0 response_mode values that this OP supports. If omitted, the default for Dynamic OpenID Providers is ["query", "fragment"] + /// + [Optional] + [JsonPropertyName("response_modes_supported")] + public IEnumerable? ResponseModesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 response_type values that this OP supports. Dynamic OpenID Providers MUST support the code, id_token, and the token id_token Response Type values + /// + [Optional] + [JsonPropertyName("response_types_supported")] + public IEnumerable? ResponseTypesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 [RFC6749] scope values that this server supports. The server MUST support the openid scope value. Servers MAY choose not to advertise some supported scope values even when this parameter is used, although those defined in [OpenID.Core] SHOULD be listed, if supported. RECOMMENDED but not REQUIRED + /// + [Optional] + [JsonPropertyName("scopes_supported")] + public IEnumerable? ScopesSupported { get; set; } + + /// + /// URL of a page containing human-readable information that developers might want or need to know when using the OpenID Provider. In particular, if the OpenID Provider does not support Dynamic Client Registration, then information on how to register Clients needs to be provided in this documentation. + /// + [Optional] + [JsonPropertyName("service_documentation")] + public string? ServiceDocumentation { get; set; } + + /// + /// A list of the Subject Identifier types that this OP supports. Valid types include pairwise and public + /// + [Optional] + [JsonPropertyName("subject_types_supported")] + public IEnumerable? SubjectTypesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + /// + /// JSON array containing a list of Client Authentication methods supported by this Token Endpoint. The options are client_secret_post, client_secret_basic, client_secret_jwt, and private_key_jwt, as described in Section 9 of OpenID Connect Core 1.0 [OpenID.Core]. Other authentication methods MAY be defined by extensions. If omitted, the default is client_secret_basic -- the HTTP Basic Authentication Scheme specified in Section 2.3.1 of OAuth 2.0 [RFC6749]. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_methods_supported")] + public IEnumerable? TokenEndpointAuthMethodsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg_values_supported")] + public IEnumerable? TokenEndpointAuthSigningAlgValuesSupported { get; set; } + + /// + /// Languages and scripts supported for the user interface, represented as a JSON array of BCP47 [RFC5646] language tag values. + /// + [Optional] + [JsonPropertyName("ui_locales_supported")] + public IEnumerable? UiLocalesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE [JWE] encryption algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_alg_values_supported")] + public IEnumerable? UserinfoEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_enc_values_supported")] + public IEnumerable? UserinfoEncryptionEncValuesSupported { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWS [JWS] signing algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. The value none MAY be included. + /// + [Optional] + [JsonPropertyName("userinfo_signing_alg_values_supported")] + public IEnumerable? UserinfoSigningAlgValuesSupported { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum.cs new file mode 100644 index 000000000..bf2773a55 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum.EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum Openid100 = + new(Values.Openid100); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum OidcV4 = + new(Values.OidcV4); + + public EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Openid100 = "openid-1.0.0"; + + public const string OidcV4 = "oidc-v4"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..b1083934c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum.cs new file mode 100644 index 000000000..317541764 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum.EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum ClientSecretPost = + new(Values.ClientSecretPost); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum PrivateKeyJwt = + new(Values.PrivateKeyJwt); + + public EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ClientSecretPost = "client_secret_post"; + + public const string PrivateKeyJwt = "private_key_jwt"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs new file mode 100644 index 000000000..9cc7f1ed5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum.EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs new file mode 100644 index 000000000..f215ef307 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum.EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum Issuer = + new(Values.Issuer); + + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum TokenEndpoint = + new(Values.TokenEndpoint); + + public EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Issuer = "issuer"; + + public const string TokenEndpoint = "token_endpoint"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum.cs new file mode 100644 index 000000000..9e31233e5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum.cs @@ -0,0 +1,126 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum.EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum BackChannel = + new(Values.BackChannel); + + public EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BackChannel = "back_channel"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1StrategyEnum.cs new file mode 100644 index 000000000..b72ed9b6f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject1StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject1StrategyEnum.EventStreamCloudEventConnectionCreatedObject1StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject1StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject1StrategyEnum Okta = new( + Values.Okta + ); + + public EventStreamCloudEventConnectionCreatedObject1StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject1StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionCreatedObject1StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject1StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject1StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject1StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject1StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject1StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject1StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject1StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject1StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject1StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Okta = "okta"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2.cs new file mode 100644 index 000000000..298831a8b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject2 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionCreatedObject2Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionCreatedObject2ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionCreatedObject2Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionCreatedObject2Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionCreatedObject2StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Authentication.cs new file mode 100644 index 000000000..bd809355d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject2Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2ConnectedAccounts.cs new file mode 100644 index 000000000..3f3a6c17d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject2ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Metadata.cs new file mode 100644 index 000000000..a2f83480c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject2Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Options.cs new file mode 100644 index 000000000..ee7989b1c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2Options.cs @@ -0,0 +1,225 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'samlp' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject2Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("assertion_decryption_settings")] + public EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettings? AssertionDecryptionSettings { get; set; } + + /// + /// X.509 signing certificate from the identity provider in .der format. Used to validate signatures in SAML Responses and Assertions. This is an alternative to signingCert and is kept for backward compatibility. Prefer using signingCert instead. + /// + [Optional] + [JsonPropertyName("cert")] + public string? Cert { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + [Optional] + [JsonPropertyName("digestAlgorithm")] + public EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum? DigestAlgorithm { get; set; } + + /// + /// Domain aliases for the connection + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// The entity identifier (Issuer) for the SAML Service Provider. When not provided, defaults to 'urn:auth0:{tenant}:{connection}'. This value is included in SAML AuthnRequest messages sent to the identity provider. + /// + [Optional] + [JsonPropertyName("entityId")] + public string? EntityId { get; set; } + + /// + /// ISO 8601 formatted datetime indicating when the identity provider's signing certificate expires. + /// + [Optional] + [JsonPropertyName("expires")] + public DateTime? Expires { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + [Optional] + [JsonPropertyName("idpinitiated")] + public EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiated? Idpinitiated { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("protocolBinding")] + public EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum? ProtocolBinding { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("signatureAlgorithm")] + public EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum? SignatureAlgorithm { get; set; } + + /// + /// Identity provider's SAML SingleSignOnService endpoint URL where Auth0 sends SAML authentication requests. This is the primary login URL for the SAML connection. Required unless using metadataUrl or metadataXml. + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Base64-encoded X.509 certificate from the identity provider used to validate signatures in SAML responses and assertions. The certificate is decoded and used for cryptographic signature verification. + /// + [Optional] + [JsonPropertyName("signingCert")] + public string? SigningCert { get; set; } + + /// + /// When true, Auth0 signs SAML authentication requests using the connection's signing key. The signature includes the request's digest and is validated by the identity provider. Defaults to false (unsigned requests). + /// + [Optional] + [JsonPropertyName("signSAMLRequest")] + public bool? SignSamlRequest { get; set; } + + [Optional] + [JsonPropertyName("subject")] + public EventStreamCloudEventConnectionCreatedObject2OptionsSubject? Subject { get; set; } + + /// + /// For SAML connections, the tenant domain used to construct the login endpoint URL. Can be a string for single-tenant or an array of strings for multi-tenant validation. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// SHA-1 thumbprints (fingerprints) of the identity provider's signing certificates. Automatically computed from signingCert during connection creation. Each thumbprint must be a 40-character hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// When true, enables detailed SAML debugging by issuing 'w' (warning) events in tenant logs containing SAML request/response details. WARNING: Potentially exposes sensitive user information (PII, credentials) and should only be enabled temporarily for debugging purposes. + /// + [Optional] + [JsonPropertyName("debug")] + public bool? Debug { get; set; } + + /// + /// When true, enables DEFLATE compression for SAML requests sent via HTTP-Redirect binding. + /// + [Optional] + [JsonPropertyName("deflate")] + public bool? Deflate { get; set; } + + /// + /// The URL where Auth0 will send SAML authentication requests (the Identity Provider's SSO URL). Must be a valid HTTPS URL. + /// + [Optional] + [JsonPropertyName("destinationUrl")] + public string? DestinationUrl { get; set; } + + /// + /// When true, disables sending SAML logout requests (SingleLogoutService) to the identity provider during user sign-out. The user will be logged out of Auth0 but will remain logged into the identity provider. Defaults to false (federated logout enabled). + /// + [Optional] + [JsonPropertyName("disableSignout")] + public bool? DisableSignout { get; set; } + + [Optional] + [JsonPropertyName("fieldsMap")] + public Dictionary? FieldsMap { get; set; } + + /// + /// Expected 'iss' (Issuer) claim value for JWT tokens in Global Token Revocation requests from the identity provider. When configured, Auth0 validates the JWT issuer matches this value before processing token revocation. Must be used together with global_token_revocation_jwt_sub. + /// + [Optional] + [JsonPropertyName("global_token_revocation_jwt_iss")] + public string? GlobalTokenRevocationJwtIss { get; set; } + + /// + /// Expected 'sub' (Subject) claim value for JWT tokens in Global Token Revocation requests from the identity provider. When configured, Auth0 validates the JWT subject matches this value before processing token revocation. Must be used together with global_token_revocation_jwt_iss. + /// + [Optional] + [JsonPropertyName("global_token_revocation_jwt_sub")] + public string? GlobalTokenRevocationJwtSub { get; set; } + + /// + /// HTTPS URL to the identity provider's SAML metadata document. When provided, Auth0 automatically fetches and parses the metadata to extract signInEndpoint, signOutEndpoint, signingCert, signSAMLRequest, and protocolBinding. Use metadataUrl OR metadataXml, not both. + /// + [Optional] + [JsonPropertyName("metadataUrl")] + public string? MetadataUrl { get; set; } + + /// + /// The URL where Auth0 will send SAML authentication requests (the Identity Provider's SSO URL). Must be a valid HTTPS URL. + /// + [Optional] + [JsonPropertyName("recipientUrl")] + public string? RecipientUrl { get; set; } + + /// + /// Custom XML template for SAML authentication requests. Supports variable substitution using @@variableName@@ syntax. When not provided, uses default SAML AuthnRequest template. See https://auth0.com/docs/authenticate/protocols/saml/saml-sso-integrations/configure-auth0-saml-service-provider#customize-the-request-template + /// + [Optional] + [JsonPropertyName("requestTemplate")] + public string? RequestTemplate { get; set; } + + /// + /// Identity provider's SAML SingleLogoutService endpoint URL where Auth0 sends logout requests for federated sign-out. When not provided, defaults to signInEndpoint. Only used if disableSignout is false. + /// + [Optional] + [JsonPropertyName("signOutEndpoint")] + public string? SignOutEndpoint { get; set; } + + /// + /// Custom SAML assertion attribute to use as the unique user identifier. When provided, this attribute is prepended to the default user_id mapping list with highest priority. Accepts a string (single SAML attribute name). + /// + [Optional] + [JsonPropertyName("user_id_attribute")] + public string? UserIdAttribute { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettings.cs new file mode 100644 index 000000000..06b771776 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettings.cs @@ -0,0 +1,39 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Settings for SAML assertion decryption. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of insecure algorithms to allow for SAML assertion decryption. + /// + [Optional] + [JsonPropertyName("algorithm_exceptions")] + public IEnumerable? AlgorithmExceptions { get; set; } + + [JsonPropertyName("algorithm_profile")] + public required EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum AlgorithmProfile { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs new file mode 100644 index 000000000..1e440b13d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs @@ -0,0 +1,134 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum V20261 = + new(Values.V20261); + + public EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string V20261 = "v2026-1"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum.cs new file mode 100644 index 000000000..d37dbbeca --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum.EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum Sha1 = + new(Values.Sha1); + + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum Sha256 = + new(Values.Sha256); + + public EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Sha1 = "sha1"; + + public const string Sha256 = "sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiated.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiated.cs new file mode 100644 index 000000000..727e1a8bc --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiated.cs @@ -0,0 +1,53 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for IdP-Initiated SAML Single Sign-On. When enabled, allows users to initiate login directly from their SAML identity provider without first visiting Auth0. The IdP must include the connection parameter in the post-back URL (Assertion Consumer Service URL). +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiated : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// The query string sent to the default application + /// + [Optional] + [JsonPropertyName("client_authorizequery")] + public string? ClientAuthorizequery { get; set; } + + /// + /// The client ID to use for IdP-initiated login requests. + /// + [Optional] + [JsonPropertyName("client_id")] + public string? ClientId { get; set; } + + [Optional] + [JsonPropertyName("client_protocol")] + public EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum? ClientProtocol { get; set; } + + /// + /// When true, enables IdP-initiated login support for this SAML connection. Allows users to log in directly from the identity provider without first visiting Auth0. + /// + [Optional] + [JsonPropertyName("enabled")] + public bool? Enabled { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum.cs new file mode 100644 index 000000000..587984baf --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum.EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum Oidc = + new(Values.Oidc); + + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum Samlp = + new(Values.Samlp); + + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum Wsfed = + new(Values.Wsfed); + + public EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oidc = "oidc"; + + public const string Samlp = "samlp"; + + public const string Wsfed = "wsfed"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum.cs new file mode 100644 index 000000000..868b00258 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum.EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpPost = + new(Values.UrnOasisNamesTcSaml20BindingsHttpPost); + + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpRedirect = + new(Values.UrnOasisNamesTcSaml20BindingsHttpRedirect); + + public EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string UrnOasisNamesTcSaml20BindingsHttpPost = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"; + + public const string UrnOasisNamesTcSaml20BindingsHttpRedirect = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..66bc31d54 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum.cs new file mode 100644 index 000000000..6df69d168 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum.EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum RsaSha1 = + new(Values.RsaSha1); + + public static readonly EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum RsaSha256 = + new(Values.RsaSha256); + + public EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string RsaSha1 = "rsa-sha1"; + + public const string RsaSha256 = "rsa-sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSubject.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSubject.cs new file mode 100644 index 000000000..db6efb1b0 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2OptionsSubject.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Certificate Subject Distinguished Name (DN) extracted from the identity provider's signing certificate. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject2OptionsSubject : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2StrategyEnum.cs new file mode 100644 index 000000000..42dc0aa2e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject2StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject2StrategyEnum.EventStreamCloudEventConnectionCreatedObject2StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject2StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject2StrategyEnum Samlp = new( + Values.Samlp + ); + + public EventStreamCloudEventConnectionCreatedObject2StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject2StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionCreatedObject2StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject2StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject2StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject2StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject2StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject2StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject2StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject2StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject2StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject2StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Samlp = "samlp"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3.cs new file mode 100644 index 000000000..140ee7a9a --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject3 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionCreatedObject3Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionCreatedObject3ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionCreatedObject3Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionCreatedObject3Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionCreatedObject3StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Authentication.cs new file mode 100644 index 000000000..488ada1e6 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject3Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3ConnectedAccounts.cs new file mode 100644 index 000000000..05a30e469 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject3ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Metadata.cs new file mode 100644 index 000000000..3d248f158 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject3Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Options.cs new file mode 100644 index 000000000..b89644825 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3Options.cs @@ -0,0 +1,150 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'pingfederate' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject3Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("assertion_decryption_settings")] + public EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettings? AssertionDecryptionSettings { get; set; } + + /// + /// X.509 signing certificate from the identity provider in .der format. Used to validate signatures in SAML Responses and Assertions. This is an alternative to signingCert and is kept for backward compatibility. Prefer using signingCert instead. + /// + [Optional] + [JsonPropertyName("cert")] + public string? Cert { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + [Optional] + [JsonPropertyName("digestAlgorithm")] + public EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum? DigestAlgorithm { get; set; } + + /// + /// Domain aliases for the connection + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// The entity identifier (Issuer) for the SAML Service Provider. When not provided, defaults to 'urn:auth0:{tenant}:{connection}'. This value is included in SAML AuthnRequest messages sent to the identity provider. + /// + [Optional] + [JsonPropertyName("entityId")] + public string? EntityId { get; set; } + + /// + /// ISO 8601 formatted datetime indicating when the identity provider's signing certificate expires. + /// + [Optional] + [JsonPropertyName("expires")] + public DateTime? Expires { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + [Optional] + [JsonPropertyName("idpinitiated")] + public EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiated? Idpinitiated { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("protocolBinding")] + public EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum? ProtocolBinding { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("signatureAlgorithm")] + public EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum? SignatureAlgorithm { get; set; } + + /// + /// Identity provider's SAML SingleSignOnService endpoint URL where Auth0 sends SAML authentication requests. This is the primary login URL for the SAML connection. Required unless using metadataUrl or metadataXml. + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Base64-encoded X.509 certificate from the identity provider used to validate signatures in SAML responses and assertions. The certificate is decoded and used for cryptographic signature verification. + /// + [Optional] + [JsonPropertyName("signingCert")] + public string? SigningCert { get; set; } + + /// + /// When true, Auth0 signs SAML authentication requests using the connection's signing key. The signature includes the request's digest and is validated by the identity provider. Defaults to false (unsigned requests). + /// + [Optional] + [JsonPropertyName("signSAMLRequest")] + public bool? SignSamlRequest { get; set; } + + [Optional] + [JsonPropertyName("subject")] + public EventStreamCloudEventConnectionCreatedObject3OptionsSubject? Subject { get; set; } + + /// + /// For SAML connections, the tenant domain used to construct the login endpoint URL. Can be a string for single-tenant or an array of strings for multi-tenant validation. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// SHA-1 thumbprints (fingerprints) of the identity provider's signing certificates. Automatically computed from signingCert during connection creation. Each thumbprint must be a 40-character hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// URL provided by PingFederate which returns information used for creating the connection + /// + [JsonPropertyName("pingFederateBaseUrl")] + public required string PingFederateBaseUrl { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettings.cs new file mode 100644 index 000000000..4d8da12fe --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettings.cs @@ -0,0 +1,39 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Settings for SAML assertion decryption. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of insecure algorithms to allow for SAML assertion decryption. + /// + [Optional] + [JsonPropertyName("algorithm_exceptions")] + public IEnumerable? AlgorithmExceptions { get; set; } + + [JsonPropertyName("algorithm_profile")] + public required EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum AlgorithmProfile { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs new file mode 100644 index 000000000..cf1399e38 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs @@ -0,0 +1,134 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum V20261 = + new(Values.V20261); + + public EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string V20261 = "v2026-1"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum.cs new file mode 100644 index 000000000..22b7c9992 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum.EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum Sha1 = + new(Values.Sha1); + + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum Sha256 = + new(Values.Sha256); + + public EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Sha1 = "sha1"; + + public const string Sha256 = "sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiated.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiated.cs new file mode 100644 index 000000000..26bd0db21 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiated.cs @@ -0,0 +1,53 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for IdP-Initiated SAML Single Sign-On. When enabled, allows users to initiate login directly from their SAML identity provider without first visiting Auth0. The IdP must include the connection parameter in the post-back URL (Assertion Consumer Service URL). +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiated : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// The query string sent to the default application + /// + [Optional] + [JsonPropertyName("client_authorizequery")] + public string? ClientAuthorizequery { get; set; } + + /// + /// The client ID to use for IdP-initiated login requests. + /// + [Optional] + [JsonPropertyName("client_id")] + public string? ClientId { get; set; } + + [Optional] + [JsonPropertyName("client_protocol")] + public EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum? ClientProtocol { get; set; } + + /// + /// When true, enables IdP-initiated login support for this SAML connection. Allows users to log in directly from the identity provider without first visiting Auth0. + /// + [Optional] + [JsonPropertyName("enabled")] + public bool? Enabled { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum.cs new file mode 100644 index 000000000..db251d1b8 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum.EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum Oidc = + new(Values.Oidc); + + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum Samlp = + new(Values.Samlp); + + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum Wsfed = + new(Values.Wsfed); + + public EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oidc = "oidc"; + + public const string Samlp = "samlp"; + + public const string Wsfed = "wsfed"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum.cs new file mode 100644 index 000000000..320aa4ffd --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum.EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpPost = + new(Values.UrnOasisNamesTcSaml20BindingsHttpPost); + + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpRedirect = + new(Values.UrnOasisNamesTcSaml20BindingsHttpRedirect); + + public EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string UrnOasisNamesTcSaml20BindingsHttpPost = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"; + + public const string UrnOasisNamesTcSaml20BindingsHttpRedirect = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..a1707fb31 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum.cs new file mode 100644 index 000000000..8ec00b793 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum.EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum RsaSha1 = + new(Values.RsaSha1); + + public static readonly EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum RsaSha256 = + new(Values.RsaSha256); + + public EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string RsaSha1 = "rsa-sha1"; + + public const string RsaSha256 = "rsa-sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSubject.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSubject.cs new file mode 100644 index 000000000..7be857d2b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3OptionsSubject.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Certificate Subject Distinguished Name (DN) extracted from the identity provider's signing certificate. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject3OptionsSubject : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3StrategyEnum.cs new file mode 100644 index 000000000..59cba2f70 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject3StrategyEnum.cs @@ -0,0 +1,124 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject3StrategyEnum.EventStreamCloudEventConnectionCreatedObject3StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject3StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject3StrategyEnum Pingfederate = + new(Values.Pingfederate); + + public EventStreamCloudEventConnectionCreatedObject3StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject3StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionCreatedObject3StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject3StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject3StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject3StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject3StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject3StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject3StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject3StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject3StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject3StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Pingfederate = "pingfederate"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4.cs new file mode 100644 index 000000000..1c6fbbbdc --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject4 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionCreatedObject4Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionCreatedObject4ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionCreatedObject4Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionCreatedObject4Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionCreatedObject4StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Authentication.cs new file mode 100644 index 000000000..bcca7c356 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject4Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4ConnectedAccounts.cs new file mode 100644 index 000000000..5e0bc32b8 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject4ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Metadata.cs new file mode 100644 index 000000000..c720d9b7d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject4Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Options.cs new file mode 100644 index 000000000..71bb0d93f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4Options.cs @@ -0,0 +1,124 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'adfs' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject4Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// ADFS federation metadata host or XML URL used to discover WS-Fed endpoints and certificates. Errors if adfs_server and fedMetadataXml are both absent. + /// + [Optional] + [JsonPropertyName("adfs_server")] + public string? AdfsServer { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// The entity identifier (Issuer) for the ADFS Service Provider. When not provided, defaults to 'urn:auth0:{tenant}:{connection}'. + /// + [Optional] + [JsonPropertyName("entityId")] + public string? EntityId { get; set; } + + /// + /// Inline XML alternative to 'adfs_server'. Cannot be set together with 'adfs_server'. + /// + [Optional] + [JsonPropertyName("fedMetadataXml")] + public string? FedMetadataXml { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + /// + /// Array of certificate thumbprints (SHA-128/SHA-256/SHA-512 hex hashes) for validating SAML signatures. Used with WS-Federation protocol. Maximum 20 thumbprints. Each thumbprint must be a hexadecimal string. + /// + [Optional] + [JsonPropertyName("prev_thumbprints")] + public IEnumerable? PrevThumbprints { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("should_trust_email_verified_connection")] + public EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum? ShouldTrustEmailVerifiedConnection { get; set; } + + /// + /// Passive Requestor (WS-Fed) sign-in endpoint discovered from metadata or provided explicitly. + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Tenant domain + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// Array of certificate thumbprints (SHA-128/SHA-256/SHA-512 hex hashes) for validating SAML signatures. Used with WS-Federation protocol. Maximum 20 thumbprints. Each thumbprint must be a hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Custom ADFS claim to use as the unique user identifier. When provided, this attribute is prepended to the default user_id mapping list with highest priority. Accepts a string (single ADFS claim name). + /// + [Optional] + [JsonPropertyName("user_id_attribute")] + public string? UserIdAttribute { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..e52972110 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject4OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs new file mode 100644 index 000000000..78c3c52e0 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum NeverSetEmailsAsVerified = + new(Values.NeverSetEmailsAsVerified); + + public static readonly EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum AlwaysSetEmailsAsVerified = + new(Values.AlwaysSetEmailsAsVerified); + + public EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string NeverSetEmailsAsVerified = "never_set_emails_as_verified"; + + public const string AlwaysSetEmailsAsVerified = "always_set_emails_as_verified"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4StrategyEnum.cs new file mode 100644 index 000000000..6fa78ebd4 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject4StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject4StrategyEnum.EventStreamCloudEventConnectionCreatedObject4StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject4StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject4StrategyEnum Adfs = new( + Values.Adfs + ); + + public EventStreamCloudEventConnectionCreatedObject4StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject4StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionCreatedObject4StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject4StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject4StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject4StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject4StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject4StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject4StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject4StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject4StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject4StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject4StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject4StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Adfs = "adfs"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5.cs new file mode 100644 index 000000000..65974708f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5.cs @@ -0,0 +1,84 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject5 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionCreatedObject5Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionCreatedObject5ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionCreatedObject5Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionCreatedObject5Options? Options { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionCreatedObject5StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Authentication.cs new file mode 100644 index 000000000..e2a8dfc89 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject5Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5ConnectedAccounts.cs new file mode 100644 index 000000000..430357e72 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject5ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Metadata.cs new file mode 100644 index 000000000..85e795055 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject5Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Options.cs new file mode 100644 index 000000000..6536ccafe --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5Options.cs @@ -0,0 +1,148 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'ad' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject5Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// IP address of the AD connector agent used to validate that authentication requests originate from the corporate network for Kerberos authentication (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("agentIP")] + public string? AgentIp { get; set; } + + /// + /// When enabled, allows direct username/password authentication through the AD connector agent instead of WS-Federation protocol (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("agentMode")] + public bool? AgentMode { get; set; } + + /// + /// Version identifier of the installed AD connector agent software (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("agentVersion")] + public string? AgentVersion { get; set; } + + /// + /// Enables Auth0's brute force protection to prevent credential stuffing attacks. When enabled, blocks suspicious login attempts from specific IP addresses after repeated failures. + /// + [Optional] + [JsonPropertyName("brute_force_protection")] + public bool? BruteForceProtection { get; set; } + + /// + /// Enables client SSL certificate authentication for the AD connector, requiring HTTPS on the sign-in endpoint + /// + [Optional] + [JsonPropertyName("certAuth")] + public bool? CertAuth { get; set; } + + /// + /// Array of X.509 certificates in PEM format used for validating SAML signatures from the AD identity provider (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("certs")] + public IEnumerable? Certs { get; set; } + + /// + /// When enabled, disables caching of AD connector authentication results to ensure real-time validation against the directory + /// + [Optional] + [JsonPropertyName("disable_cache")] + public bool? DisableCache { get; set; } + + /// + /// When enabled, hides the 'Forgot Password' link on login pages to prevent users from initiating self-service password resets + /// + [Optional] + [JsonPropertyName("disable_self_service_change_password")] + public bool? DisableSelfServiceChangePassword { get; set; } + + /// + /// List of domain names that can be used with identifier-first authentication flow to route users to this AD connection; each domain must be a valid DNS name up to 256 characters + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// https url of the icon to be shown + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Array of IP address ranges in CIDR notation used to determine if authentication requests originate from the corporate network for Kerberos or certificate authentication. + /// + [Optional] + [JsonPropertyName("ips")] + public IEnumerable? Ips { get; set; } + + /// + /// Enables Windows Integrated Authentication (Kerberos) for seamless SSO when users authenticate from within the corporate network IP ranges + /// + [Optional] + [JsonPropertyName("kerberos")] + public bool? Kerberos { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// The sign-in endpoint type for the AD-LDAP connector agent (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Primary AD domain hint used for HRD and discovery. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// Array of certificate SHA-1 thumbprints for validating signatures. Managed by Auth0 when using the AD Connector agent. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..a9aec51c6 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject5OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5StrategyEnum.cs new file mode 100644 index 000000000..f48d781b7 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject5StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject5StrategyEnum.EventStreamCloudEventConnectionCreatedObject5StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject5StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject5StrategyEnum Ad = new( + Values.Ad + ); + + public EventStreamCloudEventConnectionCreatedObject5StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject5StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionCreatedObject5StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject5StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject5StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject5StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject5StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject5StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject5StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject5StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject5StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject5StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject5StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject5StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Ad = "ad"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6.cs new file mode 100644 index 000000000..afd1947ab --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject6 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionCreatedObject6Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionCreatedObject6ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionCreatedObject6Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionCreatedObject6Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionCreatedObject6StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Authentication.cs new file mode 100644 index 000000000..09900151a --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject6Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6ConnectedAccounts.cs new file mode 100644 index 000000000..eb3df2be3 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject6ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Metadata.cs new file mode 100644 index 000000000..89a2f7e70 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject6Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Options.cs new file mode 100644 index 000000000..b6654cac3 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6Options.cs @@ -0,0 +1,179 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'google-apps' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject6Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Expiration timestamp for the `admin_access_token` in ISO 8601 format. Auth0 uses this value to determine when to refresh the token. + /// + [Optional] + [JsonPropertyName("admin_access_token_expiresin")] + public DateTime? AdminAccessTokenExpiresin { get; set; } + + /// + /// When true, allows customization of OAuth scopes requested during user login. Custom scopes are appended to the mandatory email and profile scopes. When false or omitted, only the default email and profile scopes are used. This property is automatically enabled when Token Vault or Connected Accounts features are activated. + /// + [Optional] + [JsonPropertyName("allow_setting_login_scopes")] + public bool? AllowSettingLoginScopes { get; set; } + + /// + /// Enables integration with the Google Workspace Admin SDK Directory API for groups. When true, Auth0 can synchronize groups & group memberships and supports inbound directory provisioning for groups. Defaults to false. + /// + [Optional] + [JsonPropertyName("api_enable_groups")] + public bool? ApiEnableGroups { get; set; } + + /// + /// Enables integration with the Google Workspace Admin SDK Directory API. When true, Auth0 can retrieve extended user attributes (admin status, suspension status, group memberships) and supports inbound directory provisioning (SCIM). Defaults to true. + /// + [Optional] + [JsonPropertyName("api_enable_users")] + public bool? ApiEnableUsers { get; set; } + + /// + /// Your Google OAuth 2.0 client ID. You can find this in your [Google Cloud Console](https://console.cloud.google.com/apis/credentials) under the OAuth 2.0 Client IDs section. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + /// + /// Primary Google Workspace domain name that users must belong to. + /// + [Optional] + [JsonPropertyName("domain")] + public string? Domain { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// Whether the OAuth flow requests the `email` scope. + /// + [Optional] + [JsonPropertyName("email")] + public bool? Email { get; set; } + + /// + /// Fetches the `agreedToTerms` flag from the Google Directory profile. + /// + [Optional] + [JsonPropertyName("ext_agreed_terms")] + public bool? ExtAgreedTerms { get; set; } + + /// + /// Enables enrichment with Google group memberships (required for `ext_groups_extended`). + /// + [Optional] + [JsonPropertyName("ext_groups")] + public bool? ExtGroups { get; set; } + + /// + /// Controls whether enriched group entries include `id`, `email`, `name` (true) or only the group name (false); can only be set when `ext_groups` is true. + /// + [Optional] + [JsonPropertyName("ext_groups_extended")] + public bool? ExtGroupsExtended { get; set; } + + /// + /// Fetches the Google Directory admin flag for the signing-in user. + /// + [Optional] + [JsonPropertyName("ext_is_admin")] + public bool? ExtIsAdmin { get; set; } + + /// + /// Fetches the Google Directory suspended flag for the signing-in user. + /// + [Optional] + [JsonPropertyName("ext_is_suspended")] + public bool? ExtIsSuspended { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionCreatedObject6OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// When enabled, users who sign in with their Google account through a social login will be automatically routed to this Google Workspace connection if their email domain matches the configured tenant_domain or domain_aliases. This ensures enterprise users authenticate through their organization's Google Workspace identity provider rather than through a generic Google social login, enabling access to directory-based attributes and enforcing organizational security policies. Defaults to true for new connections. + /// + [Optional] + [JsonPropertyName("handle_login_from_social")] + public bool? HandleLoginFromSocial { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Determines how Auth0 generates the user_id for Google Workspace users. When false (default), the user's email address is used. When true, Google's stable numeric user ID is used instead, which persists even if the user's email changes. This setting can only be configured when creating the connection and cannot be changed afterward. + /// + [Optional] + [JsonPropertyName("map_user_id_to_id")] + public bool? MapUserIdToId { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + /// + /// Whether the OAuth flow requests the `profile` scope. + /// + [Optional] + [JsonPropertyName("profile")] + public bool? Profile { get; set; } + + /// + /// Additional OAuth scopes requested beyond the default `email profile` scopes; ignored unless `allow_setting_login_scopes` is true. + /// + [Optional] + [JsonPropertyName("scope")] + public IEnumerable? Scope { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// The Google Workspace primary domain used to identify the organization during authentication. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..816686a48 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject6OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..c4e649d6b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject6OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6StrategyEnum.cs new file mode 100644 index 000000000..dc296ef6d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject6StrategyEnum.cs @@ -0,0 +1,124 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject6StrategyEnum.EventStreamCloudEventConnectionCreatedObject6StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject6StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject6StrategyEnum GoogleApps = + new(Values.GoogleApps); + + public EventStreamCloudEventConnectionCreatedObject6StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject6StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionCreatedObject6StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject6StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject6StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject6StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject6StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject6StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject6StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject6StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject6StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject6StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject6StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject6StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string GoogleApps = "google-apps"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7.cs new file mode 100644 index 000000000..ef77d3589 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject7 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionCreatedObject7Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionCreatedObject7ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionCreatedObject7Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionCreatedObject7Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionCreatedObject7StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Authentication.cs new file mode 100644 index 000000000..8c54d8bc1 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject7Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7ConnectedAccounts.cs new file mode 100644 index 000000000..c77d39af1 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject7ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Metadata.cs new file mode 100644 index 000000000..1cb5006b8 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject7Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Options.cs new file mode 100644 index 000000000..ca45210f0 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7Options.cs @@ -0,0 +1,199 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'waad' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject7Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enable users API + /// + [Optional] + [JsonPropertyName("api_enable_users")] + public bool? ApiEnableUsers { get; set; } + + /// + /// The Azure AD application domain (e.g., 'contoso.onmicrosoft.com'). Used primarily with WS-Federation protocol and Azure AD v1 endpoints. + /// + [Optional] + [JsonPropertyName("app_domain")] + public string? AppDomain { get; set; } + + /// + /// The Application ID URI (App ID URI) for the Azure AD application. Required when using Azure AD v1 with the Resource Owner Password flow. Used to identify the resource being requested in OAuth token requests. + /// + [Optional] + [JsonPropertyName("app_id")] + public string? AppId { get; set; } + + /// + /// Includes basic user profile information from Azure AD (name, email, given_name, family_name). Always enabled and required - represents the minimum profile data retrieved during authentication. + /// + [Optional] + [JsonPropertyName("basic_profile")] + public bool? BasicProfile { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + /// + /// OAuth 2.0 client identifier issued by the identity provider during application registration. This value identifies your Auth0 connection to the identity provider. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + /// + /// The primary Azure AD tenant domain (e.g., 'contoso.onmicrosoft.com' or 'contoso.com'). + /// + [Optional] + [JsonPropertyName("domain")] + public string? Domain { get; set; } + + /// + /// Alternative domain names associated with this Azure AD tenant. Allows users from multiple verified domains to authenticate through this connection. Can be an array of domain strings. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// When enabled (true), retrieves and stores Azure AD security group memberships for the user. Requires Microsoft Graph API permissions (Directory.Read.All). Allows configuring max_groups_to_retrieve. + /// + [Optional] + [JsonPropertyName("ext_groups")] + public bool? ExtGroups { get; set; } + + /// + /// When true, stores all groups the user is member of, including transitive group memberships (groups within groups). When false (default), only direct group memberships are included. + /// + [Optional] + [JsonPropertyName("ext_nested_groups")] + public bool? ExtNestedGroups { get; set; } + + /// + /// When enabled (true), retrieves extended profile attributes from Azure AD via Microsoft Graph API (job title, department, office location, etc.). Requires Graph API permissions. Only available with Azure AD v1 or when explicitly enabled for v2. + /// + [Optional] + [JsonPropertyName("ext_profile")] + public bool? ExtProfile { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionCreatedObject7OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// Indicates whether admin consent has been granted for the required Azure AD permissions. Read-only status field managed by Auth0 during the OAuth authorization flow. + /// + [Optional] + [JsonPropertyName("granted")] + public bool? Granted { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + [Optional] + [JsonPropertyName("identity_api")] + public EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum? IdentityApi { get; set; } + + /// + /// Maximum number of Azure AD groups to retrieve per user during authentication. Helps prevent performance issues for users in many groups. Only applies when ext_groups is enabled. Leave empty to use platform default. + /// + [Optional] + [JsonPropertyName("max_groups_to_retrieve")] + public string? MaxGroupsToRetrieve { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + /// + /// OAuth 2.0 scopes to request from Azure AD during authentication. Each scope represents a permission (e.g., 'User.Read', 'Group.Read.All'). Only applies with Microsoft Identity Platform v2.0. See Microsoft Graph permissions reference for available scopes. + /// + [Optional] + [JsonPropertyName("scope")] + public IEnumerable? Scope { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("should_trust_email_verified_connection")] + public EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum? ShouldTrustEmailVerifiedConnection { get; set; } + + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// The Azure AD tenant ID as a UUID. The unique identifier for your Azure AD organization. Must be a valid 36-character UUID. + /// + [Optional] + [JsonPropertyName("tenantId")] + public string? TenantId { get; set; } + + /// + /// Array of certificate thumbprints (SHA-128/SHA-256/SHA-512 hex hashes) for validating SAML signatures. Used with WS-Federation protocol. Maximum 20 thumbprints. Each thumbprint must be a hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Indicates WS-Federation protocol usage. When true, uses WS-Federation; when false, uses OpenID Connect. + /// + [Optional] + [JsonPropertyName("use_wsfed")] + public bool? UseWsfed { get; set; } + + /// + /// When enabled (true), uses the Azure AD common endpoint for multi-tenant authentication. Allows users from any Azure AD organization to sign in. Requires userid_attribute set to 'sub' (not 'oid'). Cannot be used with SCIM provisioning. Defaults to false. + /// + [Optional] + [JsonPropertyName("useCommonEndpoint")] + public bool? UseCommonEndpoint { get; set; } + + [Optional] + [JsonPropertyName("userid_attribute")] + public EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum? UseridAttribute { get; set; } + + [Optional] + [JsonPropertyName("waad_protocol")] + public EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum? WaadProtocol { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..0d78bbbdb --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionCreatedObject7OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum.cs new file mode 100644 index 000000000..6d7836d01 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum.EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum MicrosoftIdentityPlatformV20 = + new(Values.MicrosoftIdentityPlatformV20); + + public static readonly EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum AzureActiveDirectoryV10 = + new(Values.AzureActiveDirectoryV10); + + public EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7OptionsIdentityApiEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string MicrosoftIdentityPlatformV20 = "microsoft-identity-platform-v2.0"; + + public const string AzureActiveDirectoryV10 = "azure-active-directory-v1.0"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..ffe5b2e6f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs new file mode 100644 index 000000000..edd7527ff --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum NeverSetEmailsAsVerified = + new(Values.NeverSetEmailsAsVerified); + + public static readonly EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum AlwaysSetEmailsAsVerified = + new(Values.AlwaysSetEmailsAsVerified); + + public EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string NeverSetEmailsAsVerified = "never_set_emails_as_verified"; + + public const string AlwaysSetEmailsAsVerified = "always_set_emails_as_verified"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum.cs new file mode 100644 index 000000000..9f345633d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum.EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum Oid = + new(Values.Oid); + + public static readonly EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum Sub = + new(Values.Sub); + + public EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7OptionsUseridAttributeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oid = "oid"; + + public const string Sub = "sub"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum.cs new file mode 100644 index 000000000..0bd1394a9 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum.EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum WsFederation = + new(Values.WsFederation); + + public static readonly EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum OpenidConnect = + new(Values.OpenidConnect); + + public EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7OptionsWaadProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string WsFederation = "ws-federation"; + + public const string OpenidConnect = "openid-connect"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7StrategyEnum.cs new file mode 100644 index 000000000..ea0babb6b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedObject7StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedObject7StrategyEnum.EventStreamCloudEventConnectionCreatedObject7StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedObject7StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedObject7StrategyEnum Waad = new( + Values.Waad + ); + + public EventStreamCloudEventConnectionCreatedObject7StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedObject7StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionCreatedObject7StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedObject7StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedObject7StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionCreatedObject7StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedObject7StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionCreatedObject7StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedObject7StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedObject7StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedObject7StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedObject7StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Waad = "waad"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedTypeEnum.cs new file mode 100644 index 000000000..f40ac2bde --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionCreatedTypeEnum.cs @@ -0,0 +1,122 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionCreatedTypeEnum.EventStreamCloudEventConnectionCreatedTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionCreatedTypeEnum : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionCreatedTypeEnum ConnectionCreated = new( + Values.ConnectionCreated + ); + + public EventStreamCloudEventConnectionCreatedTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionCreatedTypeEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionCreatedTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionCreatedTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionCreatedTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string(EventStreamCloudEventConnectionCreatedTypeEnum value) => + value.Value; + + public static explicit operator EventStreamCloudEventConnectionCreatedTypeEnum(string value) => + new(value); + + internal class EventStreamCloudEventConnectionCreatedTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionCreatedTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionCreatedTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionCreatedTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionCreatedTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ConnectionCreated = "connection.created"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeleted.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeleted.cs new file mode 100644 index 000000000..74db57d33 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeleted.cs @@ -0,0 +1,37 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// SSE message for connection.deleted. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeleted : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Opaque cursor representing position in the stream. Pass as the `from` query parameter to resume. + /// + [JsonPropertyName("offset")] + public required string Offset { get; set; } + + [JsonPropertyName("event")] + public required EventStreamCloudEventConnectionDeletedCloudEvent Event { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedCloudEvent.cs new file mode 100644 index 000000000..8e3a49c24 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedCloudEvent.cs @@ -0,0 +1,71 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Represents an event that occurs when a connection is deleted. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedCloudEvent : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("specversion")] + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } + + [JsonPropertyName("type")] + public required EventStreamCloudEventConnectionDeletedCloudEventTypeEnum Type { get; set; } + + /// + /// The source of the event. This will take the form 'urn:auth0:<tenant>.<domain>'. + /// + [JsonPropertyName("source")] + public required string Source { get; set; } + + /// + /// A unique identifier for the event. + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// An ISO-8601 timestamp indicating when the event physically occurred. + /// + [JsonPropertyName("time")] + public required DateTime Time { get; set; } + + [JsonPropertyName("data")] + public required EventStreamCloudEventConnectionDeletedData Data { get; set; } + + /// + /// The auth0 tenant ID to which the event is associated. + /// + [JsonPropertyName("a0tenant")] + public required string A0Tenant { get; set; } + + /// + /// The auth0 event stream ID of the stream the event was delivered on. + /// + [JsonPropertyName("a0stream")] + public required string A0Stream { get; set; } + + [Optional] + [JsonPropertyName("a0purpose")] + public EventStreamCloudEventA0PurposeEnum? A0Purpose { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedCloudEventTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedCloudEventTypeEnum.cs new file mode 100644 index 000000000..c2d42d12e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedCloudEventTypeEnum.cs @@ -0,0 +1,123 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedCloudEventTypeEnum.EventStreamCloudEventConnectionDeletedCloudEventTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedCloudEventTypeEnum : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedCloudEventTypeEnum ConnectionDeleted = + new(Values.ConnectionDeleted); + + public EventStreamCloudEventConnectionDeletedCloudEventTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedCloudEventTypeEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionDeletedCloudEventTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedCloudEventTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedCloudEventTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedCloudEventTypeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedCloudEventTypeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedCloudEventTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedCloudEventTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedCloudEventTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedCloudEventTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedCloudEventTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedCloudEventTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedCloudEventTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ConnectionDeleted = "connection.deleted"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedData.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedData.cs new file mode 100644 index 000000000..40819efce --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedData.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// The event payload. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedData : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("object")] + public required EventStreamCloudEventConnectionDeletedObject Object { get; set; } + + [Optional] + [JsonPropertyName("context")] + public EventStreamCloudEventContext? Context { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject.cs new file mode 100644 index 000000000..0f007129e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject.cs @@ -0,0 +1,675 @@ +// ReSharper disable NullableWarningSuppressionIsUsed +// ReSharper disable InconsistentNaming + +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// The event content. +/// +[JsonConverter(typeof(EventStreamCloudEventConnectionDeletedObject.JsonConverter))] +[Serializable] +public class EventStreamCloudEventConnectionDeletedObject +{ + private EventStreamCloudEventConnectionDeletedObject(string type, object? value) + { + Type = type; + Value = value; + } + + /// + /// Type discriminator + /// + [JsonIgnore] + public string Type { get; internal set; } + + /// + /// Union value + /// + [JsonIgnore] + public object? Value { get; internal set; } + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject0 value. + /// + public static EventStreamCloudEventConnectionDeletedObject FromEventStreamCloudEventConnectionDeletedObject0( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject0 value + ) => new("eventStreamCloudEventConnectionDeletedObject0", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject1 value. + /// + public static EventStreamCloudEventConnectionDeletedObject FromEventStreamCloudEventConnectionDeletedObject1( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject1 value + ) => new("eventStreamCloudEventConnectionDeletedObject1", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject2 value. + /// + public static EventStreamCloudEventConnectionDeletedObject FromEventStreamCloudEventConnectionDeletedObject2( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject2 value + ) => new("eventStreamCloudEventConnectionDeletedObject2", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject3 value. + /// + public static EventStreamCloudEventConnectionDeletedObject FromEventStreamCloudEventConnectionDeletedObject3( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject3 value + ) => new("eventStreamCloudEventConnectionDeletedObject3", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject4 value. + /// + public static EventStreamCloudEventConnectionDeletedObject FromEventStreamCloudEventConnectionDeletedObject4( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject4 value + ) => new("eventStreamCloudEventConnectionDeletedObject4", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject5 value. + /// + public static EventStreamCloudEventConnectionDeletedObject FromEventStreamCloudEventConnectionDeletedObject5( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject5 value + ) => new("eventStreamCloudEventConnectionDeletedObject5", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject6 value. + /// + public static EventStreamCloudEventConnectionDeletedObject FromEventStreamCloudEventConnectionDeletedObject6( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject6 value + ) => new("eventStreamCloudEventConnectionDeletedObject6", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject7 value. + /// + public static EventStreamCloudEventConnectionDeletedObject FromEventStreamCloudEventConnectionDeletedObject7( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject7 value + ) => new("eventStreamCloudEventConnectionDeletedObject7", value); + + /// + /// Returns true if is "eventStreamCloudEventConnectionDeletedObject0" + /// + public bool IsEventStreamCloudEventConnectionDeletedObject0() => + Type == "eventStreamCloudEventConnectionDeletedObject0"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionDeletedObject1" + /// + public bool IsEventStreamCloudEventConnectionDeletedObject1() => + Type == "eventStreamCloudEventConnectionDeletedObject1"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionDeletedObject2" + /// + public bool IsEventStreamCloudEventConnectionDeletedObject2() => + Type == "eventStreamCloudEventConnectionDeletedObject2"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionDeletedObject3" + /// + public bool IsEventStreamCloudEventConnectionDeletedObject3() => + Type == "eventStreamCloudEventConnectionDeletedObject3"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionDeletedObject4" + /// + public bool IsEventStreamCloudEventConnectionDeletedObject4() => + Type == "eventStreamCloudEventConnectionDeletedObject4"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionDeletedObject5" + /// + public bool IsEventStreamCloudEventConnectionDeletedObject5() => + Type == "eventStreamCloudEventConnectionDeletedObject5"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionDeletedObject6" + /// + public bool IsEventStreamCloudEventConnectionDeletedObject6() => + Type == "eventStreamCloudEventConnectionDeletedObject6"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionDeletedObject7" + /// + public bool IsEventStreamCloudEventConnectionDeletedObject7() => + Type == "eventStreamCloudEventConnectionDeletedObject7"; + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionDeletedObject0', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionDeletedObject0'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject0 AsEventStreamCloudEventConnectionDeletedObject0() => + IsEventStreamCloudEventConnectionDeletedObject0() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject0)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionDeletedObject0'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionDeletedObject1', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionDeletedObject1'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject1 AsEventStreamCloudEventConnectionDeletedObject1() => + IsEventStreamCloudEventConnectionDeletedObject1() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject1)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionDeletedObject1'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionDeletedObject2', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionDeletedObject2'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject2 AsEventStreamCloudEventConnectionDeletedObject2() => + IsEventStreamCloudEventConnectionDeletedObject2() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject2)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionDeletedObject2'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionDeletedObject3', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionDeletedObject3'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject3 AsEventStreamCloudEventConnectionDeletedObject3() => + IsEventStreamCloudEventConnectionDeletedObject3() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject3)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionDeletedObject3'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionDeletedObject4', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionDeletedObject4'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject4 AsEventStreamCloudEventConnectionDeletedObject4() => + IsEventStreamCloudEventConnectionDeletedObject4() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject4)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionDeletedObject4'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionDeletedObject5', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionDeletedObject5'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject5 AsEventStreamCloudEventConnectionDeletedObject5() => + IsEventStreamCloudEventConnectionDeletedObject5() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject5)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionDeletedObject5'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionDeletedObject6', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionDeletedObject6'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject6 AsEventStreamCloudEventConnectionDeletedObject6() => + IsEventStreamCloudEventConnectionDeletedObject6() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject6)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionDeletedObject6'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionDeletedObject7', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionDeletedObject7'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject7 AsEventStreamCloudEventConnectionDeletedObject7() => + IsEventStreamCloudEventConnectionDeletedObject7() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject7)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionDeletedObject7'" + ); + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionDeletedObject0( + out Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject0? value + ) + { + if (Type == "eventStreamCloudEventConnectionDeletedObject0") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject0)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionDeletedObject1( + out Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject1? value + ) + { + if (Type == "eventStreamCloudEventConnectionDeletedObject1") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject1)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionDeletedObject2( + out Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject2? value + ) + { + if (Type == "eventStreamCloudEventConnectionDeletedObject2") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject2)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionDeletedObject3( + out Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject3? value + ) + { + if (Type == "eventStreamCloudEventConnectionDeletedObject3") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject3)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionDeletedObject4( + out Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject4? value + ) + { + if (Type == "eventStreamCloudEventConnectionDeletedObject4") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject4)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionDeletedObject5( + out Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject5? value + ) + { + if (Type == "eventStreamCloudEventConnectionDeletedObject5") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject5)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionDeletedObject6( + out Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject6? value + ) + { + if (Type == "eventStreamCloudEventConnectionDeletedObject6") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject6)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionDeletedObject7( + out Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject7? value + ) + { + if (Type == "eventStreamCloudEventConnectionDeletedObject7") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject7)Value!; + return true; + } + value = null; + return false; + } + + public T Match( + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject0, + T + > onEventStreamCloudEventConnectionDeletedObject0, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject1, + T + > onEventStreamCloudEventConnectionDeletedObject1, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject2, + T + > onEventStreamCloudEventConnectionDeletedObject2, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject3, + T + > onEventStreamCloudEventConnectionDeletedObject3, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject4, + T + > onEventStreamCloudEventConnectionDeletedObject4, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject5, + T + > onEventStreamCloudEventConnectionDeletedObject5, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject6, + T + > onEventStreamCloudEventConnectionDeletedObject6, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject7, + T + > onEventStreamCloudEventConnectionDeletedObject7 + ) + { + return Type switch + { + "eventStreamCloudEventConnectionDeletedObject0" => + onEventStreamCloudEventConnectionDeletedObject0( + AsEventStreamCloudEventConnectionDeletedObject0() + ), + "eventStreamCloudEventConnectionDeletedObject1" => + onEventStreamCloudEventConnectionDeletedObject1( + AsEventStreamCloudEventConnectionDeletedObject1() + ), + "eventStreamCloudEventConnectionDeletedObject2" => + onEventStreamCloudEventConnectionDeletedObject2( + AsEventStreamCloudEventConnectionDeletedObject2() + ), + "eventStreamCloudEventConnectionDeletedObject3" => + onEventStreamCloudEventConnectionDeletedObject3( + AsEventStreamCloudEventConnectionDeletedObject3() + ), + "eventStreamCloudEventConnectionDeletedObject4" => + onEventStreamCloudEventConnectionDeletedObject4( + AsEventStreamCloudEventConnectionDeletedObject4() + ), + "eventStreamCloudEventConnectionDeletedObject5" => + onEventStreamCloudEventConnectionDeletedObject5( + AsEventStreamCloudEventConnectionDeletedObject5() + ), + "eventStreamCloudEventConnectionDeletedObject6" => + onEventStreamCloudEventConnectionDeletedObject6( + AsEventStreamCloudEventConnectionDeletedObject6() + ), + "eventStreamCloudEventConnectionDeletedObject7" => + onEventStreamCloudEventConnectionDeletedObject7( + AsEventStreamCloudEventConnectionDeletedObject7() + ), + _ => throw new ManagementException($"Unknown union type: {Type}"), + }; + } + + public void Visit( + global::System.Action onEventStreamCloudEventConnectionDeletedObject0, + global::System.Action onEventStreamCloudEventConnectionDeletedObject1, + global::System.Action onEventStreamCloudEventConnectionDeletedObject2, + global::System.Action onEventStreamCloudEventConnectionDeletedObject3, + global::System.Action onEventStreamCloudEventConnectionDeletedObject4, + global::System.Action onEventStreamCloudEventConnectionDeletedObject5, + global::System.Action onEventStreamCloudEventConnectionDeletedObject6, + global::System.Action onEventStreamCloudEventConnectionDeletedObject7 + ) + { + switch (Type) + { + case "eventStreamCloudEventConnectionDeletedObject0": + onEventStreamCloudEventConnectionDeletedObject0( + AsEventStreamCloudEventConnectionDeletedObject0() + ); + break; + case "eventStreamCloudEventConnectionDeletedObject1": + onEventStreamCloudEventConnectionDeletedObject1( + AsEventStreamCloudEventConnectionDeletedObject1() + ); + break; + case "eventStreamCloudEventConnectionDeletedObject2": + onEventStreamCloudEventConnectionDeletedObject2( + AsEventStreamCloudEventConnectionDeletedObject2() + ); + break; + case "eventStreamCloudEventConnectionDeletedObject3": + onEventStreamCloudEventConnectionDeletedObject3( + AsEventStreamCloudEventConnectionDeletedObject3() + ); + break; + case "eventStreamCloudEventConnectionDeletedObject4": + onEventStreamCloudEventConnectionDeletedObject4( + AsEventStreamCloudEventConnectionDeletedObject4() + ); + break; + case "eventStreamCloudEventConnectionDeletedObject5": + onEventStreamCloudEventConnectionDeletedObject5( + AsEventStreamCloudEventConnectionDeletedObject5() + ); + break; + case "eventStreamCloudEventConnectionDeletedObject6": + onEventStreamCloudEventConnectionDeletedObject6( + AsEventStreamCloudEventConnectionDeletedObject6() + ); + break; + case "eventStreamCloudEventConnectionDeletedObject7": + onEventStreamCloudEventConnectionDeletedObject7( + AsEventStreamCloudEventConnectionDeletedObject7() + ); + break; + default: + throw new ManagementException($"Unknown union type: {Type}"); + } + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Type.GetHashCode(); + if (Value != null) + { + hashCode = (hashCode * 397) ^ Value.GetHashCode(); + } + return hashCode; + } + } + + public override bool Equals(object? obj) + { + if (obj is null) + return false; + if (ReferenceEquals(this, obj)) + return true; + if (obj is not EventStreamCloudEventConnectionDeletedObject other) + return false; + + // Compare type discriminators + if (Type != other.Type) + return false; + + // Compare values using EqualityComparer for deep comparison + return System.Collections.Generic.EqualityComparer.Default.Equals( + Value, + other.Value + ); + } + + public override string ToString() => JsonUtils.Serialize(this); + + public static implicit operator EventStreamCloudEventConnectionDeletedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject0 value + ) => new("eventStreamCloudEventConnectionDeletedObject0", value); + + public static implicit operator EventStreamCloudEventConnectionDeletedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject1 value + ) => new("eventStreamCloudEventConnectionDeletedObject1", value); + + public static implicit operator EventStreamCloudEventConnectionDeletedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject2 value + ) => new("eventStreamCloudEventConnectionDeletedObject2", value); + + public static implicit operator EventStreamCloudEventConnectionDeletedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject3 value + ) => new("eventStreamCloudEventConnectionDeletedObject3", value); + + public static implicit operator EventStreamCloudEventConnectionDeletedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject4 value + ) => new("eventStreamCloudEventConnectionDeletedObject4", value); + + public static implicit operator EventStreamCloudEventConnectionDeletedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject5 value + ) => new("eventStreamCloudEventConnectionDeletedObject5", value); + + public static implicit operator EventStreamCloudEventConnectionDeletedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject6 value + ) => new("eventStreamCloudEventConnectionDeletedObject6", value); + + public static implicit operator EventStreamCloudEventConnectionDeletedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject7 value + ) => new("eventStreamCloudEventConnectionDeletedObject7", value); + + [Serializable] + internal sealed class JsonConverter + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject? Read( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + if (reader.TokenType == JsonTokenType.Null) + { + return null; + } + + if (reader.TokenType == JsonTokenType.StartObject) + { + var document = JsonDocument.ParseValue(ref reader); + + var types = new (string Key, System.Type Type)[] + { + ( + "eventStreamCloudEventConnectionDeletedObject0", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject0) + ), + ( + "eventStreamCloudEventConnectionDeletedObject1", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject1) + ), + ( + "eventStreamCloudEventConnectionDeletedObject2", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject2) + ), + ( + "eventStreamCloudEventConnectionDeletedObject3", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject3) + ), + ( + "eventStreamCloudEventConnectionDeletedObject4", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject4) + ), + ( + "eventStreamCloudEventConnectionDeletedObject5", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject5) + ), + ( + "eventStreamCloudEventConnectionDeletedObject6", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject6) + ), + ( + "eventStreamCloudEventConnectionDeletedObject7", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionDeletedObject7) + ), + }; + + foreach (var (key, type) in types) + { + try + { + var value = document.Deserialize(type, options); + if (value != null) + { + EventStreamCloudEventConnectionDeletedObject result = new(key, value); + return result; + } + } + catch (JsonException) + { + // Try next type; + } + } + } + + throw new JsonException( + $"Cannot deserialize JSON token {reader.TokenType} into EventStreamCloudEventConnectionDeletedObject" + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject value, + JsonSerializerOptions options + ) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + + value.Visit( + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options) + ); + } + + public override EventStreamCloudEventConnectionDeletedObject ReadAsPropertyName( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = reader.GetString()!; + EventStreamCloudEventConnectionDeletedObject result = new("string", stringValue); + return result; + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value?.ToString() ?? "null"); + } + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0.cs new file mode 100644 index 000000000..5f1b6e1c6 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject0 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionDeletedObject0Authentication? Authentication { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionDeletedObject0Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionDeletedObject0ConnectedAccounts? ConnectedAccounts { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionDeletedObject0Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionDeletedObject0StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Authentication.cs new file mode 100644 index 000000000..0bb229a1d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject0Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0ConnectedAccounts.cs new file mode 100644 index 000000000..d88500b3c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0ConnectedAccounts.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject0ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [Optional] + [JsonPropertyName("cross_app_access")] + public bool? CrossAppAccess { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Metadata.cs new file mode 100644 index 000000000..ac707b1b5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject0Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Options.cs new file mode 100644 index 000000000..0bff77379 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0Options.cs @@ -0,0 +1,180 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'oidc' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject0Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [Optional] + [JsonPropertyName("authorization_endpoint")] + public string? AuthorizationEndpoint { get; set; } + + /// + /// OAuth 2.0 client identifier issued by the identity provider during application registration. This value identifies your Auth0 connection to the identity provider. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + [Optional] + [JsonPropertyName("connection_settings")] + public EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettings? ConnectionSettings { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + [Optional] + [JsonPropertyName("dpop_signing_alg")] + public EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum? DpopSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionDeletedObject0OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// https url of the icon to be shown + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Indicates whether the identity provider supports session expiry via the id_token. If true, the system will use the session_expiry claim in the id_token to determine session expiry. + /// + [Optional] + [JsonPropertyName("id_token_session_expiry_supported")] + public bool? IdTokenSessionExpirySupported { get; set; } + + /// + /// List of algorithms allowed to verify the ID tokens. Applicable when strategy=oidc or okta. + /// + [Optional] + [JsonPropertyName("id_token_signed_response_algs")] + public IEnumerable? IdTokenSignedResponseAlgs { get; set; } + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [Optional] + [JsonPropertyName("issuer")] + public string? Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("oidc_metadata")] + public EventStreamCloudEventConnectionDeletedObject0OptionsOidcMetadata? OidcMetadata { get; set; } + + [Optional] + [JsonPropertyName("schema_version")] + public EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum? SchemaVersion { get; set; } + + /// + /// Space-separated list of OAuth 2.0 scopes requested during authorization. Must include 'openid' (required by OIDC spec). Common values: 'openid profile email'. Additional scopes depend on the identity provider. + /// + [Optional] + [JsonPropertyName("scope")] + public string? Scope { get; set; } + + /// + /// When true and type is 'back_channel', includes a cryptographic nonce in authorization requests to prevent replay attacks. The identity provider must include this nonce in the ID token for validation. + /// + [Optional] + [JsonPropertyName("send_back_channel_nonce")] + public bool? SendBackChannelNonce { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// Tenant domain + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_method")] + public EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum? TokenEndpointAuthMethod { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg")] + public EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum? TokenEndpointAuthSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_jwtca_aud_format")] + public EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum? TokenEndpointJwtcaAudFormat { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + [Optional] + [JsonPropertyName("attribute_map")] + public EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMap? AttributeMap { get; set; } + + /// + /// URL of the identity provider's OIDC Discovery endpoint (/.well-known/openid-configuration). When provided and oidc_metadata is empty, Auth0 automatically retrieves the provider's configuration including endpoints and supported features. + /// + [Optional] + [JsonPropertyName("discovery_url")] + public string? DiscoveryUrl { get; set; } + + [Optional] + [JsonPropertyName("type")] + public EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum? Type { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMap.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMap.cs new file mode 100644 index 000000000..6dffc6d9b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMap.cs @@ -0,0 +1,43 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for mapping claims from the identity provider to Auth0 user profile attributes. Allows customizing which IdP claims populate user fields and how they are transformed. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMap : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("attributes")] + public Dictionary? Attributes { get; set; } + + /// + /// Scopes to send to the IdP's Userinfo endpoint + /// + [Optional] + [JsonPropertyName("userinfo_scope")] + public string? UserinfoScope { get; set; } + + [Optional] + [JsonPropertyName("mapping_mode")] + public EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum? MappingMode { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum.cs new file mode 100644 index 000000000..019ae0834 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum.EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum BindAll = + new(Values.BindAll); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum UseMap = + new(Values.UseMap); + + public EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BindAll = "bind_all"; + + public const string UseMap = "use_map"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettings.cs new file mode 100644 index 000000000..3f281e5cb --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettings.cs @@ -0,0 +1,33 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OAuth 2.0 PKCE (Proof Key for Code Exchange) settings. PKCE enhances security for public clients by preventing authorization code interception attacks. 'auto' (recommended) uses the strongest method supported by the IdP. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("pkce")] + public EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum? Pkce { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum.cs new file mode 100644 index 000000000..dea9c56bb --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum.cs @@ -0,0 +1,149 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum.EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum Auto = + new(Values.Auto); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum S256 = + new(Values.S256); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum Plain = + new(Values.Plain); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum Disabled = + new(Values.Disabled); + + public EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Auto = "auto"; + + public const string S256 = "S256"; + + public const string Plain = "plain"; + + public const string Disabled = "disabled"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum.cs new file mode 100644 index 000000000..9809de504 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum.cs @@ -0,0 +1,145 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum.EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum Es512 = + new(Values.Es512); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum Ed25519 = + new(Values.Ed25519); + + public EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Es512 = "ES512"; + + public const string Ed25519 = "Ed25519"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..e0f4e3578 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject0OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs new file mode 100644 index 000000000..12794f5f8 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum.EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsOidcMetadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsOidcMetadata.cs new file mode 100644 index 000000000..8a8ce1d4f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsOidcMetadata.cs @@ -0,0 +1,283 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OpenID Connect Provider Metadata as per https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject0OptionsOidcMetadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of the Authentication Context Class References that this OP supports + /// + [Optional] + [JsonPropertyName("acr_values_supported")] + public IEnumerable? AcrValuesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [JsonPropertyName("authorization_endpoint")] + public required string AuthorizationEndpoint { get; set; } + + /// + /// JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described in Section 5.6 of OpenID Connect Core 1.0 [OpenID.Core]. If omitted, the implementation supports only normal Claims. + /// + [Optional] + [JsonPropertyName("claim_types_supported")] + public IEnumerable? ClaimTypesSupported { get; set; } + + /// + /// Languages and scripts supported for values in Claims being returned, represented as a JSON array of BCP47 [RFC5646] language tag values. Not all languages and scripts are necessarily supported for all Claim values. + /// + [Optional] + [JsonPropertyName("claims_locales_supported")] + public IEnumerable? ClaimsLocalesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the claims parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("claims_parameter_supported")] + public bool? ClaimsParameterSupported { get; set; } + + /// + /// JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list. + /// + [Optional] + [JsonPropertyName("claims_supported")] + public IEnumerable? ClaimsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("display_values_supported")] + public IEnumerable? DisplayValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported for DPoP proof JWT signing. + /// + [Optional] + [JsonPropertyName("dpop_signing_alg_values_supported")] + public IEnumerable? DpopSigningAlgValuesSupported { get; set; } + + /// + /// URL of the identity provider's logout/end session endpoint. When configured as a static URL, users are redirected here after logging out from Auth0. Must use HTTPS scheme. + /// + [Optional] + [JsonPropertyName("end_session_endpoint")] + public string? EndSessionEndpoint { get; set; } + + /// + /// A list of the OAuth 2.0 Grant Type values that this OP supports. Dynamic OpenID Providers MUST support the authorization_code and implicit Grant Type values and MAY support other Grant Types. If omitted, the default value is ["authorization_code", "implicit"]. + /// + [Optional] + [JsonPropertyName("grant_types_supported")] + public IEnumerable? GrantTypesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT + /// + [Optional] + [JsonPropertyName("id_token_encryption_alg_values_supported")] + public IEnumerable? IdTokenEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("id_token_encryption_enc_values_supported")] + public IEnumerable? IdTokenEncryptionEncValuesSupported { get; set; } + + /// + /// A list of the JWS signing algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT. The algorithm RS256 MUST be included. The value none MAY be supported, but MUST NOT be used unless the Response Type used returns no ID Token from the Authorization Endpoint (such as when using the Authorization Code Flow). https://datatracker.ietf.org/doc/html/rfc7518 + /// + [JsonPropertyName("id_token_signing_alg_values_supported")] + public IEnumerable IdTokenSigningAlgValuesSupported { get; set; } = new List(); + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [JsonPropertyName("issuer")] + public required string Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [JsonPropertyName("jwks_uri")] + public required string JwksUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about the OPs requirements on how the Relying Party can use the data provided by the OP. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_policy_uri")] + public string? OpPolicyUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about OpenID Providers terms of service. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_tos_uri")] + public string? OpTosUri { get; set; } + + /// + /// URL of the OPs Dynamic Client Registration Endpoint. RECOMMENDED but not REQUIRED. https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Registration + /// + [Optional] + [JsonPropertyName("registration_endpoint")] + public string? RegistrationEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_alg_values_supported")] + public IEnumerable? RequestObjectEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_enc_values_supported")] + public IEnumerable? RequestObjectEncryptionEncValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for Request Objects, which are described in Section 6.1 of OpenID Connect Core 1.0 [OpenID.Core]. These algorithms are used both when the Request Object is passed by value (using the request parameter) and when it is passed by reference (using the request_uri parameter). Servers SHOULD support none and RS256. + /// + [Optional] + [JsonPropertyName("request_object_signing_alg_values_supported")] + public IEnumerable? RequestObjectSigningAlgValuesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_parameter_supported")] + public bool? RequestParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request_uri parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_uri_parameter_supported")] + public bool? RequestUriParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP requires use of the request_uri parameter. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("require_request_uri_registration")] + public bool? RequireRequestUriRegistration { get; set; } + + /// + /// A list of the OAuth 2.0 response_mode values that this OP supports. If omitted, the default for Dynamic OpenID Providers is ["query", "fragment"] + /// + [Optional] + [JsonPropertyName("response_modes_supported")] + public IEnumerable? ResponseModesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 response_type values that this OP supports. Dynamic OpenID Providers MUST support the code, id_token, and the token id_token Response Type values + /// + [Optional] + [JsonPropertyName("response_types_supported")] + public IEnumerable? ResponseTypesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 [RFC6749] scope values that this server supports. The server MUST support the openid scope value. Servers MAY choose not to advertise some supported scope values even when this parameter is used, although those defined in [OpenID.Core] SHOULD be listed, if supported. RECOMMENDED but not REQUIRED + /// + [Optional] + [JsonPropertyName("scopes_supported")] + public IEnumerable? ScopesSupported { get; set; } + + /// + /// URL of a page containing human-readable information that developers might want or need to know when using the OpenID Provider. In particular, if the OpenID Provider does not support Dynamic Client Registration, then information on how to register Clients needs to be provided in this documentation. + /// + [Optional] + [JsonPropertyName("service_documentation")] + public string? ServiceDocumentation { get; set; } + + /// + /// A list of the Subject Identifier types that this OP supports. Valid types include pairwise and public + /// + [Optional] + [JsonPropertyName("subject_types_supported")] + public IEnumerable? SubjectTypesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + /// + /// JSON array containing a list of Client Authentication methods supported by this Token Endpoint. The options are client_secret_post, client_secret_basic, client_secret_jwt, and private_key_jwt, as described in Section 9 of OpenID Connect Core 1.0 [OpenID.Core]. Other authentication methods MAY be defined by extensions. If omitted, the default is client_secret_basic -- the HTTP Basic Authentication Scheme specified in Section 2.3.1 of OAuth 2.0 [RFC6749]. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_methods_supported")] + public IEnumerable? TokenEndpointAuthMethodsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg_values_supported")] + public IEnumerable? TokenEndpointAuthSigningAlgValuesSupported { get; set; } + + /// + /// Languages and scripts supported for the user interface, represented as a JSON array of BCP47 [RFC5646] language tag values. + /// + [Optional] + [JsonPropertyName("ui_locales_supported")] + public IEnumerable? UiLocalesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE [JWE] encryption algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_alg_values_supported")] + public IEnumerable? UserinfoEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_enc_values_supported")] + public IEnumerable? UserinfoEncryptionEncValuesSupported { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWS [JWS] signing algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. The value none MAY be included. + /// + [Optional] + [JsonPropertyName("userinfo_signing_alg_values_supported")] + public IEnumerable? UserinfoSigningAlgValuesSupported { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum.cs new file mode 100644 index 000000000..6c9086bb1 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum.EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum Openid100 = + new(Values.Openid100); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum OidcV4 = + new(Values.OidcV4); + + public EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Openid100 = "openid-1.0.0"; + + public const string OidcV4 = "oidc-v4"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..061854622 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum.cs new file mode 100644 index 000000000..1879a8885 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum.EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum ClientSecretPost = + new(Values.ClientSecretPost); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum PrivateKeyJwt = + new(Values.PrivateKeyJwt); + + public EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ClientSecretPost = "client_secret_post"; + + public const string PrivateKeyJwt = "private_key_jwt"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs new file mode 100644 index 000000000..41034e48b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum.EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs new file mode 100644 index 000000000..1f424ff6f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum.EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum Issuer = + new(Values.Issuer); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum TokenEndpoint = + new(Values.TokenEndpoint); + + public EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Issuer = "issuer"; + + public const string TokenEndpoint = "token_endpoint"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum.cs new file mode 100644 index 000000000..724cdb2e3 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum.cs @@ -0,0 +1,131 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum.EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum BackChannel = + new(Values.BackChannel); + + public static readonly EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum FrontChannel = + new(Values.FrontChannel); + + public EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BackChannel = "back_channel"; + + public const string FrontChannel = "front_channel"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0StrategyEnum.cs new file mode 100644 index 000000000..2705255a0 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject0StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject0StrategyEnum.EventStreamCloudEventConnectionDeletedObject0StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject0StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject0StrategyEnum Oidc = new( + Values.Oidc + ); + + public EventStreamCloudEventConnectionDeletedObject0StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject0StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionDeletedObject0StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject0StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject0StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject0StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject0StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject0StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject0StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject0StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject0StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject0StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oidc = "oidc"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1.cs new file mode 100644 index 000000000..231a5362e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject1 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionDeletedObject1Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionDeletedObject1ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionDeletedObject1Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionDeletedObject1Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionDeletedObject1StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Authentication.cs new file mode 100644 index 000000000..95e652a6f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject1Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1ConnectedAccounts.cs new file mode 100644 index 000000000..4a3a4ad3e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject1ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Metadata.cs new file mode 100644 index 000000000..a6f7dc077 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject1Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Options.cs new file mode 100644 index 000000000..d8c66938d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1Options.cs @@ -0,0 +1,180 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'okta' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject1Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [Optional] + [JsonPropertyName("authorization_endpoint")] + public string? AuthorizationEndpoint { get; set; } + + /// + /// OAuth 2.0 client identifier issued by the identity provider during application registration. This value identifies your Auth0 connection to the identity provider. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + [Optional] + [JsonPropertyName("connection_settings")] + public EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettings? ConnectionSettings { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + [Optional] + [JsonPropertyName("dpop_signing_alg")] + public EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum? DpopSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionDeletedObject1OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// https url of the icon to be shown + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Indicates whether the identity provider supports session expiry via the id_token. If true, the system will use the session_expiry claim in the id_token to determine session expiry. + /// + [Optional] + [JsonPropertyName("id_token_session_expiry_supported")] + public bool? IdTokenSessionExpirySupported { get; set; } + + /// + /// List of algorithms allowed to verify the ID tokens. Applicable when strategy=oidc or okta. + /// + [Optional] + [JsonPropertyName("id_token_signed_response_algs")] + public IEnumerable? IdTokenSignedResponseAlgs { get; set; } + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [Optional] + [JsonPropertyName("issuer")] + public string? Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("oidc_metadata")] + public EventStreamCloudEventConnectionDeletedObject1OptionsOidcMetadata? OidcMetadata { get; set; } + + [Optional] + [JsonPropertyName("schema_version")] + public EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum? SchemaVersion { get; set; } + + /// + /// Space-separated list of OAuth 2.0 scopes requested during authorization. Must include 'openid' (required by OIDC spec). Common values: 'openid profile email'. Additional scopes depend on the identity provider. + /// + [Optional] + [JsonPropertyName("scope")] + public string? Scope { get; set; } + + /// + /// When true and type is 'back_channel', includes a cryptographic nonce in authorization requests to prevent replay attacks. The identity provider must include this nonce in the ID token for validation. + /// + [Optional] + [JsonPropertyName("send_back_channel_nonce")] + public bool? SendBackChannelNonce { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// Tenant domain + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_method")] + public EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum? TokenEndpointAuthMethod { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg")] + public EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum? TokenEndpointAuthSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_jwtca_aud_format")] + public EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum? TokenEndpointJwtcaAudFormat { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + [Optional] + [JsonPropertyName("attribute_map")] + public EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMap? AttributeMap { get; set; } + + /// + /// Domain of the Okta organization (e.g., dev-123456.okta.com). Should be just the domain of the okta server with no scheme or trailing backslash. Discovery runs only when connection.options.oidc_metadata is empty and a domain is provided + /// + [Optional] + [JsonPropertyName("domain")] + public string? Domain { get; set; } + + [Optional] + [JsonPropertyName("type")] + public EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum? Type { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMap.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMap.cs new file mode 100644 index 000000000..3c092ccc5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMap.cs @@ -0,0 +1,43 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Mapping of claims received from the identity provider (IdP) +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMap : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("attributes")] + public Dictionary? Attributes { get; set; } + + /// + /// Scopes to send to the IdP's Userinfo endpoint + /// + [Optional] + [JsonPropertyName("userinfo_scope")] + public string? UserinfoScope { get; set; } + + [Optional] + [JsonPropertyName("mapping_mode")] + public EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum? MappingMode { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum.cs new file mode 100644 index 000000000..b66d5a1e3 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum.EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum BasicProfile = + new(Values.BasicProfile); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum UseMap = + new(Values.UseMap); + + public EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BasicProfile = "basic_profile"; + + public const string UseMap = "use_map"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettings.cs new file mode 100644 index 000000000..9c05ed720 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettings.cs @@ -0,0 +1,33 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OAuth 2.0 PKCE (Proof Key for Code Exchange) settings. PKCE enhances security for public clients by preventing authorization code interception attacks. 'auto' (recommended) uses the strongest method supported by the IdP. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("pkce")] + public EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum? Pkce { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum.cs new file mode 100644 index 000000000..30c399d2a --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum.cs @@ -0,0 +1,149 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum.EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum Auto = + new(Values.Auto); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum S256 = + new(Values.S256); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum Plain = + new(Values.Plain); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum Disabled = + new(Values.Disabled); + + public EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Auto = "auto"; + + public const string S256 = "S256"; + + public const string Plain = "plain"; + + public const string Disabled = "disabled"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum.cs new file mode 100644 index 000000000..702dde629 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum.cs @@ -0,0 +1,145 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum.EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum Es512 = + new(Values.Es512); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum Ed25519 = + new(Values.Ed25519); + + public EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Es512 = "ES512"; + + public const string Ed25519 = "Ed25519"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..e3da50eee --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject1OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs new file mode 100644 index 000000000..5aee03236 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum.EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsOidcMetadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsOidcMetadata.cs new file mode 100644 index 000000000..f3917ce5d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsOidcMetadata.cs @@ -0,0 +1,283 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OpenID Connect Provider Metadata as per https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject1OptionsOidcMetadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of the Authentication Context Class References that this OP supports + /// + [Optional] + [JsonPropertyName("acr_values_supported")] + public IEnumerable? AcrValuesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [JsonPropertyName("authorization_endpoint")] + public required string AuthorizationEndpoint { get; set; } + + /// + /// JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described in Section 5.6 of OpenID Connect Core 1.0 [OpenID.Core]. If omitted, the implementation supports only normal Claims. + /// + [Optional] + [JsonPropertyName("claim_types_supported")] + public IEnumerable? ClaimTypesSupported { get; set; } + + /// + /// Languages and scripts supported for values in Claims being returned, represented as a JSON array of BCP47 [RFC5646] language tag values. Not all languages and scripts are necessarily supported for all Claim values. + /// + [Optional] + [JsonPropertyName("claims_locales_supported")] + public IEnumerable? ClaimsLocalesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the claims parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("claims_parameter_supported")] + public bool? ClaimsParameterSupported { get; set; } + + /// + /// JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list. + /// + [Optional] + [JsonPropertyName("claims_supported")] + public IEnumerable? ClaimsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("display_values_supported")] + public IEnumerable? DisplayValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported for DPoP proof JWT signing. + /// + [Optional] + [JsonPropertyName("dpop_signing_alg_values_supported")] + public IEnumerable? DpopSigningAlgValuesSupported { get; set; } + + /// + /// URL of the identity provider's logout/end session endpoint. When configured as a static URL, users are redirected here after logging out from Auth0. Must use HTTPS scheme. + /// + [Optional] + [JsonPropertyName("end_session_endpoint")] + public string? EndSessionEndpoint { get; set; } + + /// + /// A list of the OAuth 2.0 Grant Type values that this OP supports. Dynamic OpenID Providers MUST support the authorization_code and implicit Grant Type values and MAY support other Grant Types. If omitted, the default value is ["authorization_code", "implicit"]. + /// + [Optional] + [JsonPropertyName("grant_types_supported")] + public IEnumerable? GrantTypesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT + /// + [Optional] + [JsonPropertyName("id_token_encryption_alg_values_supported")] + public IEnumerable? IdTokenEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("id_token_encryption_enc_values_supported")] + public IEnumerable? IdTokenEncryptionEncValuesSupported { get; set; } + + /// + /// A list of the JWS signing algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT. The algorithm RS256 MUST be included. The value none MAY be supported, but MUST NOT be used unless the Response Type used returns no ID Token from the Authorization Endpoint (such as when using the Authorization Code Flow). https://datatracker.ietf.org/doc/html/rfc7518 + /// + [JsonPropertyName("id_token_signing_alg_values_supported")] + public IEnumerable IdTokenSigningAlgValuesSupported { get; set; } = new List(); + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [JsonPropertyName("issuer")] + public required string Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [JsonPropertyName("jwks_uri")] + public required string JwksUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about the OPs requirements on how the Relying Party can use the data provided by the OP. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_policy_uri")] + public string? OpPolicyUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about OpenID Providers terms of service. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_tos_uri")] + public string? OpTosUri { get; set; } + + /// + /// URL of the OPs Dynamic Client Registration Endpoint. RECOMMENDED but not REQUIRED. https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Registration + /// + [Optional] + [JsonPropertyName("registration_endpoint")] + public string? RegistrationEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_alg_values_supported")] + public IEnumerable? RequestObjectEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_enc_values_supported")] + public IEnumerable? RequestObjectEncryptionEncValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for Request Objects, which are described in Section 6.1 of OpenID Connect Core 1.0 [OpenID.Core]. These algorithms are used both when the Request Object is passed by value (using the request parameter) and when it is passed by reference (using the request_uri parameter). Servers SHOULD support none and RS256. + /// + [Optional] + [JsonPropertyName("request_object_signing_alg_values_supported")] + public IEnumerable? RequestObjectSigningAlgValuesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_parameter_supported")] + public bool? RequestParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request_uri parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_uri_parameter_supported")] + public bool? RequestUriParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP requires use of the request_uri parameter. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("require_request_uri_registration")] + public bool? RequireRequestUriRegistration { get; set; } + + /// + /// A list of the OAuth 2.0 response_mode values that this OP supports. If omitted, the default for Dynamic OpenID Providers is ["query", "fragment"] + /// + [Optional] + [JsonPropertyName("response_modes_supported")] + public IEnumerable? ResponseModesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 response_type values that this OP supports. Dynamic OpenID Providers MUST support the code, id_token, and the token id_token Response Type values + /// + [Optional] + [JsonPropertyName("response_types_supported")] + public IEnumerable? ResponseTypesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 [RFC6749] scope values that this server supports. The server MUST support the openid scope value. Servers MAY choose not to advertise some supported scope values even when this parameter is used, although those defined in [OpenID.Core] SHOULD be listed, if supported. RECOMMENDED but not REQUIRED + /// + [Optional] + [JsonPropertyName("scopes_supported")] + public IEnumerable? ScopesSupported { get; set; } + + /// + /// URL of a page containing human-readable information that developers might want or need to know when using the OpenID Provider. In particular, if the OpenID Provider does not support Dynamic Client Registration, then information on how to register Clients needs to be provided in this documentation. + /// + [Optional] + [JsonPropertyName("service_documentation")] + public string? ServiceDocumentation { get; set; } + + /// + /// A list of the Subject Identifier types that this OP supports. Valid types include pairwise and public + /// + [Optional] + [JsonPropertyName("subject_types_supported")] + public IEnumerable? SubjectTypesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + /// + /// JSON array containing a list of Client Authentication methods supported by this Token Endpoint. The options are client_secret_post, client_secret_basic, client_secret_jwt, and private_key_jwt, as described in Section 9 of OpenID Connect Core 1.0 [OpenID.Core]. Other authentication methods MAY be defined by extensions. If omitted, the default is client_secret_basic -- the HTTP Basic Authentication Scheme specified in Section 2.3.1 of OAuth 2.0 [RFC6749]. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_methods_supported")] + public IEnumerable? TokenEndpointAuthMethodsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg_values_supported")] + public IEnumerable? TokenEndpointAuthSigningAlgValuesSupported { get; set; } + + /// + /// Languages and scripts supported for the user interface, represented as a JSON array of BCP47 [RFC5646] language tag values. + /// + [Optional] + [JsonPropertyName("ui_locales_supported")] + public IEnumerable? UiLocalesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE [JWE] encryption algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_alg_values_supported")] + public IEnumerable? UserinfoEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_enc_values_supported")] + public IEnumerable? UserinfoEncryptionEncValuesSupported { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWS [JWS] signing algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. The value none MAY be included. + /// + [Optional] + [JsonPropertyName("userinfo_signing_alg_values_supported")] + public IEnumerable? UserinfoSigningAlgValuesSupported { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum.cs new file mode 100644 index 000000000..5d93ce34d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum.EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum Openid100 = + new(Values.Openid100); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum OidcV4 = + new(Values.OidcV4); + + public EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Openid100 = "openid-1.0.0"; + + public const string OidcV4 = "oidc-v4"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..52239ad55 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum.cs new file mode 100644 index 000000000..2e6a648c5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum.EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum ClientSecretPost = + new(Values.ClientSecretPost); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum PrivateKeyJwt = + new(Values.PrivateKeyJwt); + + public EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ClientSecretPost = "client_secret_post"; + + public const string PrivateKeyJwt = "private_key_jwt"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs new file mode 100644 index 000000000..385cc9778 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum.EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs new file mode 100644 index 000000000..094b8bf85 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum.EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum Issuer = + new(Values.Issuer); + + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum TokenEndpoint = + new(Values.TokenEndpoint); + + public EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Issuer = "issuer"; + + public const string TokenEndpoint = "token_endpoint"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum.cs new file mode 100644 index 000000000..b0201233e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum.cs @@ -0,0 +1,126 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum.EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum BackChannel = + new(Values.BackChannel); + + public EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BackChannel = "back_channel"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1StrategyEnum.cs new file mode 100644 index 000000000..b06a7d5fd --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject1StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject1StrategyEnum.EventStreamCloudEventConnectionDeletedObject1StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject1StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject1StrategyEnum Okta = new( + Values.Okta + ); + + public EventStreamCloudEventConnectionDeletedObject1StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject1StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionDeletedObject1StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject1StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject1StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject1StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject1StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject1StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject1StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject1StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject1StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject1StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Okta = "okta"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2.cs new file mode 100644 index 000000000..156e71f8a --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject2 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionDeletedObject2Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionDeletedObject2ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionDeletedObject2Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionDeletedObject2Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionDeletedObject2StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Authentication.cs new file mode 100644 index 000000000..c5ea650fe --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject2Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2ConnectedAccounts.cs new file mode 100644 index 000000000..7c84b612c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject2ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Metadata.cs new file mode 100644 index 000000000..0937947e5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject2Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Options.cs new file mode 100644 index 000000000..4ffa861b2 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2Options.cs @@ -0,0 +1,225 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'samlp' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject2Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("assertion_decryption_settings")] + public EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettings? AssertionDecryptionSettings { get; set; } + + /// + /// X.509 signing certificate from the identity provider in .der format. Used to validate signatures in SAML Responses and Assertions. This is an alternative to signingCert and is kept for backward compatibility. Prefer using signingCert instead. + /// + [Optional] + [JsonPropertyName("cert")] + public string? Cert { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + [Optional] + [JsonPropertyName("digestAlgorithm")] + public EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum? DigestAlgorithm { get; set; } + + /// + /// Domain aliases for the connection + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// The entity identifier (Issuer) for the SAML Service Provider. When not provided, defaults to 'urn:auth0:{tenant}:{connection}'. This value is included in SAML AuthnRequest messages sent to the identity provider. + /// + [Optional] + [JsonPropertyName("entityId")] + public string? EntityId { get; set; } + + /// + /// ISO 8601 formatted datetime indicating when the identity provider's signing certificate expires. + /// + [Optional] + [JsonPropertyName("expires")] + public DateTime? Expires { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + [Optional] + [JsonPropertyName("idpinitiated")] + public EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiated? Idpinitiated { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("protocolBinding")] + public EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum? ProtocolBinding { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("signatureAlgorithm")] + public EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum? SignatureAlgorithm { get; set; } + + /// + /// Identity provider's SAML SingleSignOnService endpoint URL where Auth0 sends SAML authentication requests. This is the primary login URL for the SAML connection. Required unless using metadataUrl or metadataXml. + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Base64-encoded X.509 certificate from the identity provider used to validate signatures in SAML responses and assertions. The certificate is decoded and used for cryptographic signature verification. + /// + [Optional] + [JsonPropertyName("signingCert")] + public string? SigningCert { get; set; } + + /// + /// When true, Auth0 signs SAML authentication requests using the connection's signing key. The signature includes the request's digest and is validated by the identity provider. Defaults to false (unsigned requests). + /// + [Optional] + [JsonPropertyName("signSAMLRequest")] + public bool? SignSamlRequest { get; set; } + + [Optional] + [JsonPropertyName("subject")] + public EventStreamCloudEventConnectionDeletedObject2OptionsSubject? Subject { get; set; } + + /// + /// For SAML connections, the tenant domain used to construct the login endpoint URL. Can be a string for single-tenant or an array of strings for multi-tenant validation. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// SHA-1 thumbprints (fingerprints) of the identity provider's signing certificates. Automatically computed from signingCert during connection creation. Each thumbprint must be a 40-character hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// When true, enables detailed SAML debugging by issuing 'w' (warning) events in tenant logs containing SAML request/response details. WARNING: Potentially exposes sensitive user information (PII, credentials) and should only be enabled temporarily for debugging purposes. + /// + [Optional] + [JsonPropertyName("debug")] + public bool? Debug { get; set; } + + /// + /// When true, enables DEFLATE compression for SAML requests sent via HTTP-Redirect binding. + /// + [Optional] + [JsonPropertyName("deflate")] + public bool? Deflate { get; set; } + + /// + /// The URL where Auth0 will send SAML authentication requests (the Identity Provider's SSO URL). Must be a valid HTTPS URL. + /// + [Optional] + [JsonPropertyName("destinationUrl")] + public string? DestinationUrl { get; set; } + + /// + /// When true, disables sending SAML logout requests (SingleLogoutService) to the identity provider during user sign-out. The user will be logged out of Auth0 but will remain logged into the identity provider. Defaults to false (federated logout enabled). + /// + [Optional] + [JsonPropertyName("disableSignout")] + public bool? DisableSignout { get; set; } + + [Optional] + [JsonPropertyName("fieldsMap")] + public Dictionary? FieldsMap { get; set; } + + /// + /// Expected 'iss' (Issuer) claim value for JWT tokens in Global Token Revocation requests from the identity provider. When configured, Auth0 validates the JWT issuer matches this value before processing token revocation. Must be used together with global_token_revocation_jwt_sub. + /// + [Optional] + [JsonPropertyName("global_token_revocation_jwt_iss")] + public string? GlobalTokenRevocationJwtIss { get; set; } + + /// + /// Expected 'sub' (Subject) claim value for JWT tokens in Global Token Revocation requests from the identity provider. When configured, Auth0 validates the JWT subject matches this value before processing token revocation. Must be used together with global_token_revocation_jwt_iss. + /// + [Optional] + [JsonPropertyName("global_token_revocation_jwt_sub")] + public string? GlobalTokenRevocationJwtSub { get; set; } + + /// + /// HTTPS URL to the identity provider's SAML metadata document. When provided, Auth0 automatically fetches and parses the metadata to extract signInEndpoint, signOutEndpoint, signingCert, signSAMLRequest, and protocolBinding. Use metadataUrl OR metadataXml, not both. + /// + [Optional] + [JsonPropertyName("metadataUrl")] + public string? MetadataUrl { get; set; } + + /// + /// The URL where Auth0 will send SAML authentication requests (the Identity Provider's SSO URL). Must be a valid HTTPS URL. + /// + [Optional] + [JsonPropertyName("recipientUrl")] + public string? RecipientUrl { get; set; } + + /// + /// Custom XML template for SAML authentication requests. Supports variable substitution using @@variableName@@ syntax. When not provided, uses default SAML AuthnRequest template. See https://auth0.com/docs/authenticate/protocols/saml/saml-sso-integrations/configure-auth0-saml-service-provider#customize-the-request-template + /// + [Optional] + [JsonPropertyName("requestTemplate")] + public string? RequestTemplate { get; set; } + + /// + /// Identity provider's SAML SingleLogoutService endpoint URL where Auth0 sends logout requests for federated sign-out. When not provided, defaults to signInEndpoint. Only used if disableSignout is false. + /// + [Optional] + [JsonPropertyName("signOutEndpoint")] + public string? SignOutEndpoint { get; set; } + + /// + /// Custom SAML assertion attribute to use as the unique user identifier. When provided, this attribute is prepended to the default user_id mapping list with highest priority. Accepts a string (single SAML attribute name). + /// + [Optional] + [JsonPropertyName("user_id_attribute")] + public string? UserIdAttribute { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettings.cs new file mode 100644 index 000000000..a266b0955 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettings.cs @@ -0,0 +1,39 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Settings for SAML assertion decryption. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of insecure algorithms to allow for SAML assertion decryption. + /// + [Optional] + [JsonPropertyName("algorithm_exceptions")] + public IEnumerable? AlgorithmExceptions { get; set; } + + [JsonPropertyName("algorithm_profile")] + public required EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum AlgorithmProfile { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs new file mode 100644 index 000000000..0208d5beb --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs @@ -0,0 +1,134 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum V20261 = + new(Values.V20261); + + public EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string V20261 = "v2026-1"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum.cs new file mode 100644 index 000000000..dc6de6af2 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum.EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum Sha1 = + new(Values.Sha1); + + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum Sha256 = + new(Values.Sha256); + + public EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Sha1 = "sha1"; + + public const string Sha256 = "sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiated.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiated.cs new file mode 100644 index 000000000..4cb10de93 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiated.cs @@ -0,0 +1,53 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for IdP-Initiated SAML Single Sign-On. When enabled, allows users to initiate login directly from their SAML identity provider without first visiting Auth0. The IdP must include the connection parameter in the post-back URL (Assertion Consumer Service URL). +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiated : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// The query string sent to the default application + /// + [Optional] + [JsonPropertyName("client_authorizequery")] + public string? ClientAuthorizequery { get; set; } + + /// + /// The client ID to use for IdP-initiated login requests. + /// + [Optional] + [JsonPropertyName("client_id")] + public string? ClientId { get; set; } + + [Optional] + [JsonPropertyName("client_protocol")] + public EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum? ClientProtocol { get; set; } + + /// + /// When true, enables IdP-initiated login support for this SAML connection. Allows users to log in directly from the identity provider without first visiting Auth0. + /// + [Optional] + [JsonPropertyName("enabled")] + public bool? Enabled { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum.cs new file mode 100644 index 000000000..4d5e63e7b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum.EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum Oidc = + new(Values.Oidc); + + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum Samlp = + new(Values.Samlp); + + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum Wsfed = + new(Values.Wsfed); + + public EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oidc = "oidc"; + + public const string Samlp = "samlp"; + + public const string Wsfed = "wsfed"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum.cs new file mode 100644 index 000000000..369649925 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum.EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpPost = + new(Values.UrnOasisNamesTcSaml20BindingsHttpPost); + + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpRedirect = + new(Values.UrnOasisNamesTcSaml20BindingsHttpRedirect); + + public EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string UrnOasisNamesTcSaml20BindingsHttpPost = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"; + + public const string UrnOasisNamesTcSaml20BindingsHttpRedirect = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..f11dd8744 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum.cs new file mode 100644 index 000000000..8318f90aa --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum.EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum RsaSha1 = + new(Values.RsaSha1); + + public static readonly EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum RsaSha256 = + new(Values.RsaSha256); + + public EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string RsaSha1 = "rsa-sha1"; + + public const string RsaSha256 = "rsa-sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSubject.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSubject.cs new file mode 100644 index 000000000..324da60a1 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2OptionsSubject.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Certificate Subject Distinguished Name (DN) extracted from the identity provider's signing certificate. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject2OptionsSubject : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2StrategyEnum.cs new file mode 100644 index 000000000..10d17f838 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject2StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject2StrategyEnum.EventStreamCloudEventConnectionDeletedObject2StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject2StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject2StrategyEnum Samlp = new( + Values.Samlp + ); + + public EventStreamCloudEventConnectionDeletedObject2StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject2StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionDeletedObject2StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject2StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject2StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject2StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject2StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject2StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject2StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject2StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject2StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject2StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Samlp = "samlp"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3.cs new file mode 100644 index 000000000..5f9ca7603 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject3 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionDeletedObject3Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionDeletedObject3ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionDeletedObject3Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionDeletedObject3Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionDeletedObject3StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Authentication.cs new file mode 100644 index 000000000..5091b750f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject3Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3ConnectedAccounts.cs new file mode 100644 index 000000000..73020c753 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject3ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Metadata.cs new file mode 100644 index 000000000..253ebf24f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject3Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Options.cs new file mode 100644 index 000000000..252cb845b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3Options.cs @@ -0,0 +1,150 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'pingfederate' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject3Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("assertion_decryption_settings")] + public EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettings? AssertionDecryptionSettings { get; set; } + + /// + /// X.509 signing certificate from the identity provider in .der format. Used to validate signatures in SAML Responses and Assertions. This is an alternative to signingCert and is kept for backward compatibility. Prefer using signingCert instead. + /// + [Optional] + [JsonPropertyName("cert")] + public string? Cert { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + [Optional] + [JsonPropertyName("digestAlgorithm")] + public EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum? DigestAlgorithm { get; set; } + + /// + /// Domain aliases for the connection + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// The entity identifier (Issuer) for the SAML Service Provider. When not provided, defaults to 'urn:auth0:{tenant}:{connection}'. This value is included in SAML AuthnRequest messages sent to the identity provider. + /// + [Optional] + [JsonPropertyName("entityId")] + public string? EntityId { get; set; } + + /// + /// ISO 8601 formatted datetime indicating when the identity provider's signing certificate expires. + /// + [Optional] + [JsonPropertyName("expires")] + public DateTime? Expires { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + [Optional] + [JsonPropertyName("idpinitiated")] + public EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiated? Idpinitiated { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("protocolBinding")] + public EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum? ProtocolBinding { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("signatureAlgorithm")] + public EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum? SignatureAlgorithm { get; set; } + + /// + /// Identity provider's SAML SingleSignOnService endpoint URL where Auth0 sends SAML authentication requests. This is the primary login URL for the SAML connection. Required unless using metadataUrl or metadataXml. + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Base64-encoded X.509 certificate from the identity provider used to validate signatures in SAML responses and assertions. The certificate is decoded and used for cryptographic signature verification. + /// + [Optional] + [JsonPropertyName("signingCert")] + public string? SigningCert { get; set; } + + /// + /// When true, Auth0 signs SAML authentication requests using the connection's signing key. The signature includes the request's digest and is validated by the identity provider. Defaults to false (unsigned requests). + /// + [Optional] + [JsonPropertyName("signSAMLRequest")] + public bool? SignSamlRequest { get; set; } + + [Optional] + [JsonPropertyName("subject")] + public EventStreamCloudEventConnectionDeletedObject3OptionsSubject? Subject { get; set; } + + /// + /// For SAML connections, the tenant domain used to construct the login endpoint URL. Can be a string for single-tenant or an array of strings for multi-tenant validation. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// SHA-1 thumbprints (fingerprints) of the identity provider's signing certificates. Automatically computed from signingCert during connection creation. Each thumbprint must be a 40-character hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// URL provided by PingFederate which returns information used for creating the connection + /// + [JsonPropertyName("pingFederateBaseUrl")] + public required string PingFederateBaseUrl { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettings.cs new file mode 100644 index 000000000..c403266cd --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettings.cs @@ -0,0 +1,39 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Settings for SAML assertion decryption. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of insecure algorithms to allow for SAML assertion decryption. + /// + [Optional] + [JsonPropertyName("algorithm_exceptions")] + public IEnumerable? AlgorithmExceptions { get; set; } + + [JsonPropertyName("algorithm_profile")] + public required EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum AlgorithmProfile { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs new file mode 100644 index 000000000..de6572739 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs @@ -0,0 +1,134 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum V20261 = + new(Values.V20261); + + public EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string V20261 = "v2026-1"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum.cs new file mode 100644 index 000000000..459cdb445 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum.EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum Sha1 = + new(Values.Sha1); + + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum Sha256 = + new(Values.Sha256); + + public EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Sha1 = "sha1"; + + public const string Sha256 = "sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiated.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiated.cs new file mode 100644 index 000000000..fb3211b05 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiated.cs @@ -0,0 +1,53 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for IdP-Initiated SAML Single Sign-On. When enabled, allows users to initiate login directly from their SAML identity provider without first visiting Auth0. The IdP must include the connection parameter in the post-back URL (Assertion Consumer Service URL). +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiated : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// The query string sent to the default application + /// + [Optional] + [JsonPropertyName("client_authorizequery")] + public string? ClientAuthorizequery { get; set; } + + /// + /// The client ID to use for IdP-initiated login requests. + /// + [Optional] + [JsonPropertyName("client_id")] + public string? ClientId { get; set; } + + [Optional] + [JsonPropertyName("client_protocol")] + public EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum? ClientProtocol { get; set; } + + /// + /// When true, enables IdP-initiated login support for this SAML connection. Allows users to log in directly from the identity provider without first visiting Auth0. + /// + [Optional] + [JsonPropertyName("enabled")] + public bool? Enabled { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum.cs new file mode 100644 index 000000000..2cf12caf5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum.EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum Oidc = + new(Values.Oidc); + + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum Samlp = + new(Values.Samlp); + + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum Wsfed = + new(Values.Wsfed); + + public EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oidc = "oidc"; + + public const string Samlp = "samlp"; + + public const string Wsfed = "wsfed"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum.cs new file mode 100644 index 000000000..787a05304 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum.EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpPost = + new(Values.UrnOasisNamesTcSaml20BindingsHttpPost); + + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpRedirect = + new(Values.UrnOasisNamesTcSaml20BindingsHttpRedirect); + + public EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string UrnOasisNamesTcSaml20BindingsHttpPost = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"; + + public const string UrnOasisNamesTcSaml20BindingsHttpRedirect = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..b828c2c2f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum.cs new file mode 100644 index 000000000..77097322d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum.EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum RsaSha1 = + new(Values.RsaSha1); + + public static readonly EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum RsaSha256 = + new(Values.RsaSha256); + + public EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string RsaSha1 = "rsa-sha1"; + + public const string RsaSha256 = "rsa-sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSubject.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSubject.cs new file mode 100644 index 000000000..c3883b2a4 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3OptionsSubject.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Certificate Subject Distinguished Name (DN) extracted from the identity provider's signing certificate. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject3OptionsSubject : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3StrategyEnum.cs new file mode 100644 index 000000000..296b34def --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject3StrategyEnum.cs @@ -0,0 +1,124 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject3StrategyEnum.EventStreamCloudEventConnectionDeletedObject3StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject3StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject3StrategyEnum Pingfederate = + new(Values.Pingfederate); + + public EventStreamCloudEventConnectionDeletedObject3StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject3StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionDeletedObject3StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject3StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject3StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject3StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject3StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject3StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject3StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject3StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject3StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject3StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Pingfederate = "pingfederate"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4.cs new file mode 100644 index 000000000..f19620420 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject4 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionDeletedObject4Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionDeletedObject4ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionDeletedObject4Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionDeletedObject4Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionDeletedObject4StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Authentication.cs new file mode 100644 index 000000000..590ea6345 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject4Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4ConnectedAccounts.cs new file mode 100644 index 000000000..fa0d58e83 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject4ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Metadata.cs new file mode 100644 index 000000000..82d0c4f10 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject4Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Options.cs new file mode 100644 index 000000000..1d9d9b56b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4Options.cs @@ -0,0 +1,124 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'adfs' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject4Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// ADFS federation metadata host or XML URL used to discover WS-Fed endpoints and certificates. Errors if adfs_server and fedMetadataXml are both absent. + /// + [Optional] + [JsonPropertyName("adfs_server")] + public string? AdfsServer { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// The entity identifier (Issuer) for the ADFS Service Provider. When not provided, defaults to 'urn:auth0:{tenant}:{connection}'. + /// + [Optional] + [JsonPropertyName("entityId")] + public string? EntityId { get; set; } + + /// + /// Inline XML alternative to 'adfs_server'. Cannot be set together with 'adfs_server'. + /// + [Optional] + [JsonPropertyName("fedMetadataXml")] + public string? FedMetadataXml { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + /// + /// Array of certificate thumbprints (SHA-128/SHA-256/SHA-512 hex hashes) for validating SAML signatures. Used with WS-Federation protocol. Maximum 20 thumbprints. Each thumbprint must be a hexadecimal string. + /// + [Optional] + [JsonPropertyName("prev_thumbprints")] + public IEnumerable? PrevThumbprints { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("should_trust_email_verified_connection")] + public EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum? ShouldTrustEmailVerifiedConnection { get; set; } + + /// + /// Passive Requestor (WS-Fed) sign-in endpoint discovered from metadata or provided explicitly. + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Tenant domain + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// Array of certificate thumbprints (SHA-128/SHA-256/SHA-512 hex hashes) for validating SAML signatures. Used with WS-Federation protocol. Maximum 20 thumbprints. Each thumbprint must be a hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Custom ADFS claim to use as the unique user identifier. When provided, this attribute is prepended to the default user_id mapping list with highest priority. Accepts a string (single ADFS claim name). + /// + [Optional] + [JsonPropertyName("user_id_attribute")] + public string? UserIdAttribute { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..a9bcc3bad --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject4OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs new file mode 100644 index 000000000..0b1323bc6 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum NeverSetEmailsAsVerified = + new(Values.NeverSetEmailsAsVerified); + + public static readonly EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum AlwaysSetEmailsAsVerified = + new(Values.AlwaysSetEmailsAsVerified); + + public EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string NeverSetEmailsAsVerified = "never_set_emails_as_verified"; + + public const string AlwaysSetEmailsAsVerified = "always_set_emails_as_verified"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4StrategyEnum.cs new file mode 100644 index 000000000..f50ebca82 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject4StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject4StrategyEnum.EventStreamCloudEventConnectionDeletedObject4StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject4StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject4StrategyEnum Adfs = new( + Values.Adfs + ); + + public EventStreamCloudEventConnectionDeletedObject4StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject4StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionDeletedObject4StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject4StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject4StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject4StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject4StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject4StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject4StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject4StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject4StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject4StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject4StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject4StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Adfs = "adfs"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5.cs new file mode 100644 index 000000000..aae1b23a2 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5.cs @@ -0,0 +1,84 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject5 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionDeletedObject5Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionDeletedObject5ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionDeletedObject5Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionDeletedObject5Options? Options { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionDeletedObject5StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Authentication.cs new file mode 100644 index 000000000..1cc077b16 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject5Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5ConnectedAccounts.cs new file mode 100644 index 000000000..512ddcadf --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject5ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Metadata.cs new file mode 100644 index 000000000..7944dd8e7 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject5Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Options.cs new file mode 100644 index 000000000..ffa1af991 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5Options.cs @@ -0,0 +1,148 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'ad' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject5Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// IP address of the AD connector agent used to validate that authentication requests originate from the corporate network for Kerberos authentication (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("agentIP")] + public string? AgentIp { get; set; } + + /// + /// When enabled, allows direct username/password authentication through the AD connector agent instead of WS-Federation protocol (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("agentMode")] + public bool? AgentMode { get; set; } + + /// + /// Version identifier of the installed AD connector agent software (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("agentVersion")] + public string? AgentVersion { get; set; } + + /// + /// Enables Auth0's brute force protection to prevent credential stuffing attacks. When enabled, blocks suspicious login attempts from specific IP addresses after repeated failures. + /// + [Optional] + [JsonPropertyName("brute_force_protection")] + public bool? BruteForceProtection { get; set; } + + /// + /// Enables client SSL certificate authentication for the AD connector, requiring HTTPS on the sign-in endpoint + /// + [Optional] + [JsonPropertyName("certAuth")] + public bool? CertAuth { get; set; } + + /// + /// Array of X.509 certificates in PEM format used for validating SAML signatures from the AD identity provider (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("certs")] + public IEnumerable? Certs { get; set; } + + /// + /// When enabled, disables caching of AD connector authentication results to ensure real-time validation against the directory + /// + [Optional] + [JsonPropertyName("disable_cache")] + public bool? DisableCache { get; set; } + + /// + /// When enabled, hides the 'Forgot Password' link on login pages to prevent users from initiating self-service password resets + /// + [Optional] + [JsonPropertyName("disable_self_service_change_password")] + public bool? DisableSelfServiceChangePassword { get; set; } + + /// + /// List of domain names that can be used with identifier-first authentication flow to route users to this AD connection; each domain must be a valid DNS name up to 256 characters + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// https url of the icon to be shown + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Array of IP address ranges in CIDR notation used to determine if authentication requests originate from the corporate network for Kerberos or certificate authentication. + /// + [Optional] + [JsonPropertyName("ips")] + public IEnumerable? Ips { get; set; } + + /// + /// Enables Windows Integrated Authentication (Kerberos) for seamless SSO when users authenticate from within the corporate network IP ranges + /// + [Optional] + [JsonPropertyName("kerberos")] + public bool? Kerberos { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// The sign-in endpoint type for the AD-LDAP connector agent (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Primary AD domain hint used for HRD and discovery. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// Array of certificate SHA-1 thumbprints for validating signatures. Managed by Auth0 when using the AD Connector agent. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..9b05385c7 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject5OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5StrategyEnum.cs new file mode 100644 index 000000000..7aca23657 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject5StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject5StrategyEnum.EventStreamCloudEventConnectionDeletedObject5StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject5StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject5StrategyEnum Ad = new( + Values.Ad + ); + + public EventStreamCloudEventConnectionDeletedObject5StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject5StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionDeletedObject5StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject5StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject5StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject5StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject5StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject5StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject5StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject5StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject5StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject5StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject5StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject5StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Ad = "ad"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6.cs new file mode 100644 index 000000000..d2b0aa885 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject6 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionDeletedObject6Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionDeletedObject6ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionDeletedObject6Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionDeletedObject6Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionDeletedObject6StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Authentication.cs new file mode 100644 index 000000000..3e369bf99 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject6Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6ConnectedAccounts.cs new file mode 100644 index 000000000..80c7522b2 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject6ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Metadata.cs new file mode 100644 index 000000000..c5d2f722a --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject6Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Options.cs new file mode 100644 index 000000000..614cf2cbc --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6Options.cs @@ -0,0 +1,179 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'google-apps' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject6Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Expiration timestamp for the `admin_access_token` in ISO 8601 format. Auth0 uses this value to determine when to refresh the token. + /// + [Optional] + [JsonPropertyName("admin_access_token_expiresin")] + public DateTime? AdminAccessTokenExpiresin { get; set; } + + /// + /// When true, allows customization of OAuth scopes requested during user login. Custom scopes are appended to the mandatory email and profile scopes. When false or omitted, only the default email and profile scopes are used. This property is automatically enabled when Token Vault or Connected Accounts features are activated. + /// + [Optional] + [JsonPropertyName("allow_setting_login_scopes")] + public bool? AllowSettingLoginScopes { get; set; } + + /// + /// Enables integration with the Google Workspace Admin SDK Directory API for groups. When true, Auth0 can synchronize groups & group memberships and supports inbound directory provisioning for groups. Defaults to false. + /// + [Optional] + [JsonPropertyName("api_enable_groups")] + public bool? ApiEnableGroups { get; set; } + + /// + /// Enables integration with the Google Workspace Admin SDK Directory API. When true, Auth0 can retrieve extended user attributes (admin status, suspension status, group memberships) and supports inbound directory provisioning (SCIM). Defaults to true. + /// + [Optional] + [JsonPropertyName("api_enable_users")] + public bool? ApiEnableUsers { get; set; } + + /// + /// Your Google OAuth 2.0 client ID. You can find this in your [Google Cloud Console](https://console.cloud.google.com/apis/credentials) under the OAuth 2.0 Client IDs section. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + /// + /// Primary Google Workspace domain name that users must belong to. + /// + [Optional] + [JsonPropertyName("domain")] + public string? Domain { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// Whether the OAuth flow requests the `email` scope. + /// + [Optional] + [JsonPropertyName("email")] + public bool? Email { get; set; } + + /// + /// Fetches the `agreedToTerms` flag from the Google Directory profile. + /// + [Optional] + [JsonPropertyName("ext_agreed_terms")] + public bool? ExtAgreedTerms { get; set; } + + /// + /// Enables enrichment with Google group memberships (required for `ext_groups_extended`). + /// + [Optional] + [JsonPropertyName("ext_groups")] + public bool? ExtGroups { get; set; } + + /// + /// Controls whether enriched group entries include `id`, `email`, `name` (true) or only the group name (false); can only be set when `ext_groups` is true. + /// + [Optional] + [JsonPropertyName("ext_groups_extended")] + public bool? ExtGroupsExtended { get; set; } + + /// + /// Fetches the Google Directory admin flag for the signing-in user. + /// + [Optional] + [JsonPropertyName("ext_is_admin")] + public bool? ExtIsAdmin { get; set; } + + /// + /// Fetches the Google Directory suspended flag for the signing-in user. + /// + [Optional] + [JsonPropertyName("ext_is_suspended")] + public bool? ExtIsSuspended { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionDeletedObject6OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// When enabled, users who sign in with their Google account through a social login will be automatically routed to this Google Workspace connection if their email domain matches the configured tenant_domain or domain_aliases. This ensures enterprise users authenticate through their organization's Google Workspace identity provider rather than through a generic Google social login, enabling access to directory-based attributes and enforcing organizational security policies. Defaults to true for new connections. + /// + [Optional] + [JsonPropertyName("handle_login_from_social")] + public bool? HandleLoginFromSocial { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Determines how Auth0 generates the user_id for Google Workspace users. When false (default), the user's email address is used. When true, Google's stable numeric user ID is used instead, which persists even if the user's email changes. This setting can only be configured when creating the connection and cannot be changed afterward. + /// + [Optional] + [JsonPropertyName("map_user_id_to_id")] + public bool? MapUserIdToId { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + /// + /// Whether the OAuth flow requests the `profile` scope. + /// + [Optional] + [JsonPropertyName("profile")] + public bool? Profile { get; set; } + + /// + /// Additional OAuth scopes requested beyond the default `email profile` scopes; ignored unless `allow_setting_login_scopes` is true. + /// + [Optional] + [JsonPropertyName("scope")] + public IEnumerable? Scope { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// The Google Workspace primary domain used to identify the organization during authentication. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..be841c9e8 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject6OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..5f625b9bc --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject6OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6StrategyEnum.cs new file mode 100644 index 000000000..70d68a421 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject6StrategyEnum.cs @@ -0,0 +1,124 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject6StrategyEnum.EventStreamCloudEventConnectionDeletedObject6StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject6StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject6StrategyEnum GoogleApps = + new(Values.GoogleApps); + + public EventStreamCloudEventConnectionDeletedObject6StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject6StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionDeletedObject6StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject6StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject6StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject6StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject6StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject6StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject6StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject6StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject6StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject6StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject6StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject6StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string GoogleApps = "google-apps"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7.cs new file mode 100644 index 000000000..e9a84f41c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject7 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionDeletedObject7Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionDeletedObject7ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionDeletedObject7Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionDeletedObject7Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionDeletedObject7StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Authentication.cs new file mode 100644 index 000000000..8a051bb30 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject7Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7ConnectedAccounts.cs new file mode 100644 index 000000000..f8b0a0a7b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject7ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Metadata.cs new file mode 100644 index 000000000..395c2765d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject7Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Options.cs new file mode 100644 index 000000000..3fbaa3aea --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7Options.cs @@ -0,0 +1,199 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'waad' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject7Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enable users API + /// + [Optional] + [JsonPropertyName("api_enable_users")] + public bool? ApiEnableUsers { get; set; } + + /// + /// The Azure AD application domain (e.g., 'contoso.onmicrosoft.com'). Used primarily with WS-Federation protocol and Azure AD v1 endpoints. + /// + [Optional] + [JsonPropertyName("app_domain")] + public string? AppDomain { get; set; } + + /// + /// The Application ID URI (App ID URI) for the Azure AD application. Required when using Azure AD v1 with the Resource Owner Password flow. Used to identify the resource being requested in OAuth token requests. + /// + [Optional] + [JsonPropertyName("app_id")] + public string? AppId { get; set; } + + /// + /// Includes basic user profile information from Azure AD (name, email, given_name, family_name). Always enabled and required - represents the minimum profile data retrieved during authentication. + /// + [Optional] + [JsonPropertyName("basic_profile")] + public bool? BasicProfile { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + /// + /// OAuth 2.0 client identifier issued by the identity provider during application registration. This value identifies your Auth0 connection to the identity provider. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + /// + /// The primary Azure AD tenant domain (e.g., 'contoso.onmicrosoft.com' or 'contoso.com'). + /// + [Optional] + [JsonPropertyName("domain")] + public string? Domain { get; set; } + + /// + /// Alternative domain names associated with this Azure AD tenant. Allows users from multiple verified domains to authenticate through this connection. Can be an array of domain strings. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// When enabled (true), retrieves and stores Azure AD security group memberships for the user. Requires Microsoft Graph API permissions (Directory.Read.All). Allows configuring max_groups_to_retrieve. + /// + [Optional] + [JsonPropertyName("ext_groups")] + public bool? ExtGroups { get; set; } + + /// + /// When true, stores all groups the user is member of, including transitive group memberships (groups within groups). When false (default), only direct group memberships are included. + /// + [Optional] + [JsonPropertyName("ext_nested_groups")] + public bool? ExtNestedGroups { get; set; } + + /// + /// When enabled (true), retrieves extended profile attributes from Azure AD via Microsoft Graph API (job title, department, office location, etc.). Requires Graph API permissions. Only available with Azure AD v1 or when explicitly enabled for v2. + /// + [Optional] + [JsonPropertyName("ext_profile")] + public bool? ExtProfile { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionDeletedObject7OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// Indicates whether admin consent has been granted for the required Azure AD permissions. Read-only status field managed by Auth0 during the OAuth authorization flow. + /// + [Optional] + [JsonPropertyName("granted")] + public bool? Granted { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + [Optional] + [JsonPropertyName("identity_api")] + public EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum? IdentityApi { get; set; } + + /// + /// Maximum number of Azure AD groups to retrieve per user during authentication. Helps prevent performance issues for users in many groups. Only applies when ext_groups is enabled. Leave empty to use platform default. + /// + [Optional] + [JsonPropertyName("max_groups_to_retrieve")] + public string? MaxGroupsToRetrieve { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + /// + /// OAuth 2.0 scopes to request from Azure AD during authentication. Each scope represents a permission (e.g., 'User.Read', 'Group.Read.All'). Only applies with Microsoft Identity Platform v2.0. See Microsoft Graph permissions reference for available scopes. + /// + [Optional] + [JsonPropertyName("scope")] + public IEnumerable? Scope { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("should_trust_email_verified_connection")] + public EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum? ShouldTrustEmailVerifiedConnection { get; set; } + + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// The Azure AD tenant ID as a UUID. The unique identifier for your Azure AD organization. Must be a valid 36-character UUID. + /// + [Optional] + [JsonPropertyName("tenantId")] + public string? TenantId { get; set; } + + /// + /// Array of certificate thumbprints (SHA-128/SHA-256/SHA-512 hex hashes) for validating SAML signatures. Used with WS-Federation protocol. Maximum 20 thumbprints. Each thumbprint must be a hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Indicates WS-Federation protocol usage. When true, uses WS-Federation; when false, uses OpenID Connect. + /// + [Optional] + [JsonPropertyName("use_wsfed")] + public bool? UseWsfed { get; set; } + + /// + /// When enabled (true), uses the Azure AD common endpoint for multi-tenant authentication. Allows users from any Azure AD organization to sign in. Requires userid_attribute set to 'sub' (not 'oid'). Cannot be used with SCIM provisioning. Defaults to false. + /// + [Optional] + [JsonPropertyName("useCommonEndpoint")] + public bool? UseCommonEndpoint { get; set; } + + [Optional] + [JsonPropertyName("userid_attribute")] + public EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum? UseridAttribute { get; set; } + + [Optional] + [JsonPropertyName("waad_protocol")] + public EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum? WaadProtocol { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..f8f21be5d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionDeletedObject7OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum.cs new file mode 100644 index 000000000..beffb96bc --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum.EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum MicrosoftIdentityPlatformV20 = + new(Values.MicrosoftIdentityPlatformV20); + + public static readonly EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum AzureActiveDirectoryV10 = + new(Values.AzureActiveDirectoryV10); + + public EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7OptionsIdentityApiEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string MicrosoftIdentityPlatformV20 = "microsoft-identity-platform-v2.0"; + + public const string AzureActiveDirectoryV10 = "azure-active-directory-v1.0"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..159454888 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs new file mode 100644 index 000000000..30e4b4737 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum NeverSetEmailsAsVerified = + new(Values.NeverSetEmailsAsVerified); + + public static readonly EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum AlwaysSetEmailsAsVerified = + new(Values.AlwaysSetEmailsAsVerified); + + public EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string NeverSetEmailsAsVerified = "never_set_emails_as_verified"; + + public const string AlwaysSetEmailsAsVerified = "always_set_emails_as_verified"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum.cs new file mode 100644 index 000000000..5a6b3da46 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum.EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum Oid = + new(Values.Oid); + + public static readonly EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum Sub = + new(Values.Sub); + + public EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7OptionsUseridAttributeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oid = "oid"; + + public const string Sub = "sub"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum.cs new file mode 100644 index 000000000..4bb7874e7 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum.EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum WsFederation = + new(Values.WsFederation); + + public static readonly EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum OpenidConnect = + new(Values.OpenidConnect); + + public EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7OptionsWaadProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string WsFederation = "ws-federation"; + + public const string OpenidConnect = "openid-connect"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7StrategyEnum.cs new file mode 100644 index 000000000..b995357a1 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedObject7StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedObject7StrategyEnum.EventStreamCloudEventConnectionDeletedObject7StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedObject7StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedObject7StrategyEnum Waad = new( + Values.Waad + ); + + public EventStreamCloudEventConnectionDeletedObject7StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedObject7StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionDeletedObject7StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedObject7StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedObject7StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionDeletedObject7StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedObject7StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionDeletedObject7StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedObject7StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedObject7StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedObject7StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedObject7StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Waad = "waad"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedTypeEnum.cs new file mode 100644 index 000000000..4a17d4f44 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionDeletedTypeEnum.cs @@ -0,0 +1,122 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionDeletedTypeEnum.EventStreamCloudEventConnectionDeletedTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionDeletedTypeEnum : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionDeletedTypeEnum ConnectionDeleted = new( + Values.ConnectionDeleted + ); + + public EventStreamCloudEventConnectionDeletedTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionDeletedTypeEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionDeletedTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionDeletedTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionDeletedTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string(EventStreamCloudEventConnectionDeletedTypeEnum value) => + value.Value; + + public static explicit operator EventStreamCloudEventConnectionDeletedTypeEnum(string value) => + new(value); + + internal class EventStreamCloudEventConnectionDeletedTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionDeletedTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionDeletedTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionDeletedTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionDeletedTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ConnectionDeleted = "connection.deleted"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdated.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdated.cs new file mode 100644 index 000000000..41862360f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdated.cs @@ -0,0 +1,37 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// SSE message for connection.updated. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdated : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Opaque cursor representing position in the stream. Pass as the `from` query parameter to resume. + /// + [JsonPropertyName("offset")] + public required string Offset { get; set; } + + [JsonPropertyName("event")] + public required EventStreamCloudEventConnectionUpdatedCloudEvent Event { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedCloudEvent.cs new file mode 100644 index 000000000..6f661d08e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedCloudEvent.cs @@ -0,0 +1,71 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Represents an event that occurs when a connection is updated. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedCloudEvent : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("specversion")] + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } + + [JsonPropertyName("type")] + public required EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum Type { get; set; } + + /// + /// The source of the event. This will take the form 'urn:auth0:<tenant>.<domain>'. + /// + [JsonPropertyName("source")] + public required string Source { get; set; } + + /// + /// A unique identifier for the event. + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// An ISO-8601 timestamp indicating when the event physically occurred. + /// + [JsonPropertyName("time")] + public required DateTime Time { get; set; } + + [JsonPropertyName("data")] + public required EventStreamCloudEventConnectionUpdatedData Data { get; set; } + + /// + /// The auth0 tenant ID to which the event is associated. + /// + [JsonPropertyName("a0tenant")] + public required string A0Tenant { get; set; } + + /// + /// The auth0 event stream ID of the stream the event was delivered on. + /// + [JsonPropertyName("a0stream")] + public required string A0Stream { get; set; } + + [Optional] + [JsonPropertyName("a0purpose")] + public EventStreamCloudEventA0PurposeEnum? A0Purpose { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum.cs new file mode 100644 index 000000000..956d80e99 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum.cs @@ -0,0 +1,123 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum.EventStreamCloudEventConnectionUpdatedCloudEventTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum ConnectionUpdated = + new(Values.ConnectionUpdated); + + public EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedCloudEventTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedCloudEventTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ConnectionUpdated = "connection.updated"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedData.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedData.cs new file mode 100644 index 000000000..2dc53e14e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedData.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// The event payload. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedData : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("object")] + public required EventStreamCloudEventConnectionUpdatedObject Object { get; set; } + + [Optional] + [JsonPropertyName("context")] + public EventStreamCloudEventContext? Context { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject.cs new file mode 100644 index 000000000..4c511b696 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject.cs @@ -0,0 +1,675 @@ +// ReSharper disable NullableWarningSuppressionIsUsed +// ReSharper disable InconsistentNaming + +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// The event content. +/// +[JsonConverter(typeof(EventStreamCloudEventConnectionUpdatedObject.JsonConverter))] +[Serializable] +public class EventStreamCloudEventConnectionUpdatedObject +{ + private EventStreamCloudEventConnectionUpdatedObject(string type, object? value) + { + Type = type; + Value = value; + } + + /// + /// Type discriminator + /// + [JsonIgnore] + public string Type { get; internal set; } + + /// + /// Union value + /// + [JsonIgnore] + public object? Value { get; internal set; } + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject0 value. + /// + public static EventStreamCloudEventConnectionUpdatedObject FromEventStreamCloudEventConnectionUpdatedObject0( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject0 value + ) => new("eventStreamCloudEventConnectionUpdatedObject0", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject1 value. + /// + public static EventStreamCloudEventConnectionUpdatedObject FromEventStreamCloudEventConnectionUpdatedObject1( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject1 value + ) => new("eventStreamCloudEventConnectionUpdatedObject1", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject2 value. + /// + public static EventStreamCloudEventConnectionUpdatedObject FromEventStreamCloudEventConnectionUpdatedObject2( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject2 value + ) => new("eventStreamCloudEventConnectionUpdatedObject2", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject3 value. + /// + public static EventStreamCloudEventConnectionUpdatedObject FromEventStreamCloudEventConnectionUpdatedObject3( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject3 value + ) => new("eventStreamCloudEventConnectionUpdatedObject3", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject4 value. + /// + public static EventStreamCloudEventConnectionUpdatedObject FromEventStreamCloudEventConnectionUpdatedObject4( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject4 value + ) => new("eventStreamCloudEventConnectionUpdatedObject4", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject5 value. + /// + public static EventStreamCloudEventConnectionUpdatedObject FromEventStreamCloudEventConnectionUpdatedObject5( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject5 value + ) => new("eventStreamCloudEventConnectionUpdatedObject5", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject6 value. + /// + public static EventStreamCloudEventConnectionUpdatedObject FromEventStreamCloudEventConnectionUpdatedObject6( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject6 value + ) => new("eventStreamCloudEventConnectionUpdatedObject6", value); + + /// + /// Factory method to create a union from a Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject7 value. + /// + public static EventStreamCloudEventConnectionUpdatedObject FromEventStreamCloudEventConnectionUpdatedObject7( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject7 value + ) => new("eventStreamCloudEventConnectionUpdatedObject7", value); + + /// + /// Returns true if is "eventStreamCloudEventConnectionUpdatedObject0" + /// + public bool IsEventStreamCloudEventConnectionUpdatedObject0() => + Type == "eventStreamCloudEventConnectionUpdatedObject0"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionUpdatedObject1" + /// + public bool IsEventStreamCloudEventConnectionUpdatedObject1() => + Type == "eventStreamCloudEventConnectionUpdatedObject1"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionUpdatedObject2" + /// + public bool IsEventStreamCloudEventConnectionUpdatedObject2() => + Type == "eventStreamCloudEventConnectionUpdatedObject2"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionUpdatedObject3" + /// + public bool IsEventStreamCloudEventConnectionUpdatedObject3() => + Type == "eventStreamCloudEventConnectionUpdatedObject3"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionUpdatedObject4" + /// + public bool IsEventStreamCloudEventConnectionUpdatedObject4() => + Type == "eventStreamCloudEventConnectionUpdatedObject4"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionUpdatedObject5" + /// + public bool IsEventStreamCloudEventConnectionUpdatedObject5() => + Type == "eventStreamCloudEventConnectionUpdatedObject5"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionUpdatedObject6" + /// + public bool IsEventStreamCloudEventConnectionUpdatedObject6() => + Type == "eventStreamCloudEventConnectionUpdatedObject6"; + + /// + /// Returns true if is "eventStreamCloudEventConnectionUpdatedObject7" + /// + public bool IsEventStreamCloudEventConnectionUpdatedObject7() => + Type == "eventStreamCloudEventConnectionUpdatedObject7"; + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionUpdatedObject0', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionUpdatedObject0'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject0 AsEventStreamCloudEventConnectionUpdatedObject0() => + IsEventStreamCloudEventConnectionUpdatedObject0() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject0)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionUpdatedObject0'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionUpdatedObject1', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionUpdatedObject1'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject1 AsEventStreamCloudEventConnectionUpdatedObject1() => + IsEventStreamCloudEventConnectionUpdatedObject1() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject1)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionUpdatedObject1'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionUpdatedObject2', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionUpdatedObject2'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject2 AsEventStreamCloudEventConnectionUpdatedObject2() => + IsEventStreamCloudEventConnectionUpdatedObject2() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject2)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionUpdatedObject2'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionUpdatedObject3', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionUpdatedObject3'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject3 AsEventStreamCloudEventConnectionUpdatedObject3() => + IsEventStreamCloudEventConnectionUpdatedObject3() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject3)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionUpdatedObject3'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionUpdatedObject4', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionUpdatedObject4'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject4 AsEventStreamCloudEventConnectionUpdatedObject4() => + IsEventStreamCloudEventConnectionUpdatedObject4() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject4)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionUpdatedObject4'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionUpdatedObject5', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionUpdatedObject5'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject5 AsEventStreamCloudEventConnectionUpdatedObject5() => + IsEventStreamCloudEventConnectionUpdatedObject5() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject5)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionUpdatedObject5'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionUpdatedObject6', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionUpdatedObject6'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject6 AsEventStreamCloudEventConnectionUpdatedObject6() => + IsEventStreamCloudEventConnectionUpdatedObject6() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject6)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionUpdatedObject6'" + ); + + /// + /// Returns the value as a if is 'eventStreamCloudEventConnectionUpdatedObject7', otherwise throws an exception. + /// + /// Thrown when is not 'eventStreamCloudEventConnectionUpdatedObject7'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject7 AsEventStreamCloudEventConnectionUpdatedObject7() => + IsEventStreamCloudEventConnectionUpdatedObject7() + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject7)Value! + : throw new ManagementException( + "Union type is not 'eventStreamCloudEventConnectionUpdatedObject7'" + ); + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionUpdatedObject0( + out Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject0? value + ) + { + if (Type == "eventStreamCloudEventConnectionUpdatedObject0") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject0)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionUpdatedObject1( + out Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject1? value + ) + { + if (Type == "eventStreamCloudEventConnectionUpdatedObject1") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject1)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionUpdatedObject2( + out Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject2? value + ) + { + if (Type == "eventStreamCloudEventConnectionUpdatedObject2") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject2)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionUpdatedObject3( + out Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject3? value + ) + { + if (Type == "eventStreamCloudEventConnectionUpdatedObject3") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject3)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionUpdatedObject4( + out Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject4? value + ) + { + if (Type == "eventStreamCloudEventConnectionUpdatedObject4") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject4)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionUpdatedObject5( + out Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject5? value + ) + { + if (Type == "eventStreamCloudEventConnectionUpdatedObject5") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject5)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionUpdatedObject6( + out Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject6? value + ) + { + if (Type == "eventStreamCloudEventConnectionUpdatedObject6") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject6)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryGetEventStreamCloudEventConnectionUpdatedObject7( + out Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject7? value + ) + { + if (Type == "eventStreamCloudEventConnectionUpdatedObject7") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject7)Value!; + return true; + } + value = null; + return false; + } + + public T Match( + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject0, + T + > onEventStreamCloudEventConnectionUpdatedObject0, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject1, + T + > onEventStreamCloudEventConnectionUpdatedObject1, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject2, + T + > onEventStreamCloudEventConnectionUpdatedObject2, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject3, + T + > onEventStreamCloudEventConnectionUpdatedObject3, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject4, + T + > onEventStreamCloudEventConnectionUpdatedObject4, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject5, + T + > onEventStreamCloudEventConnectionUpdatedObject5, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject6, + T + > onEventStreamCloudEventConnectionUpdatedObject6, + Func< + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject7, + T + > onEventStreamCloudEventConnectionUpdatedObject7 + ) + { + return Type switch + { + "eventStreamCloudEventConnectionUpdatedObject0" => + onEventStreamCloudEventConnectionUpdatedObject0( + AsEventStreamCloudEventConnectionUpdatedObject0() + ), + "eventStreamCloudEventConnectionUpdatedObject1" => + onEventStreamCloudEventConnectionUpdatedObject1( + AsEventStreamCloudEventConnectionUpdatedObject1() + ), + "eventStreamCloudEventConnectionUpdatedObject2" => + onEventStreamCloudEventConnectionUpdatedObject2( + AsEventStreamCloudEventConnectionUpdatedObject2() + ), + "eventStreamCloudEventConnectionUpdatedObject3" => + onEventStreamCloudEventConnectionUpdatedObject3( + AsEventStreamCloudEventConnectionUpdatedObject3() + ), + "eventStreamCloudEventConnectionUpdatedObject4" => + onEventStreamCloudEventConnectionUpdatedObject4( + AsEventStreamCloudEventConnectionUpdatedObject4() + ), + "eventStreamCloudEventConnectionUpdatedObject5" => + onEventStreamCloudEventConnectionUpdatedObject5( + AsEventStreamCloudEventConnectionUpdatedObject5() + ), + "eventStreamCloudEventConnectionUpdatedObject6" => + onEventStreamCloudEventConnectionUpdatedObject6( + AsEventStreamCloudEventConnectionUpdatedObject6() + ), + "eventStreamCloudEventConnectionUpdatedObject7" => + onEventStreamCloudEventConnectionUpdatedObject7( + AsEventStreamCloudEventConnectionUpdatedObject7() + ), + _ => throw new ManagementException($"Unknown union type: {Type}"), + }; + } + + public void Visit( + global::System.Action onEventStreamCloudEventConnectionUpdatedObject0, + global::System.Action onEventStreamCloudEventConnectionUpdatedObject1, + global::System.Action onEventStreamCloudEventConnectionUpdatedObject2, + global::System.Action onEventStreamCloudEventConnectionUpdatedObject3, + global::System.Action onEventStreamCloudEventConnectionUpdatedObject4, + global::System.Action onEventStreamCloudEventConnectionUpdatedObject5, + global::System.Action onEventStreamCloudEventConnectionUpdatedObject6, + global::System.Action onEventStreamCloudEventConnectionUpdatedObject7 + ) + { + switch (Type) + { + case "eventStreamCloudEventConnectionUpdatedObject0": + onEventStreamCloudEventConnectionUpdatedObject0( + AsEventStreamCloudEventConnectionUpdatedObject0() + ); + break; + case "eventStreamCloudEventConnectionUpdatedObject1": + onEventStreamCloudEventConnectionUpdatedObject1( + AsEventStreamCloudEventConnectionUpdatedObject1() + ); + break; + case "eventStreamCloudEventConnectionUpdatedObject2": + onEventStreamCloudEventConnectionUpdatedObject2( + AsEventStreamCloudEventConnectionUpdatedObject2() + ); + break; + case "eventStreamCloudEventConnectionUpdatedObject3": + onEventStreamCloudEventConnectionUpdatedObject3( + AsEventStreamCloudEventConnectionUpdatedObject3() + ); + break; + case "eventStreamCloudEventConnectionUpdatedObject4": + onEventStreamCloudEventConnectionUpdatedObject4( + AsEventStreamCloudEventConnectionUpdatedObject4() + ); + break; + case "eventStreamCloudEventConnectionUpdatedObject5": + onEventStreamCloudEventConnectionUpdatedObject5( + AsEventStreamCloudEventConnectionUpdatedObject5() + ); + break; + case "eventStreamCloudEventConnectionUpdatedObject6": + onEventStreamCloudEventConnectionUpdatedObject6( + AsEventStreamCloudEventConnectionUpdatedObject6() + ); + break; + case "eventStreamCloudEventConnectionUpdatedObject7": + onEventStreamCloudEventConnectionUpdatedObject7( + AsEventStreamCloudEventConnectionUpdatedObject7() + ); + break; + default: + throw new ManagementException($"Unknown union type: {Type}"); + } + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Type.GetHashCode(); + if (Value != null) + { + hashCode = (hashCode * 397) ^ Value.GetHashCode(); + } + return hashCode; + } + } + + public override bool Equals(object? obj) + { + if (obj is null) + return false; + if (ReferenceEquals(this, obj)) + return true; + if (obj is not EventStreamCloudEventConnectionUpdatedObject other) + return false; + + // Compare type discriminators + if (Type != other.Type) + return false; + + // Compare values using EqualityComparer for deep comparison + return System.Collections.Generic.EqualityComparer.Default.Equals( + Value, + other.Value + ); + } + + public override string ToString() => JsonUtils.Serialize(this); + + public static implicit operator EventStreamCloudEventConnectionUpdatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject0 value + ) => new("eventStreamCloudEventConnectionUpdatedObject0", value); + + public static implicit operator EventStreamCloudEventConnectionUpdatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject1 value + ) => new("eventStreamCloudEventConnectionUpdatedObject1", value); + + public static implicit operator EventStreamCloudEventConnectionUpdatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject2 value + ) => new("eventStreamCloudEventConnectionUpdatedObject2", value); + + public static implicit operator EventStreamCloudEventConnectionUpdatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject3 value + ) => new("eventStreamCloudEventConnectionUpdatedObject3", value); + + public static implicit operator EventStreamCloudEventConnectionUpdatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject4 value + ) => new("eventStreamCloudEventConnectionUpdatedObject4", value); + + public static implicit operator EventStreamCloudEventConnectionUpdatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject5 value + ) => new("eventStreamCloudEventConnectionUpdatedObject5", value); + + public static implicit operator EventStreamCloudEventConnectionUpdatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject6 value + ) => new("eventStreamCloudEventConnectionUpdatedObject6", value); + + public static implicit operator EventStreamCloudEventConnectionUpdatedObject( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject7 value + ) => new("eventStreamCloudEventConnectionUpdatedObject7", value); + + [Serializable] + internal sealed class JsonConverter + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject? Read( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + if (reader.TokenType == JsonTokenType.Null) + { + return null; + } + + if (reader.TokenType == JsonTokenType.StartObject) + { + var document = JsonDocument.ParseValue(ref reader); + + var types = new (string Key, System.Type Type)[] + { + ( + "eventStreamCloudEventConnectionUpdatedObject0", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject0) + ), + ( + "eventStreamCloudEventConnectionUpdatedObject1", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject1) + ), + ( + "eventStreamCloudEventConnectionUpdatedObject2", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject2) + ), + ( + "eventStreamCloudEventConnectionUpdatedObject3", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject3) + ), + ( + "eventStreamCloudEventConnectionUpdatedObject4", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject4) + ), + ( + "eventStreamCloudEventConnectionUpdatedObject5", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject5) + ), + ( + "eventStreamCloudEventConnectionUpdatedObject6", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject6) + ), + ( + "eventStreamCloudEventConnectionUpdatedObject7", + typeof(Auth0.ManagementApi.EventStreamCloudEventConnectionUpdatedObject7) + ), + }; + + foreach (var (key, type) in types) + { + try + { + var value = document.Deserialize(type, options); + if (value != null) + { + EventStreamCloudEventConnectionUpdatedObject result = new(key, value); + return result; + } + } + catch (JsonException) + { + // Try next type; + } + } + } + + throw new JsonException( + $"Cannot deserialize JSON token {reader.TokenType} into EventStreamCloudEventConnectionUpdatedObject" + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject value, + JsonSerializerOptions options + ) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + + value.Visit( + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options), + obj => JsonSerializer.Serialize(writer, obj, options) + ); + } + + public override EventStreamCloudEventConnectionUpdatedObject ReadAsPropertyName( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = reader.GetString()!; + EventStreamCloudEventConnectionUpdatedObject result = new("string", stringValue); + return result; + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value?.ToString() ?? "null"); + } + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0.cs new file mode 100644 index 000000000..5ae3e06da --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject0 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionUpdatedObject0Authentication? Authentication { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionUpdatedObject0Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionUpdatedObject0ConnectedAccounts? ConnectedAccounts { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionUpdatedObject0Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionUpdatedObject0StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Authentication.cs new file mode 100644 index 000000000..21d55d0e0 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject0Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0ConnectedAccounts.cs new file mode 100644 index 000000000..c680c01d2 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0ConnectedAccounts.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject0ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [Optional] + [JsonPropertyName("cross_app_access")] + public bool? CrossAppAccess { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Metadata.cs new file mode 100644 index 000000000..2b45144e9 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject0Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Options.cs new file mode 100644 index 000000000..6ced25f24 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0Options.cs @@ -0,0 +1,180 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'oidc' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject0Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [Optional] + [JsonPropertyName("authorization_endpoint")] + public string? AuthorizationEndpoint { get; set; } + + /// + /// OAuth 2.0 client identifier issued by the identity provider during application registration. This value identifies your Auth0 connection to the identity provider. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + [Optional] + [JsonPropertyName("connection_settings")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettings? ConnectionSettings { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + [Optional] + [JsonPropertyName("dpop_signing_alg")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum? DpopSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// https url of the icon to be shown + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Indicates whether the identity provider supports session expiry via the id_token. If true, the system will use the session_expiry claim in the id_token to determine session expiry. + /// + [Optional] + [JsonPropertyName("id_token_session_expiry_supported")] + public bool? IdTokenSessionExpirySupported { get; set; } + + /// + /// List of algorithms allowed to verify the ID tokens. Applicable when strategy=oidc or okta. + /// + [Optional] + [JsonPropertyName("id_token_signed_response_algs")] + public IEnumerable? IdTokenSignedResponseAlgs { get; set; } + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [Optional] + [JsonPropertyName("issuer")] + public string? Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("oidc_metadata")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsOidcMetadata? OidcMetadata { get; set; } + + [Optional] + [JsonPropertyName("schema_version")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum? SchemaVersion { get; set; } + + /// + /// Space-separated list of OAuth 2.0 scopes requested during authorization. Must include 'openid' (required by OIDC spec). Common values: 'openid profile email'. Additional scopes depend on the identity provider. + /// + [Optional] + [JsonPropertyName("scope")] + public string? Scope { get; set; } + + /// + /// When true and type is 'back_channel', includes a cryptographic nonce in authorization requests to prevent replay attacks. The identity provider must include this nonce in the ID token for validation. + /// + [Optional] + [JsonPropertyName("send_back_channel_nonce")] + public bool? SendBackChannelNonce { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// Tenant domain + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_method")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum? TokenEndpointAuthMethod { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum? TokenEndpointAuthSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_jwtca_aud_format")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum? TokenEndpointJwtcaAudFormat { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + [Optional] + [JsonPropertyName("attribute_map")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMap? AttributeMap { get; set; } + + /// + /// URL of the identity provider's OIDC Discovery endpoint (/.well-known/openid-configuration). When provided and oidc_metadata is empty, Auth0 automatically retrieves the provider's configuration including endpoints and supported features. + /// + [Optional] + [JsonPropertyName("discovery_url")] + public string? DiscoveryUrl { get; set; } + + [Optional] + [JsonPropertyName("type")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum? Type { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMap.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMap.cs new file mode 100644 index 000000000..eed60b766 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMap.cs @@ -0,0 +1,43 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for mapping claims from the identity provider to Auth0 user profile attributes. Allows customizing which IdP claims populate user fields and how they are transformed. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMap : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("attributes")] + public Dictionary? Attributes { get; set; } + + /// + /// Scopes to send to the IdP's Userinfo endpoint + /// + [Optional] + [JsonPropertyName("userinfo_scope")] + public string? UserinfoScope { get; set; } + + [Optional] + [JsonPropertyName("mapping_mode")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum? MappingMode { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum.cs new file mode 100644 index 000000000..548a993ed --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum.EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum BindAll = + new(Values.BindAll); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum UseMap = + new(Values.UseMap); + + public EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BindAll = "bind_all"; + + public const string UseMap = "use_map"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettings.cs new file mode 100644 index 000000000..049330c6b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettings.cs @@ -0,0 +1,33 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OAuth 2.0 PKCE (Proof Key for Code Exchange) settings. PKCE enhances security for public clients by preventing authorization code interception attacks. 'auto' (recommended) uses the strongest method supported by the IdP. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("pkce")] + public EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum? Pkce { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum.cs new file mode 100644 index 000000000..fb04e3ad9 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum.cs @@ -0,0 +1,149 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum.EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum Auto = + new(Values.Auto); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum S256 = + new(Values.S256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum Plain = + new(Values.Plain); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum Disabled = + new(Values.Disabled); + + public EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Auto = "auto"; + + public const string S256 = "S256"; + + public const string Plain = "plain"; + + public const string Disabled = "disabled"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum.cs new file mode 100644 index 000000000..32487a21c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum.cs @@ -0,0 +1,145 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum.EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum Es512 = + new(Values.Es512); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum Ed25519 = + new(Values.Ed25519); + + public EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Es512 = "ES512"; + + public const string Ed25519 = "Ed25519"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..90c965c3f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject0OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs new file mode 100644 index 000000000..3e3bde055 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum.EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsOidcMetadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsOidcMetadata.cs new file mode 100644 index 000000000..12990b67b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsOidcMetadata.cs @@ -0,0 +1,283 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OpenID Connect Provider Metadata as per https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject0OptionsOidcMetadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of the Authentication Context Class References that this OP supports + /// + [Optional] + [JsonPropertyName("acr_values_supported")] + public IEnumerable? AcrValuesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [JsonPropertyName("authorization_endpoint")] + public required string AuthorizationEndpoint { get; set; } + + /// + /// JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described in Section 5.6 of OpenID Connect Core 1.0 [OpenID.Core]. If omitted, the implementation supports only normal Claims. + /// + [Optional] + [JsonPropertyName("claim_types_supported")] + public IEnumerable? ClaimTypesSupported { get; set; } + + /// + /// Languages and scripts supported for values in Claims being returned, represented as a JSON array of BCP47 [RFC5646] language tag values. Not all languages and scripts are necessarily supported for all Claim values. + /// + [Optional] + [JsonPropertyName("claims_locales_supported")] + public IEnumerable? ClaimsLocalesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the claims parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("claims_parameter_supported")] + public bool? ClaimsParameterSupported { get; set; } + + /// + /// JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list. + /// + [Optional] + [JsonPropertyName("claims_supported")] + public IEnumerable? ClaimsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("display_values_supported")] + public IEnumerable? DisplayValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported for DPoP proof JWT signing. + /// + [Optional] + [JsonPropertyName("dpop_signing_alg_values_supported")] + public IEnumerable? DpopSigningAlgValuesSupported { get; set; } + + /// + /// URL of the identity provider's logout/end session endpoint. When configured as a static URL, users are redirected here after logging out from Auth0. Must use HTTPS scheme. + /// + [Optional] + [JsonPropertyName("end_session_endpoint")] + public string? EndSessionEndpoint { get; set; } + + /// + /// A list of the OAuth 2.0 Grant Type values that this OP supports. Dynamic OpenID Providers MUST support the authorization_code and implicit Grant Type values and MAY support other Grant Types. If omitted, the default value is ["authorization_code", "implicit"]. + /// + [Optional] + [JsonPropertyName("grant_types_supported")] + public IEnumerable? GrantTypesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT + /// + [Optional] + [JsonPropertyName("id_token_encryption_alg_values_supported")] + public IEnumerable? IdTokenEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("id_token_encryption_enc_values_supported")] + public IEnumerable? IdTokenEncryptionEncValuesSupported { get; set; } + + /// + /// A list of the JWS signing algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT. The algorithm RS256 MUST be included. The value none MAY be supported, but MUST NOT be used unless the Response Type used returns no ID Token from the Authorization Endpoint (such as when using the Authorization Code Flow). https://datatracker.ietf.org/doc/html/rfc7518 + /// + [JsonPropertyName("id_token_signing_alg_values_supported")] + public IEnumerable IdTokenSigningAlgValuesSupported { get; set; } = new List(); + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [JsonPropertyName("issuer")] + public required string Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [JsonPropertyName("jwks_uri")] + public required string JwksUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about the OPs requirements on how the Relying Party can use the data provided by the OP. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_policy_uri")] + public string? OpPolicyUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about OpenID Providers terms of service. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_tos_uri")] + public string? OpTosUri { get; set; } + + /// + /// URL of the OPs Dynamic Client Registration Endpoint. RECOMMENDED but not REQUIRED. https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Registration + /// + [Optional] + [JsonPropertyName("registration_endpoint")] + public string? RegistrationEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_alg_values_supported")] + public IEnumerable? RequestObjectEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_enc_values_supported")] + public IEnumerable? RequestObjectEncryptionEncValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for Request Objects, which are described in Section 6.1 of OpenID Connect Core 1.0 [OpenID.Core]. These algorithms are used both when the Request Object is passed by value (using the request parameter) and when it is passed by reference (using the request_uri parameter). Servers SHOULD support none and RS256. + /// + [Optional] + [JsonPropertyName("request_object_signing_alg_values_supported")] + public IEnumerable? RequestObjectSigningAlgValuesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_parameter_supported")] + public bool? RequestParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request_uri parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_uri_parameter_supported")] + public bool? RequestUriParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP requires use of the request_uri parameter. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("require_request_uri_registration")] + public bool? RequireRequestUriRegistration { get; set; } + + /// + /// A list of the OAuth 2.0 response_mode values that this OP supports. If omitted, the default for Dynamic OpenID Providers is ["query", "fragment"] + /// + [Optional] + [JsonPropertyName("response_modes_supported")] + public IEnumerable? ResponseModesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 response_type values that this OP supports. Dynamic OpenID Providers MUST support the code, id_token, and the token id_token Response Type values + /// + [Optional] + [JsonPropertyName("response_types_supported")] + public IEnumerable? ResponseTypesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 [RFC6749] scope values that this server supports. The server MUST support the openid scope value. Servers MAY choose not to advertise some supported scope values even when this parameter is used, although those defined in [OpenID.Core] SHOULD be listed, if supported. RECOMMENDED but not REQUIRED + /// + [Optional] + [JsonPropertyName("scopes_supported")] + public IEnumerable? ScopesSupported { get; set; } + + /// + /// URL of a page containing human-readable information that developers might want or need to know when using the OpenID Provider. In particular, if the OpenID Provider does not support Dynamic Client Registration, then information on how to register Clients needs to be provided in this documentation. + /// + [Optional] + [JsonPropertyName("service_documentation")] + public string? ServiceDocumentation { get; set; } + + /// + /// A list of the Subject Identifier types that this OP supports. Valid types include pairwise and public + /// + [Optional] + [JsonPropertyName("subject_types_supported")] + public IEnumerable? SubjectTypesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + /// + /// JSON array containing a list of Client Authentication methods supported by this Token Endpoint. The options are client_secret_post, client_secret_basic, client_secret_jwt, and private_key_jwt, as described in Section 9 of OpenID Connect Core 1.0 [OpenID.Core]. Other authentication methods MAY be defined by extensions. If omitted, the default is client_secret_basic -- the HTTP Basic Authentication Scheme specified in Section 2.3.1 of OAuth 2.0 [RFC6749]. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_methods_supported")] + public IEnumerable? TokenEndpointAuthMethodsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg_values_supported")] + public IEnumerable? TokenEndpointAuthSigningAlgValuesSupported { get; set; } + + /// + /// Languages and scripts supported for the user interface, represented as a JSON array of BCP47 [RFC5646] language tag values. + /// + [Optional] + [JsonPropertyName("ui_locales_supported")] + public IEnumerable? UiLocalesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE [JWE] encryption algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_alg_values_supported")] + public IEnumerable? UserinfoEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_enc_values_supported")] + public IEnumerable? UserinfoEncryptionEncValuesSupported { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWS [JWS] signing algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. The value none MAY be included. + /// + [Optional] + [JsonPropertyName("userinfo_signing_alg_values_supported")] + public IEnumerable? UserinfoSigningAlgValuesSupported { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum.cs new file mode 100644 index 000000000..0f90be0f7 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum.EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum Openid100 = + new(Values.Openid100); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum OidcV4 = + new(Values.OidcV4); + + public EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Openid100 = "openid-1.0.0"; + + public const string OidcV4 = "oidc-v4"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..1abcb14ea --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum.cs new file mode 100644 index 000000000..da63269ff --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum.EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum ClientSecretPost = + new(Values.ClientSecretPost); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum PrivateKeyJwt = + new(Values.PrivateKeyJwt); + + public EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ClientSecretPost = "client_secret_post"; + + public const string PrivateKeyJwt = "private_key_jwt"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs new file mode 100644 index 000000000..6be17756c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum.EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs new file mode 100644 index 000000000..68653bf6a --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum.EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum Issuer = + new(Values.Issuer); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum TokenEndpoint = + new(Values.TokenEndpoint); + + public EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Issuer = "issuer"; + + public const string TokenEndpoint = "token_endpoint"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum.cs new file mode 100644 index 000000000..882d5aa8b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum.cs @@ -0,0 +1,131 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum.EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum BackChannel = + new(Values.BackChannel); + + public static readonly EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum FrontChannel = + new(Values.FrontChannel); + + public EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BackChannel = "back_channel"; + + public const string FrontChannel = "front_channel"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0StrategyEnum.cs new file mode 100644 index 000000000..2a7fb6fe6 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject0StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject0StrategyEnum.EventStreamCloudEventConnectionUpdatedObject0StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject0StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject0StrategyEnum Oidc = new( + Values.Oidc + ); + + public EventStreamCloudEventConnectionUpdatedObject0StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject0StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionUpdatedObject0StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject0StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject0StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject0StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject0StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject0StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject0StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject0StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject0StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject0StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oidc = "oidc"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1.cs new file mode 100644 index 000000000..a01edaf6e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject1 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionUpdatedObject1Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionUpdatedObject1ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionUpdatedObject1Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionUpdatedObject1Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionUpdatedObject1StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Authentication.cs new file mode 100644 index 000000000..bc839cb07 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject1Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1ConnectedAccounts.cs new file mode 100644 index 000000000..ab13ef489 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject1ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Metadata.cs new file mode 100644 index 000000000..8f9af8675 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject1Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Options.cs new file mode 100644 index 000000000..d4aa22b50 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1Options.cs @@ -0,0 +1,180 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'okta' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject1Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [Optional] + [JsonPropertyName("authorization_endpoint")] + public string? AuthorizationEndpoint { get; set; } + + /// + /// OAuth 2.0 client identifier issued by the identity provider during application registration. This value identifies your Auth0 connection to the identity provider. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + [Optional] + [JsonPropertyName("connection_settings")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettings? ConnectionSettings { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + [Optional] + [JsonPropertyName("dpop_signing_alg")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum? DpopSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// https url of the icon to be shown + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Indicates whether the identity provider supports session expiry via the id_token. If true, the system will use the session_expiry claim in the id_token to determine session expiry. + /// + [Optional] + [JsonPropertyName("id_token_session_expiry_supported")] + public bool? IdTokenSessionExpirySupported { get; set; } + + /// + /// List of algorithms allowed to verify the ID tokens. Applicable when strategy=oidc or okta. + /// + [Optional] + [JsonPropertyName("id_token_signed_response_algs")] + public IEnumerable? IdTokenSignedResponseAlgs { get; set; } + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [Optional] + [JsonPropertyName("issuer")] + public string? Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [Optional] + [JsonPropertyName("jwks_uri")] + public string? JwksUri { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("oidc_metadata")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsOidcMetadata? OidcMetadata { get; set; } + + [Optional] + [JsonPropertyName("schema_version")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum? SchemaVersion { get; set; } + + /// + /// Space-separated list of OAuth 2.0 scopes requested during authorization. Must include 'openid' (required by OIDC spec). Common values: 'openid profile email'. Additional scopes depend on the identity provider. + /// + [Optional] + [JsonPropertyName("scope")] + public string? Scope { get; set; } + + /// + /// When true and type is 'back_channel', includes a cryptographic nonce in authorization requests to prevent replay attacks. The identity provider must include this nonce in the ID token for validation. + /// + [Optional] + [JsonPropertyName("send_back_channel_nonce")] + public bool? SendBackChannelNonce { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// Tenant domain + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_method")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum? TokenEndpointAuthMethod { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum? TokenEndpointAuthSigningAlg { get; set; } + + [Optional] + [JsonPropertyName("token_endpoint_jwtca_aud_format")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum? TokenEndpointJwtcaAudFormat { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + [Optional] + [JsonPropertyName("attribute_map")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMap? AttributeMap { get; set; } + + /// + /// Domain of the Okta organization (e.g., dev-123456.okta.com). Should be just the domain of the okta server with no scheme or trailing backslash. Discovery runs only when connection.options.oidc_metadata is empty and a domain is provided + /// + [Optional] + [JsonPropertyName("domain")] + public string? Domain { get; set; } + + [Optional] + [JsonPropertyName("type")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum? Type { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMap.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMap.cs new file mode 100644 index 000000000..31de1e4f0 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMap.cs @@ -0,0 +1,43 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Mapping of claims received from the identity provider (IdP) +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMap : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("attributes")] + public Dictionary? Attributes { get; set; } + + /// + /// Scopes to send to the IdP's Userinfo endpoint + /// + [Optional] + [JsonPropertyName("userinfo_scope")] + public string? UserinfoScope { get; set; } + + [Optional] + [JsonPropertyName("mapping_mode")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum? MappingMode { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum.cs new file mode 100644 index 000000000..244be8e12 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum.EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum BasicProfile = + new(Values.BasicProfile); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum UseMap = + new(Values.UseMap); + + public EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsAttributeMapMappingModeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BasicProfile = "basic_profile"; + + public const string UseMap = "use_map"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettings.cs new file mode 100644 index 000000000..9cd3fee4b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettings.cs @@ -0,0 +1,33 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OAuth 2.0 PKCE (Proof Key for Code Exchange) settings. PKCE enhances security for public clients by preventing authorization code interception attacks. 'auto' (recommended) uses the strongest method supported by the IdP. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("pkce")] + public EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum? Pkce { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum.cs new file mode 100644 index 000000000..9d0faf8f5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum.cs @@ -0,0 +1,149 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum.EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum Auto = + new(Values.Auto); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum S256 = + new(Values.S256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum Plain = + new(Values.Plain); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum Disabled = + new(Values.Disabled); + + public EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsConnectionSettingsPkceEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Auto = "auto"; + + public const string S256 = "S256"; + + public const string Plain = "plain"; + + public const string Disabled = "disabled"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum.cs new file mode 100644 index 000000000..b53300a16 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum.cs @@ -0,0 +1,145 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum.EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum Es512 = + new(Values.Es512); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum Ed25519 = + new(Values.Ed25519); + + public EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsDpopSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Es512 = "ES512"; + + public const string Ed25519 = "Ed25519"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..a50765e4b --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject1OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs new file mode 100644 index 000000000..623c7afd8 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum.EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsIdTokenSignedResponseAlgsItemEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsOidcMetadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsOidcMetadata.cs new file mode 100644 index 000000000..2f9726366 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsOidcMetadata.cs @@ -0,0 +1,283 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// OpenID Connect Provider Metadata as per https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject1OptionsOidcMetadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of the Authentication Context Class References that this OP supports + /// + [Optional] + [JsonPropertyName("acr_values_supported")] + public IEnumerable? AcrValuesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 authorization endpoint where users are redirected for authentication. Must be a valid HTTPS URL. This endpoint initiates the OAuth 2.0 authorization code flow. + /// + [JsonPropertyName("authorization_endpoint")] + public required string AuthorizationEndpoint { get; set; } + + /// + /// JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described in Section 5.6 of OpenID Connect Core 1.0 [OpenID.Core]. If omitted, the implementation supports only normal Claims. + /// + [Optional] + [JsonPropertyName("claim_types_supported")] + public IEnumerable? ClaimTypesSupported { get; set; } + + /// + /// Languages and scripts supported for values in Claims being returned, represented as a JSON array of BCP47 [RFC5646] language tag values. Not all languages and scripts are necessarily supported for all Claim values. + /// + [Optional] + [JsonPropertyName("claims_locales_supported")] + public IEnumerable? ClaimsLocalesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the claims parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("claims_parameter_supported")] + public bool? ClaimsParameterSupported { get; set; } + + /// + /// JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list. + /// + [Optional] + [JsonPropertyName("claims_supported")] + public IEnumerable? ClaimsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("display_values_supported")] + public IEnumerable? DisplayValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported for DPoP proof JWT signing. + /// + [Optional] + [JsonPropertyName("dpop_signing_alg_values_supported")] + public IEnumerable? DpopSigningAlgValuesSupported { get; set; } + + /// + /// URL of the identity provider's logout/end session endpoint. When configured as a static URL, users are redirected here after logging out from Auth0. Must use HTTPS scheme. + /// + [Optional] + [JsonPropertyName("end_session_endpoint")] + public string? EndSessionEndpoint { get; set; } + + /// + /// A list of the OAuth 2.0 Grant Type values that this OP supports. Dynamic OpenID Providers MUST support the authorization_code and implicit Grant Type values and MAY support other Grant Types. If omitted, the default value is ["authorization_code", "implicit"]. + /// + [Optional] + [JsonPropertyName("grant_types_supported")] + public IEnumerable? GrantTypesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT + /// + [Optional] + [JsonPropertyName("id_token_encryption_alg_values_supported")] + public IEnumerable? IdTokenEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("id_token_encryption_enc_values_supported")] + public IEnumerable? IdTokenEncryptionEncValuesSupported { get; set; } + + /// + /// A list of the JWS signing algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT. The algorithm RS256 MUST be included. The value none MAY be supported, but MUST NOT be used unless the Response Type used returns no ID Token from the Authorization Endpoint (such as when using the Authorization Code Flow). https://datatracker.ietf.org/doc/html/rfc7518 + /// + [JsonPropertyName("id_token_signing_alg_values_supported")] + public IEnumerable IdTokenSigningAlgValuesSupported { get; set; } = new List(); + + /// + /// The identity provider's unique issuer identifier URL (e.g., https://accounts.google.com). Must match the 'iss' claim in ID tokens from the identity provider. + /// + [JsonPropertyName("issuer")] + public required string Issuer { get; set; } + + /// + /// URL of the identity provider's JSON Web Key Set (JWKS) endpoint containing public keys for signature verification. Auth0 retrieves these keys to validate ID token signatures. + /// + [JsonPropertyName("jwks_uri")] + public required string JwksUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about the OPs requirements on how the Relying Party can use the data provided by the OP. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_policy_uri")] + public string? OpPolicyUri { get; set; } + + /// + /// URL that the OpenID Provider provides to the person registering the Client to read about OpenID Providers terms of service. The registration process SHOULD display this URL to the person registering the Client if it is given. + /// + [Optional] + [JsonPropertyName("op_tos_uri")] + public string? OpTosUri { get; set; } + + /// + /// URL of the OPs Dynamic Client Registration Endpoint. RECOMMENDED but not REQUIRED. https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Registration + /// + [Optional] + [JsonPropertyName("registration_endpoint")] + public string? RegistrationEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_alg_values_supported")] + public IEnumerable? RequestObjectEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference. + /// + [Optional] + [JsonPropertyName("request_object_encryption_enc_values_supported")] + public IEnumerable? RequestObjectEncryptionEncValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for Request Objects, which are described in Section 6.1 of OpenID Connect Core 1.0 [OpenID.Core]. These algorithms are used both when the Request Object is passed by value (using the request parameter) and when it is passed by reference (using the request_uri parameter). Servers SHOULD support none and RS256. + /// + [Optional] + [JsonPropertyName("request_object_signing_alg_values_supported")] + public IEnumerable? RequestObjectSigningAlgValuesSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_parameter_supported")] + public bool? RequestParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP supports use of the request_uri parameter, with true indicating support. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("request_uri_parameter_supported")] + public bool? RequestUriParameterSupported { get; set; } + + /// + /// Boolean value specifying whether the OP requires use of the request_uri parameter. If omitted, the default value is false. + /// + [Optional] + [JsonPropertyName("require_request_uri_registration")] + public bool? RequireRequestUriRegistration { get; set; } + + /// + /// A list of the OAuth 2.0 response_mode values that this OP supports. If omitted, the default for Dynamic OpenID Providers is ["query", "fragment"] + /// + [Optional] + [JsonPropertyName("response_modes_supported")] + public IEnumerable? ResponseModesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 response_type values that this OP supports. Dynamic OpenID Providers MUST support the code, id_token, and the token id_token Response Type values + /// + [Optional] + [JsonPropertyName("response_types_supported")] + public IEnumerable? ResponseTypesSupported { get; set; } + + /// + /// A list of the OAuth 2.0 [RFC6749] scope values that this server supports. The server MUST support the openid scope value. Servers MAY choose not to advertise some supported scope values even when this parameter is used, although those defined in [OpenID.Core] SHOULD be listed, if supported. RECOMMENDED but not REQUIRED + /// + [Optional] + [JsonPropertyName("scopes_supported")] + public IEnumerable? ScopesSupported { get; set; } + + /// + /// URL of a page containing human-readable information that developers might want or need to know when using the OpenID Provider. In particular, if the OpenID Provider does not support Dynamic Client Registration, then information on how to register Clients needs to be provided in this documentation. + /// + [Optional] + [JsonPropertyName("service_documentation")] + public string? ServiceDocumentation { get; set; } + + /// + /// A list of the Subject Identifier types that this OP supports. Valid types include pairwise and public + /// + [Optional] + [JsonPropertyName("subject_types_supported")] + public IEnumerable? SubjectTypesSupported { get; set; } + + /// + /// URL of the identity provider's OAuth 2.0 token endpoint where authorization codes are exchanged for access tokens. Must be a valid HTTPS URL. Required for authorization code flow but optional for implicit flow. + /// + [Optional] + [JsonPropertyName("token_endpoint")] + public string? TokenEndpoint { get; set; } + + /// + /// JSON array containing a list of Client Authentication methods supported by this Token Endpoint. The options are client_secret_post, client_secret_basic, client_secret_jwt, and private_key_jwt, as described in Section 9 of OpenID Connect Core 1.0 [OpenID.Core]. Other authentication methods MAY be defined by extensions. If omitted, the default is client_secret_basic -- the HTTP Basic Authentication Scheme specified in Section 2.3.1 of OAuth 2.0 [RFC6749]. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_methods_supported")] + public IEnumerable? TokenEndpointAuthMethodsSupported { get; set; } + + /// + /// JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used. + /// + [Optional] + [JsonPropertyName("token_endpoint_auth_signing_alg_values_supported")] + public IEnumerable? TokenEndpointAuthSigningAlgValuesSupported { get; set; } + + /// + /// Languages and scripts supported for the user interface, represented as a JSON array of BCP47 [RFC5646] language tag values. + /// + [Optional] + [JsonPropertyName("ui_locales_supported")] + public IEnumerable? UiLocalesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE [JWE] encryption algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_alg_values_supported")] + public IEnumerable? UserinfoEncryptionAlgValuesSupported { get; set; } + + /// + /// JSON array containing a list of the JWE encryption algorithms (enc values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. + /// + [Optional] + [JsonPropertyName("userinfo_encryption_enc_values_supported")] + public IEnumerable? UserinfoEncryptionEncValuesSupported { get; set; } + + /// + /// Optional URL of the identity provider's UserInfo endpoint. When configured with attribute mapping, Auth0 calls this endpoint to retrieve additional user profile claims using the access token. + /// + [Optional] + [JsonPropertyName("userinfo_endpoint")] + public string? UserinfoEndpoint { get; set; } + + /// + /// JSON array containing a list of the JWS [JWS] signing algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. The value none MAY be included. + /// + [Optional] + [JsonPropertyName("userinfo_signing_alg_values_supported")] + public IEnumerable? UserinfoSigningAlgValuesSupported { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum.cs new file mode 100644 index 000000000..c802f98ea --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum.EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum Openid100 = + new(Values.Openid100); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum OidcV4 = + new(Values.OidcV4); + + public EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsSchemaVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Openid100 = "openid-1.0.0"; + + public const string OidcV4 = "oidc-v4"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..777ed461d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum.cs new file mode 100644 index 000000000..99ccfc963 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum.EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum ClientSecretPost = + new(Values.ClientSecretPost); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum PrivateKeyJwt = + new(Values.PrivateKeyJwt); + + public EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthMethodEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ClientSecretPost = "client_secret_post"; + + public const string PrivateKeyJwt = "private_key_jwt"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs new file mode 100644 index 000000000..902601d8f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum.cs @@ -0,0 +1,164 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum.EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum Es256 = + new(Values.Es256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum Es384 = + new(Values.Es384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum Ps256 = + new(Values.Ps256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum Ps384 = + new(Values.Ps384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum Rs256 = + new(Values.Rs256); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum Rs384 = + new(Values.Rs384); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum Rs512 = + new(Values.Rs512); + + public EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointAuthSigningAlgEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Es256 = "ES256"; + + public const string Es384 = "ES384"; + + public const string Ps256 = "PS256"; + + public const string Ps384 = "PS384"; + + public const string Rs256 = "RS256"; + + public const string Rs384 = "RS384"; + + public const string Rs512 = "RS512"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs new file mode 100644 index 000000000..ecf998f9f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum.EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum Issuer = + new(Values.Issuer); + + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum TokenEndpoint = + new(Values.TokenEndpoint); + + public EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsTokenEndpointJwtcaAudFormatEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Issuer = "issuer"; + + public const string TokenEndpoint = "token_endpoint"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum.cs new file mode 100644 index 000000000..a8ccee481 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum.cs @@ -0,0 +1,126 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum.EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum BackChannel = + new(Values.BackChannel); + + public EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1OptionsTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BackChannel = "back_channel"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1StrategyEnum.cs new file mode 100644 index 000000000..dfbcfde20 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject1StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject1StrategyEnum.EventStreamCloudEventConnectionUpdatedObject1StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject1StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject1StrategyEnum Okta = new( + Values.Okta + ); + + public EventStreamCloudEventConnectionUpdatedObject1StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject1StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionUpdatedObject1StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject1StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject1StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject1StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject1StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject1StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject1StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject1StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject1StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject1StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Okta = "okta"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2.cs new file mode 100644 index 000000000..2918fe3c4 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject2 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionUpdatedObject2Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionUpdatedObject2ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionUpdatedObject2Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionUpdatedObject2Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionUpdatedObject2StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Authentication.cs new file mode 100644 index 000000000..d88b68b9c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject2Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2ConnectedAccounts.cs new file mode 100644 index 000000000..aae425bb6 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject2ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Metadata.cs new file mode 100644 index 000000000..1c7a121a9 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject2Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Options.cs new file mode 100644 index 000000000..5045b66c5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2Options.cs @@ -0,0 +1,225 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'samlp' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject2Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("assertion_decryption_settings")] + public EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettings? AssertionDecryptionSettings { get; set; } + + /// + /// X.509 signing certificate from the identity provider in .der format. Used to validate signatures in SAML Responses and Assertions. This is an alternative to signingCert and is kept for backward compatibility. Prefer using signingCert instead. + /// + [Optional] + [JsonPropertyName("cert")] + public string? Cert { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + [Optional] + [JsonPropertyName("digestAlgorithm")] + public EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum? DigestAlgorithm { get; set; } + + /// + /// Domain aliases for the connection + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// The entity identifier (Issuer) for the SAML Service Provider. When not provided, defaults to 'urn:auth0:{tenant}:{connection}'. This value is included in SAML AuthnRequest messages sent to the identity provider. + /// + [Optional] + [JsonPropertyName("entityId")] + public string? EntityId { get; set; } + + /// + /// ISO 8601 formatted datetime indicating when the identity provider's signing certificate expires. + /// + [Optional] + [JsonPropertyName("expires")] + public DateTime? Expires { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + [Optional] + [JsonPropertyName("idpinitiated")] + public EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiated? Idpinitiated { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("protocolBinding")] + public EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum? ProtocolBinding { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("signatureAlgorithm")] + public EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum? SignatureAlgorithm { get; set; } + + /// + /// Identity provider's SAML SingleSignOnService endpoint URL where Auth0 sends SAML authentication requests. This is the primary login URL for the SAML connection. Required unless using metadataUrl or metadataXml. + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Base64-encoded X.509 certificate from the identity provider used to validate signatures in SAML responses and assertions. The certificate is decoded and used for cryptographic signature verification. + /// + [Optional] + [JsonPropertyName("signingCert")] + public string? SigningCert { get; set; } + + /// + /// When true, Auth0 signs SAML authentication requests using the connection's signing key. The signature includes the request's digest and is validated by the identity provider. Defaults to false (unsigned requests). + /// + [Optional] + [JsonPropertyName("signSAMLRequest")] + public bool? SignSamlRequest { get; set; } + + [Optional] + [JsonPropertyName("subject")] + public EventStreamCloudEventConnectionUpdatedObject2OptionsSubject? Subject { get; set; } + + /// + /// For SAML connections, the tenant domain used to construct the login endpoint URL. Can be a string for single-tenant or an array of strings for multi-tenant validation. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// SHA-1 thumbprints (fingerprints) of the identity provider's signing certificates. Automatically computed from signingCert during connection creation. Each thumbprint must be a 40-character hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// When true, enables detailed SAML debugging by issuing 'w' (warning) events in tenant logs containing SAML request/response details. WARNING: Potentially exposes sensitive user information (PII, credentials) and should only be enabled temporarily for debugging purposes. + /// + [Optional] + [JsonPropertyName("debug")] + public bool? Debug { get; set; } + + /// + /// When true, enables DEFLATE compression for SAML requests sent via HTTP-Redirect binding. + /// + [Optional] + [JsonPropertyName("deflate")] + public bool? Deflate { get; set; } + + /// + /// The URL where Auth0 will send SAML authentication requests (the Identity Provider's SSO URL). Must be a valid HTTPS URL. + /// + [Optional] + [JsonPropertyName("destinationUrl")] + public string? DestinationUrl { get; set; } + + /// + /// When true, disables sending SAML logout requests (SingleLogoutService) to the identity provider during user sign-out. The user will be logged out of Auth0 but will remain logged into the identity provider. Defaults to false (federated logout enabled). + /// + [Optional] + [JsonPropertyName("disableSignout")] + public bool? DisableSignout { get; set; } + + [Optional] + [JsonPropertyName("fieldsMap")] + public Dictionary? FieldsMap { get; set; } + + /// + /// Expected 'iss' (Issuer) claim value for JWT tokens in Global Token Revocation requests from the identity provider. When configured, Auth0 validates the JWT issuer matches this value before processing token revocation. Must be used together with global_token_revocation_jwt_sub. + /// + [Optional] + [JsonPropertyName("global_token_revocation_jwt_iss")] + public string? GlobalTokenRevocationJwtIss { get; set; } + + /// + /// Expected 'sub' (Subject) claim value for JWT tokens in Global Token Revocation requests from the identity provider. When configured, Auth0 validates the JWT subject matches this value before processing token revocation. Must be used together with global_token_revocation_jwt_iss. + /// + [Optional] + [JsonPropertyName("global_token_revocation_jwt_sub")] + public string? GlobalTokenRevocationJwtSub { get; set; } + + /// + /// HTTPS URL to the identity provider's SAML metadata document. When provided, Auth0 automatically fetches and parses the metadata to extract signInEndpoint, signOutEndpoint, signingCert, signSAMLRequest, and protocolBinding. Use metadataUrl OR metadataXml, not both. + /// + [Optional] + [JsonPropertyName("metadataUrl")] + public string? MetadataUrl { get; set; } + + /// + /// The URL where Auth0 will send SAML authentication requests (the Identity Provider's SSO URL). Must be a valid HTTPS URL. + /// + [Optional] + [JsonPropertyName("recipientUrl")] + public string? RecipientUrl { get; set; } + + /// + /// Custom XML template for SAML authentication requests. Supports variable substitution using @@variableName@@ syntax. When not provided, uses default SAML AuthnRequest template. See https://auth0.com/docs/authenticate/protocols/saml/saml-sso-integrations/configure-auth0-saml-service-provider#customize-the-request-template + /// + [Optional] + [JsonPropertyName("requestTemplate")] + public string? RequestTemplate { get; set; } + + /// + /// Identity provider's SAML SingleLogoutService endpoint URL where Auth0 sends logout requests for federated sign-out. When not provided, defaults to signInEndpoint. Only used if disableSignout is false. + /// + [Optional] + [JsonPropertyName("signOutEndpoint")] + public string? SignOutEndpoint { get; set; } + + /// + /// Custom SAML assertion attribute to use as the unique user identifier. When provided, this attribute is prepended to the default user_id mapping list with highest priority. Accepts a string (single SAML attribute name). + /// + [Optional] + [JsonPropertyName("user_id_attribute")] + public string? UserIdAttribute { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettings.cs new file mode 100644 index 000000000..38e8f6822 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettings.cs @@ -0,0 +1,39 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Settings for SAML assertion decryption. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of insecure algorithms to allow for SAML assertion decryption. + /// + [Optional] + [JsonPropertyName("algorithm_exceptions")] + public IEnumerable? AlgorithmExceptions { get; set; } + + [JsonPropertyName("algorithm_profile")] + public required EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum AlgorithmProfile { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs new file mode 100644 index 000000000..e4ff7f21c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs @@ -0,0 +1,134 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum V20261 = + new(Values.V20261); + + public EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string V20261 = "v2026-1"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum.cs new file mode 100644 index 000000000..e7f66670c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum.EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum Sha1 = + new(Values.Sha1); + + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum Sha256 = + new(Values.Sha256); + + public EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Sha1 = "sha1"; + + public const string Sha256 = "sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiated.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiated.cs new file mode 100644 index 000000000..a222659c0 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiated.cs @@ -0,0 +1,53 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for IdP-Initiated SAML Single Sign-On. When enabled, allows users to initiate login directly from their SAML identity provider without first visiting Auth0. The IdP must include the connection parameter in the post-back URL (Assertion Consumer Service URL). +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiated : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// The query string sent to the default application + /// + [Optional] + [JsonPropertyName("client_authorizequery")] + public string? ClientAuthorizequery { get; set; } + + /// + /// The client ID to use for IdP-initiated login requests. + /// + [Optional] + [JsonPropertyName("client_id")] + public string? ClientId { get; set; } + + [Optional] + [JsonPropertyName("client_protocol")] + public EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum? ClientProtocol { get; set; } + + /// + /// When true, enables IdP-initiated login support for this SAML connection. Allows users to log in directly from the identity provider without first visiting Auth0. + /// + [Optional] + [JsonPropertyName("enabled")] + public bool? Enabled { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum.cs new file mode 100644 index 000000000..44baa95f7 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum.EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum Oidc = + new(Values.Oidc); + + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum Samlp = + new(Values.Samlp); + + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum Wsfed = + new(Values.Wsfed); + + public EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oidc = "oidc"; + + public const string Samlp = "samlp"; + + public const string Wsfed = "wsfed"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum.cs new file mode 100644 index 000000000..83dfa0ee7 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum.EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpPost = + new(Values.UrnOasisNamesTcSaml20BindingsHttpPost); + + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpRedirect = + new(Values.UrnOasisNamesTcSaml20BindingsHttpRedirect); + + public EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string UrnOasisNamesTcSaml20BindingsHttpPost = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"; + + public const string UrnOasisNamesTcSaml20BindingsHttpRedirect = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..0f58ec2b1 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum.cs new file mode 100644 index 000000000..8cbcf23a9 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum.EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum RsaSha1 = + new(Values.RsaSha1); + + public static readonly EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum RsaSha256 = + new(Values.RsaSha256); + + public EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string RsaSha1 = "rsa-sha1"; + + public const string RsaSha256 = "rsa-sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSubject.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSubject.cs new file mode 100644 index 000000000..bdf3c4297 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2OptionsSubject.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Certificate Subject Distinguished Name (DN) extracted from the identity provider's signing certificate. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject2OptionsSubject : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2StrategyEnum.cs new file mode 100644 index 000000000..099f248a9 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject2StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject2StrategyEnum.EventStreamCloudEventConnectionUpdatedObject2StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject2StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject2StrategyEnum Samlp = new( + Values.Samlp + ); + + public EventStreamCloudEventConnectionUpdatedObject2StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject2StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionUpdatedObject2StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject2StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject2StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject2StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject2StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject2StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject2StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject2StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject2StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject2StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Samlp = "samlp"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3.cs new file mode 100644 index 000000000..2989bdb23 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject3 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionUpdatedObject3Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionUpdatedObject3ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionUpdatedObject3Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionUpdatedObject3Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionUpdatedObject3StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Authentication.cs new file mode 100644 index 000000000..94b465cfc --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject3Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3ConnectedAccounts.cs new file mode 100644 index 000000000..76c9fc702 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject3ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Metadata.cs new file mode 100644 index 000000000..1377cadfc --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject3Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Options.cs new file mode 100644 index 000000000..b956c547c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3Options.cs @@ -0,0 +1,150 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'pingfederate' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject3Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("assertion_decryption_settings")] + public EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettings? AssertionDecryptionSettings { get; set; } + + /// + /// X.509 signing certificate from the identity provider in .der format. Used to validate signatures in SAML Responses and Assertions. This is an alternative to signingCert and is kept for backward compatibility. Prefer using signingCert instead. + /// + [Optional] + [JsonPropertyName("cert")] + public string? Cert { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + [Optional] + [JsonPropertyName("digestAlgorithm")] + public EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum? DigestAlgorithm { get; set; } + + /// + /// Domain aliases for the connection + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// The entity identifier (Issuer) for the SAML Service Provider. When not provided, defaults to 'urn:auth0:{tenant}:{connection}'. This value is included in SAML AuthnRequest messages sent to the identity provider. + /// + [Optional] + [JsonPropertyName("entityId")] + public string? EntityId { get; set; } + + /// + /// ISO 8601 formatted datetime indicating when the identity provider's signing certificate expires. + /// + [Optional] + [JsonPropertyName("expires")] + public DateTime? Expires { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + [Optional] + [JsonPropertyName("idpinitiated")] + public EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiated? Idpinitiated { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("protocolBinding")] + public EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum? ProtocolBinding { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("signatureAlgorithm")] + public EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum? SignatureAlgorithm { get; set; } + + /// + /// Identity provider's SAML SingleSignOnService endpoint URL where Auth0 sends SAML authentication requests. This is the primary login URL for the SAML connection. Required unless using metadataUrl or metadataXml. + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Base64-encoded X.509 certificate from the identity provider used to validate signatures in SAML responses and assertions. The certificate is decoded and used for cryptographic signature verification. + /// + [Optional] + [JsonPropertyName("signingCert")] + public string? SigningCert { get; set; } + + /// + /// When true, Auth0 signs SAML authentication requests using the connection's signing key. The signature includes the request's digest and is validated by the identity provider. Defaults to false (unsigned requests). + /// + [Optional] + [JsonPropertyName("signSAMLRequest")] + public bool? SignSamlRequest { get; set; } + + [Optional] + [JsonPropertyName("subject")] + public EventStreamCloudEventConnectionUpdatedObject3OptionsSubject? Subject { get; set; } + + /// + /// For SAML connections, the tenant domain used to construct the login endpoint URL. Can be a string for single-tenant or an array of strings for multi-tenant validation. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// SHA-1 thumbprints (fingerprints) of the identity provider's signing certificates. Automatically computed from signingCert during connection creation. Each thumbprint must be a 40-character hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// URL provided by PingFederate which returns information used for creating the connection + /// + [JsonPropertyName("pingFederateBaseUrl")] + public required string PingFederateBaseUrl { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettings.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettings.cs new file mode 100644 index 000000000..41dd5c8ef --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettings.cs @@ -0,0 +1,39 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Settings for SAML assertion decryption. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettings + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// A list of insecure algorithms to allow for SAML assertion decryption. + /// + [Optional] + [JsonPropertyName("algorithm_exceptions")] + public IEnumerable? AlgorithmExceptions { get; set; } + + [JsonPropertyName("algorithm_profile")] + public required EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum AlgorithmProfile { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs new file mode 100644 index 000000000..486f21680 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.cs @@ -0,0 +1,134 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum.EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum V20261 = + new(Values.V20261); + + public EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsAssertionDecryptionSettingsAlgorithmProfileEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string V20261 = "v2026-1"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum.cs new file mode 100644 index 000000000..f7b91fdf4 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum.EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum Sha1 = + new(Values.Sha1); + + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum Sha256 = + new(Values.Sha256); + + public EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsDigestAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Sha1 = "sha1"; + + public const string Sha256 = "sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiated.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiated.cs new file mode 100644 index 000000000..546400cb9 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiated.cs @@ -0,0 +1,53 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for IdP-Initiated SAML Single Sign-On. When enabled, allows users to initiate login directly from their SAML identity provider without first visiting Auth0. The IdP must include the connection parameter in the post-back URL (Assertion Consumer Service URL). +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiated : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// The query string sent to the default application + /// + [Optional] + [JsonPropertyName("client_authorizequery")] + public string? ClientAuthorizequery { get; set; } + + /// + /// The client ID to use for IdP-initiated login requests. + /// + [Optional] + [JsonPropertyName("client_id")] + public string? ClientId { get; set; } + + [Optional] + [JsonPropertyName("client_protocol")] + public EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum? ClientProtocol { get; set; } + + /// + /// When true, enables IdP-initiated login support for this SAML connection. Allows users to log in directly from the identity provider without first visiting Auth0. + /// + [Optional] + [JsonPropertyName("enabled")] + public bool? Enabled { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum.cs new file mode 100644 index 000000000..0db71eb8e --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum.EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum Oidc = + new(Values.Oidc); + + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum Samlp = + new(Values.Samlp); + + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum Wsfed = + new(Values.Wsfed); + + public EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsIdpinitiatedClientProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oidc = "oidc"; + + public const string Samlp = "samlp"; + + public const string Wsfed = "wsfed"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum.cs new file mode 100644 index 000000000..834a72559 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum.EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpPost = + new(Values.UrnOasisNamesTcSaml20BindingsHttpPost); + + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum UrnOasisNamesTcSaml20BindingsHttpRedirect = + new(Values.UrnOasisNamesTcSaml20BindingsHttpRedirect); + + public EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsProtocolBindingEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string UrnOasisNamesTcSaml20BindingsHttpPost = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"; + + public const string UrnOasisNamesTcSaml20BindingsHttpRedirect = + "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..e2121303c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum.cs new file mode 100644 index 000000000..1de9707f2 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum.cs @@ -0,0 +1,137 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum.EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum RsaSha1 = + new(Values.RsaSha1); + + public static readonly EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum RsaSha256 = + new(Values.RsaSha256); + + public EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3OptionsSignatureAlgorithmEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string RsaSha1 = "rsa-sha1"; + + public const string RsaSha256 = "rsa-sha256"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSubject.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSubject.cs new file mode 100644 index 000000000..768c803eb --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3OptionsSubject.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Certificate Subject Distinguished Name (DN) extracted from the identity provider's signing certificate. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject3OptionsSubject : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3StrategyEnum.cs new file mode 100644 index 000000000..d5af4bc6c --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject3StrategyEnum.cs @@ -0,0 +1,124 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject3StrategyEnum.EventStreamCloudEventConnectionUpdatedObject3StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject3StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject3StrategyEnum Pingfederate = + new(Values.Pingfederate); + + public EventStreamCloudEventConnectionUpdatedObject3StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject3StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionUpdatedObject3StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject3StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject3StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject3StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject3StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject3StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject3StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject3StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject3StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject3StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Pingfederate = "pingfederate"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4.cs new file mode 100644 index 000000000..aff158c24 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject4 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionUpdatedObject4Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionUpdatedObject4ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionUpdatedObject4Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionUpdatedObject4Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionUpdatedObject4StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Authentication.cs new file mode 100644 index 000000000..c1819c3e4 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject4Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4ConnectedAccounts.cs new file mode 100644 index 000000000..47bd2ba34 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject4ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Metadata.cs new file mode 100644 index 000000000..7d32738dd --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject4Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Options.cs new file mode 100644 index 000000000..0af9396cb --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4Options.cs @@ -0,0 +1,124 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'adfs' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject4Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// ADFS federation metadata host or XML URL used to discover WS-Fed endpoints and certificates. Errors if adfs_server and fedMetadataXml are both absent. + /// + [Optional] + [JsonPropertyName("adfs_server")] + public string? AdfsServer { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// The entity identifier (Issuer) for the ADFS Service Provider. When not provided, defaults to 'urn:auth0:{tenant}:{connection}'. + /// + [Optional] + [JsonPropertyName("entityId")] + public string? EntityId { get; set; } + + /// + /// Inline XML alternative to 'adfs_server'. Cannot be set together with 'adfs_server'. + /// + [Optional] + [JsonPropertyName("fedMetadataXml")] + public string? FedMetadataXml { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + /// + /// Array of certificate thumbprints (SHA-128/SHA-256/SHA-512 hex hashes) for validating SAML signatures. Used with WS-Federation protocol. Maximum 20 thumbprints. Each thumbprint must be a hexadecimal string. + /// + [Optional] + [JsonPropertyName("prev_thumbprints")] + public IEnumerable? PrevThumbprints { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("should_trust_email_verified_connection")] + public EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum? ShouldTrustEmailVerifiedConnection { get; set; } + + /// + /// Passive Requestor (WS-Fed) sign-in endpoint discovered from metadata or provided explicitly. + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Tenant domain + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// Array of certificate thumbprints (SHA-128/SHA-256/SHA-512 hex hashes) for validating SAML signatures. Used with WS-Federation protocol. Maximum 20 thumbprints. Each thumbprint must be a hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Custom ADFS claim to use as the unique user identifier. When provided, this attribute is prepended to the default user_id mapping list with highest priority. Accepts a string (single ADFS claim name). + /// + [Optional] + [JsonPropertyName("user_id_attribute")] + public string? UserIdAttribute { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..4122db2c2 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject4OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs new file mode 100644 index 000000000..324fd65da --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum.EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum NeverSetEmailsAsVerified = + new(Values.NeverSetEmailsAsVerified); + + public static readonly EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum AlwaysSetEmailsAsVerified = + new(Values.AlwaysSetEmailsAsVerified); + + public EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject4OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string NeverSetEmailsAsVerified = "never_set_emails_as_verified"; + + public const string AlwaysSetEmailsAsVerified = "always_set_emails_as_verified"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4StrategyEnum.cs new file mode 100644 index 000000000..c16d800d5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject4StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject4StrategyEnum.EventStreamCloudEventConnectionUpdatedObject4StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject4StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject4StrategyEnum Adfs = new( + Values.Adfs + ); + + public EventStreamCloudEventConnectionUpdatedObject4StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject4StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionUpdatedObject4StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject4StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject4StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject4StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject4StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject4StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject4StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject4StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject4StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject4StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject4StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject4StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Adfs = "adfs"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5.cs new file mode 100644 index 000000000..9424f74ac --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5.cs @@ -0,0 +1,84 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject5 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionUpdatedObject5Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionUpdatedObject5ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionUpdatedObject5Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionUpdatedObject5Options? Options { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionUpdatedObject5StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Authentication.cs new file mode 100644 index 000000000..af95c79f3 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject5Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5ConnectedAccounts.cs new file mode 100644 index 000000000..cf6d0fa89 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject5ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Metadata.cs new file mode 100644 index 000000000..a44cf1525 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject5Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Options.cs new file mode 100644 index 000000000..008b958b9 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5Options.cs @@ -0,0 +1,148 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'ad' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject5Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// IP address of the AD connector agent used to validate that authentication requests originate from the corporate network for Kerberos authentication (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("agentIP")] + public string? AgentIp { get; set; } + + /// + /// When enabled, allows direct username/password authentication through the AD connector agent instead of WS-Federation protocol (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("agentMode")] + public bool? AgentMode { get; set; } + + /// + /// Version identifier of the installed AD connector agent software (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("agentVersion")] + public string? AgentVersion { get; set; } + + /// + /// Enables Auth0's brute force protection to prevent credential stuffing attacks. When enabled, blocks suspicious login attempts from specific IP addresses after repeated failures. + /// + [Optional] + [JsonPropertyName("brute_force_protection")] + public bool? BruteForceProtection { get; set; } + + /// + /// Enables client SSL certificate authentication for the AD connector, requiring HTTPS on the sign-in endpoint + /// + [Optional] + [JsonPropertyName("certAuth")] + public bool? CertAuth { get; set; } + + /// + /// Array of X.509 certificates in PEM format used for validating SAML signatures from the AD identity provider (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("certs")] + public IEnumerable? Certs { get; set; } + + /// + /// When enabled, disables caching of AD connector authentication results to ensure real-time validation against the directory + /// + [Optional] + [JsonPropertyName("disable_cache")] + public bool? DisableCache { get; set; } + + /// + /// When enabled, hides the 'Forgot Password' link on login pages to prevent users from initiating self-service password resets + /// + [Optional] + [JsonPropertyName("disable_self_service_change_password")] + public bool? DisableSelfServiceChangePassword { get; set; } + + /// + /// List of domain names that can be used with identifier-first authentication flow to route users to this AD connection; each domain must be a valid DNS name up to 256 characters + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// https url of the icon to be shown + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Array of IP address ranges in CIDR notation used to determine if authentication requests originate from the corporate network for Kerberos or certificate authentication. + /// + [Optional] + [JsonPropertyName("ips")] + public IEnumerable? Ips { get; set; } + + /// + /// Enables Windows Integrated Authentication (Kerberos) for seamless SSO when users authenticate from within the corporate network IP ranges + /// + [Optional] + [JsonPropertyName("kerberos")] + public bool? Kerberos { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// The sign-in endpoint type for the AD-LDAP connector agent (managed by the AD Connector agent). + /// + [Optional] + [JsonPropertyName("signInEndpoint")] + public string? SignInEndpoint { get; set; } + + /// + /// Primary AD domain hint used for HRD and discovery. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// Array of certificate SHA-1 thumbprints for validating signatures. Managed by Auth0 when using the AD Connector agent. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..46e2ef504 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject5OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5StrategyEnum.cs new file mode 100644 index 000000000..99a23ecd5 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject5StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject5StrategyEnum.EventStreamCloudEventConnectionUpdatedObject5StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject5StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject5StrategyEnum Ad = new( + Values.Ad + ); + + public EventStreamCloudEventConnectionUpdatedObject5StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject5StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionUpdatedObject5StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject5StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject5StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject5StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject5StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject5StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject5StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject5StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject5StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject5StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject5StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject5StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Ad = "ad"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6.cs new file mode 100644 index 000000000..55912f250 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject6 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionUpdatedObject6Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionUpdatedObject6ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionUpdatedObject6Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionUpdatedObject6Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionUpdatedObject6StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Authentication.cs new file mode 100644 index 000000000..368cb9cca --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject6Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6ConnectedAccounts.cs new file mode 100644 index 000000000..b88e995dd --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject6ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Metadata.cs new file mode 100644 index 000000000..afd31b34d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject6Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Options.cs new file mode 100644 index 000000000..f95b5c49f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6Options.cs @@ -0,0 +1,179 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'google-apps' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject6Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Expiration timestamp for the `admin_access_token` in ISO 8601 format. Auth0 uses this value to determine when to refresh the token. + /// + [Optional] + [JsonPropertyName("admin_access_token_expiresin")] + public DateTime? AdminAccessTokenExpiresin { get; set; } + + /// + /// When true, allows customization of OAuth scopes requested during user login. Custom scopes are appended to the mandatory email and profile scopes. When false or omitted, only the default email and profile scopes are used. This property is automatically enabled when Token Vault or Connected Accounts features are activated. + /// + [Optional] + [JsonPropertyName("allow_setting_login_scopes")] + public bool? AllowSettingLoginScopes { get; set; } + + /// + /// Enables integration with the Google Workspace Admin SDK Directory API for groups. When true, Auth0 can synchronize groups & group memberships and supports inbound directory provisioning for groups. Defaults to false. + /// + [Optional] + [JsonPropertyName("api_enable_groups")] + public bool? ApiEnableGroups { get; set; } + + /// + /// Enables integration with the Google Workspace Admin SDK Directory API. When true, Auth0 can retrieve extended user attributes (admin status, suspension status, group memberships) and supports inbound directory provisioning (SCIM). Defaults to true. + /// + [Optional] + [JsonPropertyName("api_enable_users")] + public bool? ApiEnableUsers { get; set; } + + /// + /// Your Google OAuth 2.0 client ID. You can find this in your [Google Cloud Console](https://console.cloud.google.com/apis/credentials) under the OAuth 2.0 Client IDs section. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + /// + /// Primary Google Workspace domain name that users must belong to. + /// + [Optional] + [JsonPropertyName("domain")] + public string? Domain { get; set; } + + /// + /// Email domains associated with this connection for Home Realm Discovery (HRD). When a user's email matches one of these domains, they are automatically routed to this connection during authentication. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// Whether the OAuth flow requests the `email` scope. + /// + [Optional] + [JsonPropertyName("email")] + public bool? Email { get; set; } + + /// + /// Fetches the `agreedToTerms` flag from the Google Directory profile. + /// + [Optional] + [JsonPropertyName("ext_agreed_terms")] + public bool? ExtAgreedTerms { get; set; } + + /// + /// Enables enrichment with Google group memberships (required for `ext_groups_extended`). + /// + [Optional] + [JsonPropertyName("ext_groups")] + public bool? ExtGroups { get; set; } + + /// + /// Controls whether enriched group entries include `id`, `email`, `name` (true) or only the group name (false); can only be set when `ext_groups` is true. + /// + [Optional] + [JsonPropertyName("ext_groups_extended")] + public bool? ExtGroupsExtended { get; set; } + + /// + /// Fetches the Google Directory admin flag for the signing-in user. + /// + [Optional] + [JsonPropertyName("ext_is_admin")] + public bool? ExtIsAdmin { get; set; } + + /// + /// Fetches the Google Directory suspended flag for the signing-in user. + /// + [Optional] + [JsonPropertyName("ext_is_suspended")] + public bool? ExtIsSuspended { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionUpdatedObject6OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// When enabled, users who sign in with their Google account through a social login will be automatically routed to this Google Workspace connection if their email domain matches the configured tenant_domain or domain_aliases. This ensures enterprise users authenticate through their organization's Google Workspace identity provider rather than through a generic Google social login, enabling access to directory-based attributes and enforcing organizational security policies. Defaults to true for new connections. + /// + [Optional] + [JsonPropertyName("handle_login_from_social")] + public bool? HandleLoginFromSocial { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + /// + /// Determines how Auth0 generates the user_id for Google Workspace users. When false (default), the user's email address is used. When true, Google's stable numeric user ID is used instead, which persists even if the user's email changes. This setting can only be configured when creating the connection and cannot be changed afterward. + /// + [Optional] + [JsonPropertyName("map_user_id_to_id")] + public bool? MapUserIdToId { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + /// + /// Whether the OAuth flow requests the `profile` scope. + /// + [Optional] + [JsonPropertyName("profile")] + public bool? Profile { get; set; } + + /// + /// Additional OAuth scopes requested beyond the default `email profile` scopes; ignored unless `allow_setting_login_scopes` is true. + /// + [Optional] + [JsonPropertyName("scope")] + public IEnumerable? Scope { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + /// + /// The Google Workspace primary domain used to identify the organization during authentication. + /// + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..6ef524d74 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject6OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..e57f21de7 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject6OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6StrategyEnum.cs new file mode 100644 index 000000000..6dc865b70 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject6StrategyEnum.cs @@ -0,0 +1,124 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject6StrategyEnum.EventStreamCloudEventConnectionUpdatedObject6StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject6StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject6StrategyEnum GoogleApps = + new(Values.GoogleApps); + + public EventStreamCloudEventConnectionUpdatedObject6StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject6StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionUpdatedObject6StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject6StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject6StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject6StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject6StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject6StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject6StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject6StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject6StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject6StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject6StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject6StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string GoogleApps = "google-apps"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7.cs new file mode 100644 index 000000000..abf1439bd --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7.cs @@ -0,0 +1,91 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject7 : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [Optional] + [JsonPropertyName("authentication")] + public EventStreamCloudEventConnectionUpdatedObject7Authentication? Authentication { get; set; } + + [Optional] + [JsonPropertyName("connected_accounts")] + public EventStreamCloudEventConnectionUpdatedObject7ConnectedAccounts? ConnectedAccounts { get; set; } + + /// + /// Connection name used in the new universal login experience + /// + [Optional] + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Use of this property is NOT RECOMMENDED. Use the PATCH /v2/connections/{id}/clients endpoint to enable the connection for a set of clients. + /// + [Optional] + [JsonPropertyName("enabled_clients")] + public IEnumerable? EnabledClients { get; set; } + + /// + /// The connection's identifier + /// + [JsonPropertyName("id")] + public required string Id { get; set; } + + /// + /// true promotes to a domain-level connection so that third-party applications can use it. false does not promote the connection, so only first-party applications with the connection enabled can use it. (Defaults to false.) + /// + [Optional] + [JsonPropertyName("is_domain_connection")] + public bool? IsDomainConnection { get; set; } + + [Optional] + [JsonPropertyName("metadata")] + public EventStreamCloudEventConnectionUpdatedObject7Metadata? Metadata { get; set; } + + /// + /// The name of the connection. Must start and end with an alphanumeric character and can only contain alphanumeric characters and '-'. Max length 128 + /// + [JsonPropertyName("name")] + public required string Name { get; set; } + + /// + /// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. + /// + [Optional] + [JsonPropertyName("realms")] + public IEnumerable? Realms { get; set; } + + [Optional] + [JsonPropertyName("options")] + public EventStreamCloudEventConnectionUpdatedObject7Options? Options { get; set; } + + /// + /// Enables showing a button for the connection in the login page (new experience only). If false, it will be usable only by HRD. Defaults to `false`. + /// + [Optional] + [JsonPropertyName("show_as_button")] + public bool? ShowAsButton { get; set; } + + [JsonPropertyName("strategy")] + public required EventStreamCloudEventConnectionUpdatedObject7StrategyEnum Strategy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Authentication.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Authentication.cs new file mode 100644 index 000000000..fc5c34338 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Authentication.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for authentication during login. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject7Authentication : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7ConnectedAccounts.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7ConnectedAccounts.cs new file mode 100644 index 000000000..6e6b231db --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7ConnectedAccounts.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configure the purpose of a connection to be used for connected accounts and Token Vault. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject7ConnectedAccounts : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Metadata.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Metadata.cs new file mode 100644 index 000000000..d924ce768 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Metadata.cs @@ -0,0 +1,28 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject7Metadata : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Options.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Options.cs new file mode 100644 index 000000000..e7e52fa44 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7Options.cs @@ -0,0 +1,199 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Options for the 'waad' connection +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject7Options : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enable users API + /// + [Optional] + [JsonPropertyName("api_enable_users")] + public bool? ApiEnableUsers { get; set; } + + /// + /// The Azure AD application domain (e.g., 'contoso.onmicrosoft.com'). Used primarily with WS-Federation protocol and Azure AD v1 endpoints. + /// + [Optional] + [JsonPropertyName("app_domain")] + public string? AppDomain { get; set; } + + /// + /// The Application ID URI (App ID URI) for the Azure AD application. Required when using Azure AD v1 with the Resource Owner Password flow. Used to identify the resource being requested in OAuth token requests. + /// + [Optional] + [JsonPropertyName("app_id")] + public string? AppId { get; set; } + + /// + /// Includes basic user profile information from Azure AD (name, email, given_name, family_name). Always enabled and required - represents the minimum profile data retrieved during authentication. + /// + [Optional] + [JsonPropertyName("basic_profile")] + public bool? BasicProfile { get; set; } + + /// + /// Timestamp of the last certificate expiring soon notification. + /// + [Optional] + [JsonPropertyName("cert_rollover_notification")] + public DateTime? CertRolloverNotification { get; set; } + + /// + /// OAuth 2.0 client identifier issued by the identity provider during application registration. This value identifies your Auth0 connection to the identity provider. + /// + [JsonPropertyName("client_id")] + public required string ClientId { get; set; } + + /// + /// The primary Azure AD tenant domain (e.g., 'contoso.onmicrosoft.com' or 'contoso.com'). + /// + [Optional] + [JsonPropertyName("domain")] + public string? Domain { get; set; } + + /// + /// Alternative domain names associated with this Azure AD tenant. Allows users from multiple verified domains to authenticate through this connection. Can be an array of domain strings. + /// + [Optional] + [JsonPropertyName("domain_aliases")] + public IEnumerable? DomainAliases { get; set; } + + /// + /// When enabled (true), retrieves and stores Azure AD security group memberships for the user. Requires Microsoft Graph API permissions (Directory.Read.All). Allows configuring max_groups_to_retrieve. + /// + [Optional] + [JsonPropertyName("ext_groups")] + public bool? ExtGroups { get; set; } + + /// + /// When true, stores all groups the user is member of, including transitive group memberships (groups within groups). When false (default), only direct group memberships are included. + /// + [Optional] + [JsonPropertyName("ext_nested_groups")] + public bool? ExtNestedGroups { get; set; } + + /// + /// When enabled (true), retrieves extended profile attributes from Azure AD via Microsoft Graph API (job title, department, office location, etc.). Requires Graph API permissions. Only available with Azure AD v1 or when explicitly enabled for v2. + /// + [Optional] + [JsonPropertyName("ext_profile")] + public bool? ExtProfile { get; set; } + + [Optional] + [JsonPropertyName("federated_connections_access_tokens")] + public EventStreamCloudEventConnectionUpdatedObject7OptionsFederatedConnectionsAccessTokens? FederatedConnectionsAccessTokens { get; set; } + + /// + /// Indicates whether admin consent has been granted for the required Azure AD permissions. Read-only status field managed by Auth0 during the OAuth authorization flow. + /// + [Optional] + [JsonPropertyName("granted")] + public bool? Granted { get; set; } + + /// + /// URL for the connection icon displayed in Auth0 login pages. Accepts HTTPS URLs. Used for visual branding in authentication flows. + /// + [Optional] + [JsonPropertyName("icon_url")] + public string? IconUrl { get; set; } + + [Optional] + [JsonPropertyName("identity_api")] + public EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum? IdentityApi { get; set; } + + /// + /// Maximum number of Azure AD groups to retrieve per user during authentication. Helps prevent performance issues for users in many groups. Only applies when ext_groups is enabled. Leave empty to use platform default. + /// + [Optional] + [JsonPropertyName("max_groups_to_retrieve")] + public string? MaxGroupsToRetrieve { get; set; } + + /// + /// An array of user fields that should not be stored in the Auth0 database (https://auth0.com/docs/security/data-security/denylist) + /// + [Optional] + [JsonPropertyName("non_persistent_attrs")] + public IEnumerable? NonPersistentAttrs { get; set; } + + /// + /// OAuth 2.0 scopes to request from Azure AD during authentication. Each scope represents a permission (e.g., 'User.Read', 'Group.Read.All'). Only applies with Microsoft Identity Platform v2.0. See Microsoft Graph permissions reference for available scopes. + /// + [Optional] + [JsonPropertyName("scope")] + public IEnumerable? Scope { get; set; } + + [Optional] + [JsonPropertyName("set_user_root_attributes")] + public EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum? SetUserRootAttributes { get; set; } + + [Optional] + [JsonPropertyName("should_trust_email_verified_connection")] + public EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum? ShouldTrustEmailVerifiedConnection { get; set; } + + [Optional] + [JsonPropertyName("tenant_domain")] + public string? TenantDomain { get; set; } + + /// + /// The Azure AD tenant ID as a UUID. The unique identifier for your Azure AD organization. Must be a valid 36-character UUID. + /// + [Optional] + [JsonPropertyName("tenantId")] + public string? TenantId { get; set; } + + /// + /// Array of certificate thumbprints (SHA-128/SHA-256/SHA-512 hex hashes) for validating SAML signatures. Used with WS-Federation protocol. Maximum 20 thumbprints. Each thumbprint must be a hexadecimal string. + /// + [Optional] + [JsonPropertyName("thumbprints")] + public IEnumerable? Thumbprints { get; set; } + + [Optional] + [JsonPropertyName("upstream_params")] + public Dictionary? UpstreamParams { get; set; } + + /// + /// Indicates WS-Federation protocol usage. When true, uses WS-Federation; when false, uses OpenID Connect. + /// + [Optional] + [JsonPropertyName("use_wsfed")] + public bool? UseWsfed { get; set; } + + /// + /// When enabled (true), uses the Azure AD common endpoint for multi-tenant authentication. Allows users from any Azure AD organization to sign in. Requires userid_attribute set to 'sub' (not 'oid'). Cannot be used with SCIM provisioning. Defaults to false. + /// + [Optional] + [JsonPropertyName("useCommonEndpoint")] + public bool? UseCommonEndpoint { get; set; } + + [Optional] + [JsonPropertyName("userid_attribute")] + public EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum? UseridAttribute { get; set; } + + [Optional] + [JsonPropertyName("waad_protocol")] + public EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum? WaadProtocol { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsFederatedConnectionsAccessTokens.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsFederatedConnectionsAccessTokens.cs new file mode 100644 index 000000000..6a89fbd4a --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsFederatedConnectionsAccessTokens.cs @@ -0,0 +1,35 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +/// +/// Configuration for storing identity provider tokens in Auth0's Token Vault. When active, Auth0 securely stores access and refresh tokens from federated logins, enabling your application to make authenticated API calls on behalf of users. +/// +[Serializable] +public record EventStreamCloudEventConnectionUpdatedObject7OptionsFederatedConnectionsAccessTokens + : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Enables refresh tokens and access tokens collection for federated connections + /// + [JsonPropertyName("active")] + public required bool Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum.cs new file mode 100644 index 000000000..9f97df293 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum.EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum MicrosoftIdentityPlatformV20 = + new(Values.MicrosoftIdentityPlatformV20); + + public static readonly EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum AzureActiveDirectoryV10 = + new(Values.AzureActiveDirectoryV10); + + public EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7OptionsIdentityApiEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string MicrosoftIdentityPlatformV20 = "microsoft-identity-platform-v2.0"; + + public const string AzureActiveDirectoryV10 = "azure-active-directory-v1.0"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum.cs new file mode 100644 index 000000000..10b411808 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum.cs @@ -0,0 +1,144 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum.EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum OnEachLogin = + new(Values.OnEachLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum OnFirstLogin = + new(Values.OnFirstLogin); + + public static readonly EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum NeverOnLogin = + new(Values.NeverOnLogin); + + public EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7OptionsSetUserRootAttributesEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string OnEachLogin = "on_each_login"; + + public const string OnFirstLogin = "on_first_login"; + + public const string NeverOnLogin = "never_on_login"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs new file mode 100644 index 000000000..fbd88daf4 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.cs @@ -0,0 +1,139 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum.EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum NeverSetEmailsAsVerified = + new(Values.NeverSetEmailsAsVerified); + + public static readonly EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum AlwaysSetEmailsAsVerified = + new(Values.AlwaysSetEmailsAsVerified); + + public EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + value + ); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7OptionsShouldTrustEmailVerifiedConnectionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string NeverSetEmailsAsVerified = "never_set_emails_as_verified"; + + public const string AlwaysSetEmailsAsVerified = "always_set_emails_as_verified"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum.cs new file mode 100644 index 000000000..7acacccf4 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum.EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum Oid = + new(Values.Oid); + + public static readonly EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum Sub = + new(Values.Sub); + + public EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7OptionsUseridAttributeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Oid = "oid"; + + public const string Sub = "sub"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum.cs new file mode 100644 index 000000000..b65c2993d --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum.cs @@ -0,0 +1,135 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum.EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum WsFederation = + new(Values.WsFederation); + + public static readonly EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum OpenidConnect = + new(Values.OpenidConnect); + + public EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum FromCustom( + string value + ) + { + return new EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum( + stringValue + ); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum( + stringValue + ); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7OptionsWaadProtocolEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string WsFederation = "ws-federation"; + + public const string OpenidConnect = "openid-connect"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7StrategyEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7StrategyEnum.cs new file mode 100644 index 000000000..1befab760 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedObject7StrategyEnum.cs @@ -0,0 +1,125 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedObject7StrategyEnum.EventStreamCloudEventConnectionUpdatedObject7StrategyEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedObject7StrategyEnum + : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedObject7StrategyEnum Waad = new( + Values.Waad + ); + + public EventStreamCloudEventConnectionUpdatedObject7StrategyEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedObject7StrategyEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionUpdatedObject7StrategyEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedObject7StrategyEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedObject7StrategyEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + EventStreamCloudEventConnectionUpdatedObject7StrategyEnum value + ) => value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedObject7StrategyEnum( + string value + ) => new(value); + + internal class EventStreamCloudEventConnectionUpdatedObject7StrategyEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedObject7StrategyEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7StrategyEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedObject7StrategyEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedObject7StrategyEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedObject7StrategyEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Waad = "waad"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedTypeEnum.cs new file mode 100644 index 000000000..95f6e8879 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventConnectionUpdatedTypeEnum.cs @@ -0,0 +1,122 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventConnectionUpdatedTypeEnum.EventStreamCloudEventConnectionUpdatedTypeEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventConnectionUpdatedTypeEnum : IStringEnum +{ + public static readonly EventStreamCloudEventConnectionUpdatedTypeEnum ConnectionUpdated = new( + Values.ConnectionUpdated + ); + + public EventStreamCloudEventConnectionUpdatedTypeEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventConnectionUpdatedTypeEnum FromCustom(string value) + { + return new EventStreamCloudEventConnectionUpdatedTypeEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + EventStreamCloudEventConnectionUpdatedTypeEnum value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + EventStreamCloudEventConnectionUpdatedTypeEnum value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string(EventStreamCloudEventConnectionUpdatedTypeEnum value) => + value.Value; + + public static explicit operator EventStreamCloudEventConnectionUpdatedTypeEnum(string value) => + new(value); + + internal class EventStreamCloudEventConnectionUpdatedTypeEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventConnectionUpdatedTypeEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedTypeEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventConnectionUpdatedTypeEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventConnectionUpdatedTypeEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventConnectionUpdatedTypeEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string ConnectionUpdated = "connection.updated"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupCreatedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupCreatedCloudEvent.cs index 0ce09e2f4..9274fa1ce 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupCreatedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupCreatedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventGroupCreatedCloudEvent : IJsonOnDeserialized private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventGroupCreatedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupDeletedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupDeletedCloudEvent.cs index a5d39f8e1..d3a2b36dc 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupDeletedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupDeletedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventGroupDeletedCloudEvent : IJsonOnDeserialized private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventGroupDeletedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupMemberAddedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupMemberAddedCloudEvent.cs index d18d6ba39..19d50d5e0 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupMemberAddedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupMemberAddedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventGroupMemberAddedCloudEvent : IJsonOnDeseriali private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventGroupMemberAddedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupMemberDeletedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupMemberDeletedCloudEvent.cs index 4212f8938..d2f4625d9 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupMemberDeletedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupMemberDeletedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventGroupMemberDeletedCloudEvent : IJsonOnDeseria private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventGroupMemberDeletedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupRoleAssignedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupRoleAssignedCloudEvent.cs index 3b81adc00..9e57af9af 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupRoleAssignedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupRoleAssignedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventGroupRoleAssignedCloudEvent : IJsonOnDeserial private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventGroupRoleAssignedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupRoleDeletedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupRoleDeletedCloudEvent.cs index a25699616..05a6709f2 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupRoleDeletedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupRoleDeletedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventGroupRoleDeletedCloudEvent : IJsonOnDeseriali private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventGroupRoleDeletedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupUpdatedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupUpdatedCloudEvent.cs index 95b9bad78..5bc8223c4 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupUpdatedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventGroupUpdatedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventGroupUpdatedCloudEvent : IJsonOnDeserialized private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventGroupUpdatedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionAddedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionAddedCloudEvent.cs index 026d72318..9c33621b3 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionAddedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionAddedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgConnectionAddedCloudEvent : IJsonOnDeseria private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgConnectionAddedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionRemovedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionRemovedCloudEvent.cs index 70dd43061..efd333eea 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionRemovedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionRemovedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgConnectionRemovedCloudEvent : IJsonOnDeser private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgConnectionRemovedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionUpdatedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionUpdatedCloudEvent.cs index 8a09de4a3..f2d4a98cf 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionUpdatedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgConnectionUpdatedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgConnectionUpdatedCloudEvent : IJsonOnDeser private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgConnectionUpdatedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgCreatedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgCreatedCloudEvent.cs index 1ad5967e8..483b694a3 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgCreatedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgCreatedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgCreatedCloudEvent : IJsonOnDeserialized private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgCreatedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgDeletedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgDeletedCloudEvent.cs index 4592bb5bc..507b2cf02 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgDeletedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgDeletedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgDeletedCloudEvent : IJsonOnDeserialized private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgDeletedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgGroupRoleAssignedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgGroupRoleAssignedCloudEvent.cs index 1ea1e2b2e..0fb8dccab 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgGroupRoleAssignedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgGroupRoleAssignedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgGroupRoleAssignedCloudEvent : IJsonOnDeser private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgGroupRoleAssignedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgGroupRoleDeletedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgGroupRoleDeletedCloudEvent.cs index d466f0268..ecf4159cd 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgGroupRoleDeletedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgGroupRoleDeletedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgGroupRoleDeletedCloudEvent : IJsonOnDeseri private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgGroupRoleDeletedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberAddedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberAddedCloudEvent.cs index d87676e6f..bf7339e66 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberAddedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberAddedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgMemberAddedCloudEvent : IJsonOnDeserialize private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgMemberAddedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberDeletedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberDeletedCloudEvent.cs index a9c7ec0e1..1c8ff89b0 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberDeletedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberDeletedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgMemberDeletedCloudEvent : IJsonOnDeseriali private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgMemberDeletedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberRoleAssignedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberRoleAssignedCloudEvent.cs index c498ab932..e1bab0851 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberRoleAssignedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberRoleAssignedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgMemberRoleAssignedCloudEvent : IJsonOnDese private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgMemberRoleAssignedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberRoleDeletedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberRoleDeletedCloudEvent.cs index bb3c59d77..57cf44b59 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberRoleDeletedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgMemberRoleDeletedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgMemberRoleDeletedCloudEvent : IJsonOnDeser private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgMemberRoleDeletedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgUpdatedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgUpdatedCloudEvent.cs index abb637848..3910ddd29 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgUpdatedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventOrgUpdatedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventOrgUpdatedCloudEvent : IJsonOnDeserialized private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventOrgUpdatedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventSpecVersionEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventSpecVersionEnum.cs new file mode 100644 index 000000000..91204b344 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventSpecVersionEnum.cs @@ -0,0 +1,116 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(EventStreamCloudEventSpecVersionEnum.EventStreamCloudEventSpecVersionEnumSerializer) +)] +[Serializable] +public readonly record struct EventStreamCloudEventSpecVersionEnum : IStringEnum +{ + public static readonly EventStreamCloudEventSpecVersionEnum One0 = new(Values.One0); + + public EventStreamCloudEventSpecVersionEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static EventStreamCloudEventSpecVersionEnum FromCustom(string value) + { + return new EventStreamCloudEventSpecVersionEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(EventStreamCloudEventSpecVersionEnum value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(EventStreamCloudEventSpecVersionEnum value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(EventStreamCloudEventSpecVersionEnum value) => + value.Value; + + public static explicit operator EventStreamCloudEventSpecVersionEnum(string value) => + new(value); + + internal class EventStreamCloudEventSpecVersionEnumSerializer + : JsonConverter + { + public override EventStreamCloudEventSpecVersionEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new EventStreamCloudEventSpecVersionEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + EventStreamCloudEventSpecVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override EventStreamCloudEventSpecVersionEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new EventStreamCloudEventSpecVersionEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + EventStreamCloudEventSpecVersionEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string One0 = "1.0"; + } +} diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserCreatedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserCreatedCloudEvent.cs index 203fe6e49..0e04872c1 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserCreatedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserCreatedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventUserCreatedCloudEvent : IJsonOnDeserialized private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventUserCreatedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserDeletedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserDeletedCloudEvent.cs index 2dcf161e7..ee83fcf0b 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserDeletedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserDeletedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventUserDeletedCloudEvent : IJsonOnDeserialized private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventUserDeletedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserUpdatedCloudEvent.cs b/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserUpdatedCloudEvent.cs index 533fe205a..636d9003d 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserUpdatedCloudEvent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamCloudEventUserUpdatedCloudEvent.cs @@ -14,11 +14,8 @@ public record EventStreamCloudEventUserUpdatedCloudEvent : IJsonOnDeserialized private readonly IDictionary _extensionData = new Dictionary(); - /// - /// The version of the CloudEvents specification which the event uses. - /// [JsonPropertyName("specversion")] - public required string Specversion { get; set; } + public required EventStreamCloudEventSpecVersionEnum Specversion { get; set; } [JsonPropertyName("type")] public required EventStreamCloudEventUserUpdatedCloudEventTypeEnum Type { get; set; } diff --git a/src/Auth0.ManagementApi/Types/EventStreamDeliveryEventTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamDeliveryEventTypeEnum.cs index d7eb466eb..6e4107e94 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamDeliveryEventTypeEnum.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamDeliveryEventTypeEnum.cs @@ -8,6 +8,18 @@ namespace Auth0.ManagementApi; [Serializable] public readonly record struct EventStreamDeliveryEventTypeEnum : IStringEnum { + public static readonly EventStreamDeliveryEventTypeEnum ConnectionCreated = new( + Values.ConnectionCreated + ); + + public static readonly EventStreamDeliveryEventTypeEnum ConnectionDeleted = new( + Values.ConnectionDeleted + ); + + public static readonly EventStreamDeliveryEventTypeEnum ConnectionUpdated = new( + Values.ConnectionUpdated + ); + public static readonly EventStreamDeliveryEventTypeEnum GroupCreated = new(Values.GroupCreated); public static readonly EventStreamDeliveryEventTypeEnum GroupDeleted = new(Values.GroupDeleted); @@ -181,6 +193,12 @@ JsonSerializerOptions options [Serializable] public static class Values { + public const string ConnectionCreated = "connection.created"; + + public const string ConnectionDeleted = "connection.deleted"; + + public const string ConnectionUpdated = "connection.updated"; + public const string GroupCreated = "group.created"; public const string GroupDeleted = "group.deleted"; diff --git a/src/Auth0.ManagementApi/Types/EventStreamEventTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamEventTypeEnum.cs index 99d1e53cd..6c0193709 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamEventTypeEnum.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamEventTypeEnum.cs @@ -8,6 +8,18 @@ namespace Auth0.ManagementApi; [Serializable] public readonly record struct EventStreamEventTypeEnum : IStringEnum { + public static readonly EventStreamEventTypeEnum ConnectionCreated = new( + Values.ConnectionCreated + ); + + public static readonly EventStreamEventTypeEnum ConnectionDeleted = new( + Values.ConnectionDeleted + ); + + public static readonly EventStreamEventTypeEnum ConnectionUpdated = new( + Values.ConnectionUpdated + ); + public static readonly EventStreamEventTypeEnum GroupCreated = new(Values.GroupCreated); public static readonly EventStreamEventTypeEnum GroupDeleted = new(Values.GroupDeleted); @@ -176,6 +188,12 @@ JsonSerializerOptions options [Serializable] public static class Values { + public const string ConnectionCreated = "connection.created"; + + public const string ConnectionDeleted = "connection.deleted"; + + public const string ConnectionUpdated = "connection.updated"; + public const string GroupCreated = "group.created"; public const string GroupDeleted = "group.deleted"; diff --git a/src/Auth0.ManagementApi/Types/EventStreamSubscribeEventsEventTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamSubscribeEventsEventTypeEnum.cs index 58b2c81f0..64af03dc6 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamSubscribeEventsEventTypeEnum.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamSubscribeEventsEventTypeEnum.cs @@ -10,6 +10,18 @@ namespace Auth0.ManagementApi; [Serializable] public readonly record struct EventStreamSubscribeEventsEventTypeEnum : IStringEnum { + public static readonly EventStreamSubscribeEventsEventTypeEnum ConnectionCreated = new( + Values.ConnectionCreated + ); + + public static readonly EventStreamSubscribeEventsEventTypeEnum ConnectionDeleted = new( + Values.ConnectionDeleted + ); + + public static readonly EventStreamSubscribeEventsEventTypeEnum ConnectionUpdated = new( + Values.ConnectionUpdated + ); + public static readonly EventStreamSubscribeEventsEventTypeEnum GroupCreated = new( Values.GroupCreated ); @@ -190,6 +202,12 @@ JsonSerializerOptions options [Serializable] public static class Values { + public const string ConnectionCreated = "connection.created"; + + public const string ConnectionDeleted = "connection.deleted"; + + public const string ConnectionUpdated = "connection.updated"; + public const string GroupCreated = "group.created"; public const string GroupDeleted = "group.deleted"; diff --git a/src/Auth0.ManagementApi/Types/EventStreamSubscribeEventsResponseContent.cs b/src/Auth0.ManagementApi/Types/EventStreamSubscribeEventsResponseContent.cs index 6a533716c..d7a0f6100 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamSubscribeEventsResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamSubscribeEventsResponseContent.cs @@ -21,6 +21,39 @@ internal EventStreamSubscribeEventsResponseContent(string type, object? value) Value = value; } + /// + /// Create an instance of EventStreamSubscribeEventsResponseContent with . + /// + public EventStreamSubscribeEventsResponseContent( + EventStreamSubscribeEventsResponseContent.ConnectionCreated value + ) + { + Type = "connection.created"; + Value = value.Value; + } + + /// + /// Create an instance of EventStreamSubscribeEventsResponseContent with . + /// + public EventStreamSubscribeEventsResponseContent( + EventStreamSubscribeEventsResponseContent.ConnectionDeleted value + ) + { + Type = "connection.deleted"; + Value = value.Value; + } + + /// + /// Create an instance of EventStreamSubscribeEventsResponseContent with . + /// + public EventStreamSubscribeEventsResponseContent( + EventStreamSubscribeEventsResponseContent.ConnectionUpdated value + ) + { + Type = "connection.updated"; + Value = value.Value; + } + /// /// Create an instance of EventStreamSubscribeEventsResponseContent with . /// @@ -296,6 +329,21 @@ EventStreamSubscribeEventsResponseContent.OffsetOnly value /// public object? Value { get; internal set; } + /// + /// Returns true if is "connection.created" + /// + public bool IsConnectionCreated => Type == "connection.created"; + + /// + /// Returns true if is "connection.deleted" + /// + public bool IsConnectionDeleted => Type == "connection.deleted"; + + /// + /// Returns true if is "connection.updated" + /// + public bool IsConnectionUpdated => Type == "connection.updated"; + /// /// Returns true if is "group.created" /// @@ -416,6 +464,39 @@ EventStreamSubscribeEventsResponseContent.OffsetOnly value /// public bool IsOffsetOnly => Type == "offset-only"; + /// + /// Returns the value as a if is 'connection.created', otherwise throws an exception. + /// + /// Thrown when is not 'connection.created'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionCreated AsConnectionCreated() => + IsConnectionCreated + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionCreated)Value! + : throw new global::System.Exception( + "EventStreamSubscribeEventsResponseContent.Type is not 'connection.created'" + ); + + /// + /// Returns the value as a if is 'connection.deleted', otherwise throws an exception. + /// + /// Thrown when is not 'connection.deleted'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionDeleted AsConnectionDeleted() => + IsConnectionDeleted + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionDeleted)Value! + : throw new global::System.Exception( + "EventStreamSubscribeEventsResponseContent.Type is not 'connection.deleted'" + ); + + /// + /// Returns the value as a if is 'connection.updated', otherwise throws an exception. + /// + /// Thrown when is not 'connection.updated'. + public Auth0.ManagementApi.EventStreamCloudEventConnectionUpdated AsConnectionUpdated() => + IsConnectionUpdated + ? (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdated)Value! + : throw new global::System.Exception( + "EventStreamSubscribeEventsResponseContent.Type is not 'connection.updated'" + ); + /// /// Returns the value as a if is 'group.created', otherwise throws an exception. /// @@ -681,6 +762,9 @@ public Auth0.ManagementApi.EventStreamCloudEventOffsetOnlyMessage AsOffsetOnly() ); public T Match( + Func onConnectionCreated, + Func onConnectionDeleted, + Func onConnectionUpdated, Func onGroupCreated, Func onGroupDeleted, Func onGroupMemberAdded, @@ -734,6 +818,9 @@ public T Match( { return Type switch { + "connection.created" => onConnectionCreated(AsConnectionCreated()), + "connection.deleted" => onConnectionDeleted(AsConnectionDeleted()), + "connection.updated" => onConnectionUpdated(AsConnectionUpdated()), "group.created" => onGroupCreated(AsGroupCreated()), "group.deleted" => onGroupDeleted(AsGroupDeleted()), "group.member.added" => onGroupMemberAdded(AsGroupMemberAdded()), @@ -779,6 +866,9 @@ public T Match( } public void Visit( + global::System.Action onConnectionCreated, + global::System.Action onConnectionDeleted, + global::System.Action onConnectionUpdated, global::System.Action onGroupCreated, global::System.Action onGroupDeleted, global::System.Action onGroupMemberAdded, @@ -808,6 +898,15 @@ public void Visit( { switch (Type) { + case "connection.created": + onConnectionCreated(AsConnectionCreated()); + break; + case "connection.deleted": + onConnectionDeleted(AsConnectionDeleted()); + break; + case "connection.updated": + onConnectionUpdated(AsConnectionUpdated()); + break; case "group.created": onGroupCreated(AsGroupCreated()); break; @@ -886,6 +985,54 @@ public void Visit( } } + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryAsConnectionCreated( + out Auth0.ManagementApi.EventStreamCloudEventConnectionCreated? value + ) + { + if (Type == "connection.created") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionCreated)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryAsConnectionDeleted( + out Auth0.ManagementApi.EventStreamCloudEventConnectionDeleted? value + ) + { + if (Type == "connection.deleted") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionDeleted)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryAsConnectionUpdated( + out Auth0.ManagementApi.EventStreamCloudEventConnectionUpdated? value + ) + { + if (Type == "connection.updated") + { + value = (Auth0.ManagementApi.EventStreamCloudEventConnectionUpdated)Value!; + return true; + } + value = null; + return false; + } + /// /// Attempts to cast the value to a and returns true if successful. /// @@ -1258,6 +1405,18 @@ out Auth0.ManagementApi.EventStreamCloudEventOffsetOnlyMessage? value public override string ToString() => JsonUtils.Serialize(this); + public static implicit operator EventStreamSubscribeEventsResponseContent( + EventStreamSubscribeEventsResponseContent.ConnectionCreated value + ) => new(value); + + public static implicit operator EventStreamSubscribeEventsResponseContent( + EventStreamSubscribeEventsResponseContent.ConnectionDeleted value + ) => new(value); + + public static implicit operator EventStreamSubscribeEventsResponseContent( + EventStreamSubscribeEventsResponseContent.ConnectionUpdated value + ) => new(value); + public static implicit operator EventStreamSubscribeEventsResponseContent( EventStreamSubscribeEventsResponseContent.GroupCreated value ) => new(value); @@ -1395,6 +1554,27 @@ JsonSerializerOptions options var value = discriminator switch { + "connection.created" => + jsonWithoutDiscriminator.Deserialize( + options + ) + ?? throw new JsonException( + "Failed to deserialize Auth0.ManagementApi.EventStreamCloudEventConnectionCreated" + ), + "connection.deleted" => + jsonWithoutDiscriminator.Deserialize( + options + ) + ?? throw new JsonException( + "Failed to deserialize Auth0.ManagementApi.EventStreamCloudEventConnectionDeleted" + ), + "connection.updated" => + jsonWithoutDiscriminator.Deserialize( + options + ) + ?? throw new JsonException( + "Failed to deserialize Auth0.ManagementApi.EventStreamCloudEventConnectionUpdated" + ), "group.created" => jsonWithoutDiscriminator.Deserialize( options @@ -1577,6 +1757,9 @@ JsonSerializerOptions options JsonNode json = value.Type switch { + "connection.created" => JsonSerializer.SerializeToNode(value.Value, options), + "connection.deleted" => JsonSerializer.SerializeToNode(value.Value, options), + "connection.updated" => JsonSerializer.SerializeToNode(value.Value, options), "group.created" => JsonSerializer.SerializeToNode(value.Value, options), "group.deleted" => JsonSerializer.SerializeToNode(value.Value, options), "group.member.added" => JsonSerializer.SerializeToNode(value.Value, options), @@ -1656,6 +1839,66 @@ JsonSerializerOptions options } } + /// + /// Discriminated union type for connection.created + /// + [Serializable] + public struct ConnectionCreated + { + public ConnectionCreated(Auth0.ManagementApi.EventStreamCloudEventConnectionCreated value) + { + Value = value; + } + + internal Auth0.ManagementApi.EventStreamCloudEventConnectionCreated Value { get; set; } + + public override string ToString() => Value.ToString() ?? "null"; + + public static implicit operator EventStreamSubscribeEventsResponseContent.ConnectionCreated( + Auth0.ManagementApi.EventStreamCloudEventConnectionCreated value + ) => new(value); + } + + /// + /// Discriminated union type for connection.deleted + /// + [Serializable] + public struct ConnectionDeleted + { + public ConnectionDeleted(Auth0.ManagementApi.EventStreamCloudEventConnectionDeleted value) + { + Value = value; + } + + internal Auth0.ManagementApi.EventStreamCloudEventConnectionDeleted Value { get; set; } + + public override string ToString() => Value.ToString() ?? "null"; + + public static implicit operator EventStreamSubscribeEventsResponseContent.ConnectionDeleted( + Auth0.ManagementApi.EventStreamCloudEventConnectionDeleted value + ) => new(value); + } + + /// + /// Discriminated union type for connection.updated + /// + [Serializable] + public struct ConnectionUpdated + { + public ConnectionUpdated(Auth0.ManagementApi.EventStreamCloudEventConnectionUpdated value) + { + Value = value; + } + + internal Auth0.ManagementApi.EventStreamCloudEventConnectionUpdated Value { get; set; } + + public override string ToString() => Value.ToString() ?? "null"; + + public static implicit operator EventStreamSubscribeEventsResponseContent.ConnectionUpdated( + Auth0.ManagementApi.EventStreamCloudEventConnectionUpdated value + ) => new(value); + } + /// /// Discriminated union type for group.created /// diff --git a/src/Auth0.ManagementApi/Types/EventStreamTestEventTypeEnum.cs b/src/Auth0.ManagementApi/Types/EventStreamTestEventTypeEnum.cs index f1ccb5fac..b67ab6eb6 100644 --- a/src/Auth0.ManagementApi/Types/EventStreamTestEventTypeEnum.cs +++ b/src/Auth0.ManagementApi/Types/EventStreamTestEventTypeEnum.cs @@ -8,6 +8,18 @@ namespace Auth0.ManagementApi; [Serializable] public readonly record struct EventStreamTestEventTypeEnum : IStringEnum { + public static readonly EventStreamTestEventTypeEnum ConnectionCreated = new( + Values.ConnectionCreated + ); + + public static readonly EventStreamTestEventTypeEnum ConnectionDeleted = new( + Values.ConnectionDeleted + ); + + public static readonly EventStreamTestEventTypeEnum ConnectionUpdated = new( + Values.ConnectionUpdated + ); + public static readonly EventStreamTestEventTypeEnum GroupCreated = new(Values.GroupCreated); public static readonly EventStreamTestEventTypeEnum GroupDeleted = new(Values.GroupDeleted); @@ -181,6 +193,12 @@ JsonSerializerOptions options [Serializable] public static class Values { + public const string ConnectionCreated = "connection.created"; + + public const string ConnectionDeleted = "connection.deleted"; + + public const string ConnectionUpdated = "connection.updated"; + public const string GroupCreated = "group.created"; public const string GroupDeleted = "group.deleted"; diff --git a/src/Auth0.ManagementApi/Types/GetOrganizationByNameResponseContent.cs b/src/Auth0.ManagementApi/Types/GetOrganizationByNameResponseContent.cs index d4c467e0d..997c30814 100644 --- a/src/Auth0.ManagementApi/Types/GetOrganizationByNameResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/GetOrganizationByNameResponseContent.cs @@ -43,6 +43,10 @@ public record GetOrganizationByNameResponseContent : IJsonOnDeserialized, IJsonO [JsonPropertyName("token_quota")] public TokenQuota? TokenQuota { get; set; } + [Optional] + [JsonPropertyName("third_party_client_access")] + public OrganizationThirdPartyClientAccessEnum? ThirdPartyClientAccess { get; set; } + [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/GetOrganizationResponseContent.cs b/src/Auth0.ManagementApi/Types/GetOrganizationResponseContent.cs index a1ab01606..8e9b08872 100644 --- a/src/Auth0.ManagementApi/Types/GetOrganizationResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/GetOrganizationResponseContent.cs @@ -43,6 +43,10 @@ public record GetOrganizationResponseContent : IJsonOnDeserialized, IJsonOnSeria [JsonPropertyName("token_quota")] public TokenQuota? TokenQuota { get; set; } + [Optional] + [JsonPropertyName("third_party_client_access")] + public OrganizationThirdPartyClientAccessEnum? ThirdPartyClientAccess { get; set; } + [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/ListOrganizationRoleMembersResponseContent.cs b/src/Auth0.ManagementApi/Types/ListOrganizationRoleMembersResponseContent.cs new file mode 100644 index 000000000..aec752ddc --- /dev/null +++ b/src/Auth0.ManagementApi/Types/ListOrganizationRoleMembersResponseContent.cs @@ -0,0 +1,38 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record ListOrganizationRoleMembersResponseContent : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// List of members assigned to the role within the organization. + /// + [JsonPropertyName("members")] + public IEnumerable Members { get; set; } = new List(); + + /// + /// Cursor for the next page of results. Absent when there are no more results. + /// + [Optional] + [JsonPropertyName("next")] + public string? Next { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/ListRolesOffsetPaginatedResponseContent.cs b/src/Auth0.ManagementApi/Types/ListRolesOffsetPaginatedResponseContent.cs index 2cf1a8682..2a0c25e23 100644 --- a/src/Auth0.ManagementApi/Types/ListRolesOffsetPaginatedResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/ListRolesOffsetPaginatedResponseContent.cs @@ -11,17 +11,14 @@ public record ListRolesOffsetPaginatedResponseContent : IJsonOnDeserialized private readonly IDictionary _extensionData = new Dictionary(); - [Optional] [JsonPropertyName("start")] - public double? Start { get; set; } + public required double Start { get; set; } - [Optional] [JsonPropertyName("limit")] - public double? Limit { get; set; } + public required double Limit { get; set; } - [Optional] [JsonPropertyName("total")] - public double? Total { get; set; } + public required double Total { get; set; } [Optional] [JsonPropertyName("roles")] diff --git a/src/Auth0.ManagementApi/Types/NotFoundErrorBody.cs b/src/Auth0.ManagementApi/Types/NotFoundErrorBody.cs new file mode 100644 index 000000000..4c5daf876 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/NotFoundErrorBody.cs @@ -0,0 +1,34 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record NotFoundErrorBody : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("message")] + public required string Message { get; set; } + + [JsonPropertyName("statusCode")] + public required string StatusCode { get; set; } + + [JsonPropertyName("error")] + public required NotFoundErrorBodyError Error { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/NotFoundErrorBodyError.cs b/src/Auth0.ManagementApi/Types/NotFoundErrorBodyError.cs new file mode 100644 index 000000000..95b4e81d7 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/NotFoundErrorBodyError.cs @@ -0,0 +1,111 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter(typeof(NotFoundErrorBodyError.NotFoundErrorBodyErrorSerializer))] +[Serializable] +public readonly record struct NotFoundErrorBodyError : IStringEnum +{ + public static readonly NotFoundErrorBodyError NotFound = new(Values.NotFound); + + public NotFoundErrorBodyError(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static NotFoundErrorBodyError FromCustom(string value) + { + return new NotFoundErrorBodyError(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(NotFoundErrorBodyError value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(NotFoundErrorBodyError value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(NotFoundErrorBodyError value) => value.Value; + + public static explicit operator NotFoundErrorBodyError(string value) => new(value); + + internal class NotFoundErrorBodyErrorSerializer : JsonConverter + { + public override NotFoundErrorBodyError Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new NotFoundErrorBodyError(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + NotFoundErrorBodyError value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override NotFoundErrorBodyError ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new NotFoundErrorBodyError(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + NotFoundErrorBodyError value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string NotFound = "Not Found"; + } +} diff --git a/src/Auth0.ManagementApi/Types/Organization.cs b/src/Auth0.ManagementApi/Types/Organization.cs index 40fc8010d..9de4151a5 100644 --- a/src/Auth0.ManagementApi/Types/Organization.cs +++ b/src/Auth0.ManagementApi/Types/Organization.cs @@ -43,6 +43,10 @@ public record Organization : IJsonOnDeserialized, IJsonOnSerializing [JsonPropertyName("token_quota")] public TokenQuota? TokenQuota { get; set; } + [Optional] + [JsonPropertyName("third_party_client_access")] + public OrganizationThirdPartyClientAccessEnum? ThirdPartyClientAccess { get; set; } + [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/OrganizationThirdPartyClientAccessEnum.cs b/src/Auth0.ManagementApi/Types/OrganizationThirdPartyClientAccessEnum.cs new file mode 100644 index 000000000..c0903e900 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/OrganizationThirdPartyClientAccessEnum.cs @@ -0,0 +1,120 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter( + typeof(OrganizationThirdPartyClientAccessEnum.OrganizationThirdPartyClientAccessEnumSerializer) +)] +[Serializable] +public readonly record struct OrganizationThirdPartyClientAccessEnum : IStringEnum +{ + public static readonly OrganizationThirdPartyClientAccessEnum Block = new(Values.Block); + + public static readonly OrganizationThirdPartyClientAccessEnum Allow = new(Values.Allow); + + public OrganizationThirdPartyClientAccessEnum(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static OrganizationThirdPartyClientAccessEnum FromCustom(string value) + { + return new OrganizationThirdPartyClientAccessEnum(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(OrganizationThirdPartyClientAccessEnum value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(OrganizationThirdPartyClientAccessEnum value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(OrganizationThirdPartyClientAccessEnum value) => + value.Value; + + public static explicit operator OrganizationThirdPartyClientAccessEnum(string value) => + new(value); + + internal class OrganizationThirdPartyClientAccessEnumSerializer + : JsonConverter + { + public override OrganizationThirdPartyClientAccessEnum Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new OrganizationThirdPartyClientAccessEnum(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + OrganizationThirdPartyClientAccessEnum value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override OrganizationThirdPartyClientAccessEnum ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new OrganizationThirdPartyClientAccessEnum(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + OrganizationThirdPartyClientAccessEnum value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Block = "block"; + + public const string Allow = "allow"; + } +} diff --git a/src/Auth0.ManagementApi/Types/PartialGroupsEnum.cs b/src/Auth0.ManagementApi/Types/PartialGroupsEnum.cs index 0cb9e84b3..374a842ff 100644 --- a/src/Auth0.ManagementApi/Types/PartialGroupsEnum.cs +++ b/src/Auth0.ManagementApi/Types/PartialGroupsEnum.cs @@ -26,6 +26,8 @@ namespace Auth0.ManagementApi; public static readonly PartialGroupsEnum Passkeys = new(Values.Passkeys); + public static readonly PartialGroupsEnum Confirmation = new(Values.Confirmation); + public PartialGroupsEnum(string value) { Value = value; @@ -139,5 +141,7 @@ public static class Values public const string CustomizedConsent = "customized-consent"; public const string Passkeys = "passkeys"; + + public const string Confirmation = "confirmation"; } } diff --git a/src/Auth0.ManagementApi/Types/PhoneAttribute.cs b/src/Auth0.ManagementApi/Types/PhoneAttribute.cs index 1e9955380..064b74cef 100644 --- a/src/Auth0.ManagementApi/Types/PhoneAttribute.cs +++ b/src/Auth0.ManagementApi/Types/PhoneAttribute.cs @@ -16,7 +16,7 @@ public record PhoneAttribute : IJsonOnDeserialized [Optional] [JsonPropertyName("identifier")] - public ConnectionAttributeIdentifier? Identifier { get; set; } + public PhoneAttributeIdentifier? Identifier { get; set; } /// /// Determines if property should be required for users diff --git a/src/Auth0.ManagementApi/Types/PhoneAttributeIdentifier.cs b/src/Auth0.ManagementApi/Types/PhoneAttributeIdentifier.cs new file mode 100644 index 000000000..b7c08daa9 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/PhoneAttributeIdentifier.cs @@ -0,0 +1,36 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record PhoneAttributeIdentifier : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Determines if the attribute is used for identification + /// + [Optional] + [JsonPropertyName("active")] + public bool? Active { get; set; } + + [Optional] + [JsonPropertyName("default_method")] + public DefaultMethodPhoneNumberIdentifierEnum? DefaultMethod { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/PhoneProviderProtectionBackoffStrategyEnum.cs b/src/Auth0.ManagementApi/Types/PhoneProviderProtectionBackoffStrategyEnum.cs index fa68341e5..1d7727d5f 100644 --- a/src/Auth0.ManagementApi/Types/PhoneProviderProtectionBackoffStrategyEnum.cs +++ b/src/Auth0.ManagementApi/Types/PhoneProviderProtectionBackoffStrategyEnum.cs @@ -14,7 +14,7 @@ namespace Auth0.ManagementApi; Values.Exponential ); - public static readonly PhoneProviderProtectionBackoffStrategyEnum None = new(Values.None); + public static readonly PhoneProviderProtectionBackoffStrategyEnum Default = new(Values.Default); public PhoneProviderProtectionBackoffStrategyEnum(string value) { @@ -121,6 +121,6 @@ public static class Values { public const string Exponential = "exponential"; - public const string None = "none"; + public const string Default = "default"; } } diff --git a/src/Auth0.ManagementApi/Types/RoleMember.cs b/src/Auth0.ManagementApi/Types/RoleMember.cs new file mode 100644 index 000000000..2162b5c55 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/RoleMember.cs @@ -0,0 +1,53 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record RoleMember : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// ID of this user. + /// + [Optional] + [JsonPropertyName("user_id")] + public string? UserId { get; set; } + + /// + /// URL to a picture for this user. + /// + [Optional] + [JsonPropertyName("picture")] + public string? Picture { get; set; } + + /// + /// Name of this user. + /// + [Optional] + [JsonPropertyName("name")] + public string? Name { get; set; } + + /// + /// Email address of this user. + /// + [Optional] + [JsonPropertyName("email")] + public string? Email { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/TokenVaultPrivilegedAccessGrant.cs b/src/Auth0.ManagementApi/Types/TokenVaultPrivilegedAccessGrant.cs new file mode 100644 index 000000000..b8b78a55f --- /dev/null +++ b/src/Auth0.ManagementApi/Types/TokenVaultPrivilegedAccessGrant.cs @@ -0,0 +1,31 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record TokenVaultPrivilegedAccessGrant : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("connection")] + public required string Connection { get; set; } + + [JsonPropertyName("scopes")] + public IEnumerable Scopes { get; set; } = new List(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/TooManyRequestsErrorBody.cs b/src/Auth0.ManagementApi/Types/TooManyRequestsErrorBody.cs new file mode 100644 index 000000000..323f80ac8 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/TooManyRequestsErrorBody.cs @@ -0,0 +1,34 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record TooManyRequestsErrorBody : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("message")] + public required string Message { get; set; } + + [JsonPropertyName("statusCode")] + public required string StatusCode { get; set; } + + [JsonPropertyName("error")] + public required TooManyRequestsErrorBodyError Error { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/Types/TooManyRequestsErrorBodyError.cs b/src/Auth0.ManagementApi/Types/TooManyRequestsErrorBodyError.cs new file mode 100644 index 000000000..1fe3128b7 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/TooManyRequestsErrorBodyError.cs @@ -0,0 +1,114 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[JsonConverter(typeof(TooManyRequestsErrorBodyError.TooManyRequestsErrorBodyErrorSerializer))] +[Serializable] +public readonly record struct TooManyRequestsErrorBodyError : IStringEnum +{ + public static readonly TooManyRequestsErrorBodyError TooManyRequests = new( + Values.TooManyRequests + ); + + public TooManyRequestsErrorBodyError(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static TooManyRequestsErrorBodyError FromCustom(string value) + { + return new TooManyRequestsErrorBodyError(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(TooManyRequestsErrorBodyError value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(TooManyRequestsErrorBodyError value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(TooManyRequestsErrorBodyError value) => value.Value; + + public static explicit operator TooManyRequestsErrorBodyError(string value) => new(value); + + internal class TooManyRequestsErrorBodyErrorSerializer + : JsonConverter + { + public override TooManyRequestsErrorBodyError Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new TooManyRequestsErrorBodyError(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + TooManyRequestsErrorBodyError value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override TooManyRequestsErrorBodyError ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new TooManyRequestsErrorBodyError(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + TooManyRequestsErrorBodyError value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string TooManyRequests = "Too Many Requests"; + } +} diff --git a/src/Auth0.ManagementApi/Types/UpdateConnectionOptions.cs b/src/Auth0.ManagementApi/Types/UpdateConnectionOptions.cs index 68338c4f2..6831fbe6b 100644 --- a/src/Auth0.ManagementApi/Types/UpdateConnectionOptions.cs +++ b/src/Auth0.ManagementApi/Types/UpdateConnectionOptions.cs @@ -186,6 +186,14 @@ public Optional DiscoveryUrl { get; set; } + + [Nullable, Optional] + [JsonPropertyName("oidc_metadata")] + public Optional OidcMetadata { get; set; } + [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/UpdateOrganizationResponseContent.cs b/src/Auth0.ManagementApi/Types/UpdateOrganizationResponseContent.cs index 0dc7c12dd..c272704e1 100644 --- a/src/Auth0.ManagementApi/Types/UpdateOrganizationResponseContent.cs +++ b/src/Auth0.ManagementApi/Types/UpdateOrganizationResponseContent.cs @@ -43,6 +43,10 @@ public record UpdateOrganizationResponseContent : IJsonOnDeserialized, IJsonOnSe [JsonPropertyName("token_quota")] public TokenQuota? TokenQuota { get; set; } + [Optional] + [JsonPropertyName("third_party_client_access")] + public OrganizationThirdPartyClientAccessEnum? ThirdPartyClientAccess { get; set; } + [JsonIgnore] public AdditionalProperties AdditionalProperties { get; set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/UserGrant.cs b/src/Auth0.ManagementApi/Types/UserGrant.cs index f9e99a681..95fa21f9e 100644 --- a/src/Auth0.ManagementApi/Types/UserGrant.cs +++ b/src/Auth0.ManagementApi/Types/UserGrant.cs @@ -46,6 +46,13 @@ public record UserGrant : IJsonOnDeserialized [JsonPropertyName("scope")] public IEnumerable? Scope { get; set; } + /// + /// ID of the organization associated with the grant. + /// + [Optional] + [JsonPropertyName("organization_id")] + public string? OrganizationId { get; set; } + [JsonIgnore] public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); diff --git a/src/Auth0.ManagementApi/Types/UsernameAttribute.cs b/src/Auth0.ManagementApi/Types/UsernameAttribute.cs index e731092dd..8b3f889ec 100644 --- a/src/Auth0.ManagementApi/Types/UsernameAttribute.cs +++ b/src/Auth0.ManagementApi/Types/UsernameAttribute.cs @@ -16,7 +16,7 @@ public record UsernameAttribute : IJsonOnDeserialized [Optional] [JsonPropertyName("identifier")] - public ConnectionAttributeIdentifier? Identifier { get; set; } + public UsernameAttributeIdentifier? Identifier { get; set; } /// /// Determines if property should be required for users diff --git a/src/Auth0.ManagementApi/Types/UsernameAttributeIdentifier.cs b/src/Auth0.ManagementApi/Types/UsernameAttributeIdentifier.cs new file mode 100644 index 000000000..5fcb339f1 --- /dev/null +++ b/src/Auth0.ManagementApi/Types/UsernameAttributeIdentifier.cs @@ -0,0 +1,32 @@ +using Auth0.ManagementApi.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace Auth0.ManagementApi; + +[Serializable] +public record UsernameAttributeIdentifier : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Determines if the attribute is used for identification + /// + [Optional] + [JsonPropertyName("active")] + public bool? Active { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/Auth0.ManagementApi/UserAttributeProfiles/IUserAttributeProfilesClient.cs b/src/Auth0.ManagementApi/UserAttributeProfiles/IUserAttributeProfilesClient.cs index 305909eb4..2f037a052 100644 --- a/src/Auth0.ManagementApi/UserAttributeProfiles/IUserAttributeProfilesClient.cs +++ b/src/Auth0.ManagementApi/UserAttributeProfiles/IUserAttributeProfilesClient.cs @@ -51,7 +51,7 @@ WithRawResponseTask GetAsync( /// /// Delete a single User Attribute Profile specified by ID. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/UserAttributeProfiles/UserAttributeProfilesClient.cs b/src/Auth0.ManagementApi/UserAttributeProfiles/UserAttributeProfilesClient.cs index f6ffc294e..98af75188 100644 --- a/src/Auth0.ManagementApi/UserAttributeProfiles/UserAttributeProfilesClient.cs +++ b/src/Auth0.ManagementApi/UserAttributeProfiles/UserAttributeProfilesClient.cs @@ -72,7 +72,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -86,7 +86,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -99,13 +105,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -115,7 +161,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -126,6 +178,9 @@ private async Task> C CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -139,6 +194,7 @@ private async Task> C Method = HttpMethod.Post, Path = "user-attribute-profiles", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -159,7 +215,7 @@ private async Task> C return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -173,7 +229,13 @@ private async Task> C "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -186,15 +248,65 @@ private async Task> C switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -204,7 +316,13 @@ private async Task> C throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -216,6 +334,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -228,6 +349,7 @@ private async Task< { Method = HttpMethod.Get, Path = "user-attribute-profiles/templates", + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -248,7 +370,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -262,7 +384,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -275,11 +403,41 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -289,7 +447,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -302,6 +466,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -317,6 +484,7 @@ private async Task< "user-attribute-profiles/templates/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -337,7 +505,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -351,7 +519,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -364,13 +538,53 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -380,7 +594,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -391,6 +611,9 @@ private async Task> GetA CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -406,6 +629,7 @@ private async Task> GetA "user-attribute-profiles/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -425,7 +649,7 @@ private async Task> GetA return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -439,7 +663,13 @@ private async Task> GetA "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -452,13 +682,157 @@ private async Task> GetA switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "user-attribute-profiles/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -468,7 +842,13 @@ private async Task> GetA throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -480,6 +860,9 @@ private async Task> U CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -496,6 +879,7 @@ private async Task> U ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -516,7 +900,7 @@ private async Task> U return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -530,7 +914,13 @@ private async Task> U "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -543,15 +933,65 @@ private async Task> U switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -561,7 +1001,13 @@ private async Task> U throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -702,63 +1148,13 @@ public WithRawResponseTask GetAsync( /// /// await client.UserAttributeProfiles.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "user-attribute-profiles/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/src/Auth0.ManagementApi/UserBlocks/IUserBlocksClient.cs b/src/Auth0.ManagementApi/UserBlocks/IUserBlocksClient.cs index 2bcb64f62..69a0b5095 100644 --- a/src/Auth0.ManagementApi/UserBlocks/IUserBlocksClient.cs +++ b/src/Auth0.ManagementApi/UserBlocks/IUserBlocksClient.cs @@ -16,7 +16,7 @@ WithRawResponseTask ListByIdentifierA /// /// Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user). /// - Task DeleteByIdentifierAsync( + WithRawResponseTask DeleteByIdentifierAsync( DeleteUserBlocksByIdentifierRequestParameters request, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -37,7 +37,7 @@ WithRawResponseTask ListAsync( /// /// Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user). /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/UserBlocks/UserBlocksClient.cs b/src/Auth0.ManagementApi/UserBlocks/UserBlocksClient.cs index 9c4d5f396..09409aca8 100644 --- a/src/Auth0.ManagementApi/UserBlocks/UserBlocksClient.cs +++ b/src/Auth0.ManagementApi/UserBlocks/UserBlocksClient.cs @@ -62,7 +62,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -76,7 +76,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -89,13 +95,167 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteByIdentifierAsyncCore( + DeleteUserBlocksByIdentifierRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 1) + .Add("identifier", request.Identifier) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = "user-blocks", + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -105,7 +265,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -158,7 +324,7 @@ private async Task> ListAsyncCore return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -172,7 +338,13 @@ private async Task> ListAsyncCore "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -185,15 +357,65 @@ private async Task> ListAsyncCore switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -203,52 +425,24 @@ private async Task> ListAsyncCore throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Retrieve details of all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for a user with the given identifier (username, phone number, or email). - /// - /// - /// await client.UserBlocks.ListByIdentifierAsync( - /// new ListUserBlocksByIdentifierRequestParameters - /// { - /// Identifier = "identifier", - /// ConsiderBruteForceEnablement = true, - /// } - /// ); - /// - public WithRawResponseTask ListByIdentifierAsync( - ListUserBlocksByIdentifierRequestParameters request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask( - ListByIdentifierAsyncCore(request, options, cancellationToken) - ); - } - - /// - /// Remove all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given identifier (username, phone number, or email). - /// - /// Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user). - /// - /// - /// await client.UserBlocks.DeleteByIdentifierAsync( - /// new DeleteUserBlocksByIdentifierRequestParameters { Identifier = "identifier" } - /// ); - /// - public async Task DeleteByIdentifierAsync( - DeleteUserBlocksByIdentifierRequestParameters request, + private async Task DeleteAsyncCore( + string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 1) - .Add("identifier", request.Identifier) + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) .MergeAdditional(options?.AdditionalQueryParameters) .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() @@ -262,7 +456,7 @@ public async Task DeleteByIdentifierAsync( new JsonRequest { Method = HttpMethod.Delete, - Path = "user-blocks", + Path = string.Format("user-blocks/{0}", ValueConvert.ToPathParameterString(id)), QueryString = _queryString, Headers = _headers, Options = options, @@ -272,7 +466,12 @@ public async Task DeleteByIdentifierAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -283,13 +482,65 @@ public async Task DeleteByIdentifierAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -299,11 +550,61 @@ public async Task DeleteByIdentifierAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + /// + /// Retrieve details of all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for a user with the given identifier (username, phone number, or email). + /// + /// + /// await client.UserBlocks.ListByIdentifierAsync( + /// new ListUserBlocksByIdentifierRequestParameters + /// { + /// Identifier = "identifier", + /// ConsiderBruteForceEnablement = true, + /// } + /// ); + /// + public WithRawResponseTask ListByIdentifierAsync( + ListUserBlocksByIdentifierRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + ListByIdentifierAsyncCore(request, options, cancellationToken) + ); + } + + /// + /// Remove all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given identifier (username, phone number, or email). + /// + /// Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user). + /// + /// + /// await client.UserBlocks.DeleteByIdentifierAsync( + /// new DeleteUserBlocksByIdentifierRequestParameters { Identifier = "identifier" } + /// ); + /// + public WithRawResponseTask DeleteByIdentifierAsync( + DeleteUserBlocksByIdentifierRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + DeleteByIdentifierAsyncCore(request, options, cancellationToken) + ); + } + /// /// Retrieve details of all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given ID. /// @@ -333,63 +634,12 @@ public WithRawResponseTask ListAsync( /// /// await client.UserBlocks.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format("user-blocks/{0}", ValueConvert.ToPathParameterString(id)), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/UserGrants/IUserGrantsClient.cs b/src/Auth0.ManagementApi/UserGrants/IUserGrantsClient.cs index 0bd1ebe7d..92b6f3a4f 100644 --- a/src/Auth0.ManagementApi/UserGrants/IUserGrantsClient.cs +++ b/src/Auth0.ManagementApi/UserGrants/IUserGrantsClient.cs @@ -16,7 +16,7 @@ Task> ListAsync( /// /// Delete a grant associated with your account. /// - Task DeleteByUserIdAsync( + WithRawResponseTask DeleteByUserIdAsync( DeleteUserGrantByUserIdRequestParameters request, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -25,7 +25,7 @@ Task DeleteByUserIdAsync( /// /// Delete a grant associated with your account. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/UserGrants/UserGrantsClient.cs b/src/Auth0.ManagementApi/UserGrants/UserGrantsClient.cs index ece6d9788..13b3b16eb 100644 --- a/src/Auth0.ManagementApi/UserGrants/UserGrantsClient.cs +++ b/src/Auth0.ManagementApi/UserGrants/UserGrantsClient.cs @@ -79,7 +79,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -93,7 +93,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -106,11 +112,41 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -120,70 +156,18 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Retrieve the [grants](https://auth0.com/docs/api-auth/which-oauth-flow-to-use) associated with your account. - /// - /// - /// await client.UserGrants.ListAsync( - /// new ListUserGrantsRequestParameters - /// { - /// PerPage = 1, - /// Page = 1, - /// IncludeTotals = true, - /// UserId = "user_id", - /// ClientId = "client_id", - /// Audience = "audience", - /// } - /// ); - /// - public async Task> ListAsync( - ListUserGrantsRequestParameters request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - request = request with { }; - var pager = await OffsetPager< - ListUserGrantsRequestParameters, - RequestOptions?, - ListUserGrantsOffsetPaginatedResponseContent, - int?, - int?, - UserGrant - > - .CreateInstanceAsync( - request, - options, - async (request, options, cancellationToken) => - await ListInternalAsync(request, options, cancellationToken).WithRawResponse(), - request => request.Page.GetValueOrDefault(0), - (request, offset) => - { - request.Page = offset; - }, - null, - response => response.Grants?.ToList(), - null, - cancellationToken - ) - .ConfigureAwait(false); - return pager; - } - - /// - /// Delete a grant associated with your account. - /// - /// - /// await client.UserGrants.DeleteByUserIdAsync( - /// new DeleteUserGrantByUserIdRequestParameters { UserId = "user_id" } - /// ); - /// - public async Task DeleteByUserIdAsync( + private async Task DeleteByUserIdAsyncCore( DeleteUserGrantByUserIdRequestParameters request, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -214,7 +198,12 @@ public async Task DeleteByUserIdAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -225,11 +214,41 @@ public async Task DeleteByUserIdAsync( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -239,23 +258,26 @@ public async Task DeleteByUserIdAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Delete a grant associated with your account. - /// - /// - /// await client.UserGrants.DeleteAsync("id"); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -268,6 +290,7 @@ public async Task DeleteAsync( { Method = HttpMethod.Delete, Path = string.Format("grants/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -276,7 +299,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -287,11 +315,41 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -301,8 +359,98 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Retrieve the [grants](https://auth0.com/docs/api-auth/which-oauth-flow-to-use) associated with your account. + /// + /// + /// await client.UserGrants.ListAsync( + /// new ListUserGrantsRequestParameters + /// { + /// PerPage = 1, + /// Page = 1, + /// IncludeTotals = true, + /// UserId = "user_id", + /// ClientId = "client_id", + /// Audience = "audience", + /// } + /// ); + /// + public async Task> ListAsync( + ListUserGrantsRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + request = request with { }; + var pager = await OffsetPager< + ListUserGrantsRequestParameters, + RequestOptions?, + ListUserGrantsOffsetPaginatedResponseContent, + int?, + int?, + UserGrant + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await ListInternalAsync(request, options, cancellationToken).WithRawResponse(), + request => request.Page.GetValueOrDefault(0), + (request, offset) => + { + request.Page = offset; + }, + null, + response => response.Grants?.ToList(), + null, + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } + + /// + /// Delete a grant associated with your account. + /// + /// + /// await client.UserGrants.DeleteByUserIdAsync( + /// new DeleteUserGrantByUserIdRequestParameters { UserId = "user_id" } + /// ); + /// + public WithRawResponseTask DeleteByUserIdAsync( + DeleteUserGrantByUserIdRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + DeleteByUserIdAsyncCore(request, options, cancellationToken) + ); + } + + /// + /// Delete a grant associated with your account. + /// + /// + /// await client.UserGrants.DeleteAsync("id"); + /// + public WithRawResponseTask DeleteAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Users/AuthenticationMethods/AuthenticationMethodsClient.cs b/src/Auth0.ManagementApi/Users/AuthenticationMethods/AuthenticationMethodsClient.cs index f9b959d6a..68c8037e2 100644 --- a/src/Auth0.ManagementApi/Users/AuthenticationMethods/AuthenticationMethodsClient.cs +++ b/src/Auth0.ManagementApi/Users/AuthenticationMethods/AuthenticationMethodsClient.cs @@ -82,7 +82,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -96,7 +96,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,15 +115,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -127,7 +183,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -141,6 +203,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -157,6 +222,7 @@ private async Task< ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -178,7 +244,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -192,7 +258,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -205,17 +277,77 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -225,7 +357,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -239,6 +377,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -255,6 +396,7 @@ private async Task< ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -276,7 +418,7 @@ private async Task< >() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -290,7 +432,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -303,15 +451,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -321,7 +519,129 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAllAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "users/{0}/authentication-methods", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -333,6 +653,9 @@ private async Task> CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -349,6 +672,7 @@ private async Task> ValueConvert.ToPathParameterString(id), ValueConvert.ToPathParameterString(authenticationMethodId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -369,7 +693,7 @@ private async Task> return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -383,7 +707,13 @@ private async Task> "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -396,15 +726,195 @@ private async Task> switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + string authenticationMethodId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "users/{0}/authentication-methods/{1}", + ValueConvert.ToPathParameterString(id), + ValueConvert.ToPathParameterString(authenticationMethodId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -414,7 +924,13 @@ private async Task> throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -429,6 +945,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -446,6 +965,7 @@ private async Task< ValueConvert.ToPathParameterString(authenticationMethodId) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -467,7 +987,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -481,7 +1001,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -494,15 +1020,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -512,7 +1088,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -623,65 +1205,13 @@ public WithRawResponseTask /// await client.Users.AuthenticationMethods.DeleteAllAsync("id"); /// - public async Task DeleteAllAsync( + public WithRawResponseTask DeleteAllAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "users/{0}/authentication-methods", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAllAsyncCore(id, options, cancellationToken)); } /// @@ -705,69 +1235,16 @@ public WithRawResponseTask GetAsync( /// /// await client.Users.AuthenticationMethods.DeleteAsync("id", "authentication_method_id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, string authenticationMethodId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "users/{0}/authentication-methods/{1}", - ValueConvert.ToPathParameterString(id), - ValueConvert.ToPathParameterString(authenticationMethodId) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask( + DeleteAsyncCore(id, authenticationMethodId, options, cancellationToken) + ); } /// diff --git a/src/Auth0.ManagementApi/Users/AuthenticationMethods/IAuthenticationMethodsClient.cs b/src/Auth0.ManagementApi/Users/AuthenticationMethods/IAuthenticationMethodsClient.cs index ac7c5e991..b800aae35 100644 --- a/src/Auth0.ManagementApi/Users/AuthenticationMethods/IAuthenticationMethodsClient.cs +++ b/src/Auth0.ManagementApi/Users/AuthenticationMethods/IAuthenticationMethodsClient.cs @@ -40,7 +40,7 @@ WithRawResponseTask> Set /// /// Remove all authentication methods (i.e., enrolled MFA factors) from the specified user account. This action cannot be undone. /// - Task DeleteAllAsync( + WithRawResponseTask DeleteAllAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -56,7 +56,7 @@ WithRawResponseTask GetAsync( /// /// Remove the authentication method with the given ID from the specified user. For more information, review Manage Authentication Methods with Management API. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, string authenticationMethodId, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Users/Authenticators/AuthenticatorsClient.cs b/src/Auth0.ManagementApi/Users/Authenticators/AuthenticatorsClient.cs index adf986621..f966ee6b0 100644 --- a/src/Auth0.ManagementApi/Users/Authenticators/AuthenticatorsClient.cs +++ b/src/Auth0.ManagementApi/Users/Authenticators/AuthenticatorsClient.cs @@ -13,18 +13,15 @@ internal AuthenticatorsClient(RawClient client) _client = client; } - /// - /// 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). - /// - /// - /// await client.Users.Authenticators.DeleteAllAsync("id"); - /// - public async Task DeleteAllAsync( + private async Task DeleteAllAsyncCore( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -40,6 +37,7 @@ public async Task DeleteAllAsync( "users/{0}/authenticators", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -48,7 +46,12 @@ public async Task DeleteAllAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -59,13 +62,53 @@ public async Task DeleteAllAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -75,8 +118,29 @@ public async Task DeleteAllAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// 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). + /// + /// + /// await client.Users.Authenticators.DeleteAllAsync("id"); + /// + public WithRawResponseTask DeleteAllAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAllAsyncCore(id, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Users/Authenticators/IAuthenticatorsClient.cs b/src/Auth0.ManagementApi/Users/Authenticators/IAuthenticatorsClient.cs index 75cb729ee..3771cd90d 100644 --- a/src/Auth0.ManagementApi/Users/Authenticators/IAuthenticatorsClient.cs +++ b/src/Auth0.ManagementApi/Users/Authenticators/IAuthenticatorsClient.cs @@ -7,7 +7,7 @@ public partial interface IAuthenticatorsClient /// /// 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). /// - Task DeleteAllAsync( + WithRawResponseTask DeleteAllAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Users/ConnectedAccounts/ConnectedAccountsClient.cs b/src/Auth0.ManagementApi/Users/ConnectedAccounts/ConnectedAccountsClient.cs index a670a141f..3ba6562b7 100644 --- a/src/Auth0.ManagementApi/Users/ConnectedAccounts/ConnectedAccountsClient.cs +++ b/src/Auth0.ManagementApi/Users/ConnectedAccounts/ConnectedAccountsClient.cs @@ -77,7 +77,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -91,7 +91,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -104,15 +110,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -122,7 +178,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Users/EffectivePermissions/EffectivePermissionsClient.cs b/src/Auth0.ManagementApi/Users/EffectivePermissions/EffectivePermissionsClient.cs index 522c611ff..b584c3413 100644 --- a/src/Auth0.ManagementApi/Users/EffectivePermissions/EffectivePermissionsClient.cs +++ b/src/Auth0.ManagementApi/Users/EffectivePermissions/EffectivePermissionsClient.cs @@ -82,7 +82,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -96,7 +96,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,15 +115,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -127,7 +183,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Users/EffectivePermissions/Sources/Roles/RolesClient.cs b/src/Auth0.ManagementApi/Users/EffectivePermissions/Sources/Roles/RolesClient.cs index 15d7e9ab1..7d15ea557 100644 --- a/src/Auth0.ManagementApi/Users/EffectivePermissions/Sources/Roles/RolesClient.cs +++ b/src/Auth0.ManagementApi/Users/EffectivePermissions/Sources/Roles/RolesClient.cs @@ -80,7 +80,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -94,7 +94,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -107,15 +113,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -125,7 +181,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Users/EffectiveRoles/EffectiveRolesClient.cs b/src/Auth0.ManagementApi/Users/EffectiveRoles/EffectiveRolesClient.cs index e46c60ced..3f1ba8336 100644 --- a/src/Auth0.ManagementApi/Users/EffectiveRoles/EffectiveRolesClient.cs +++ b/src/Auth0.ManagementApi/Users/EffectiveRoles/EffectiveRolesClient.cs @@ -80,7 +80,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -94,7 +94,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -107,15 +113,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -125,7 +181,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Users/EffectiveRoles/Sources/Groups/GroupsClient.cs b/src/Auth0.ManagementApi/Users/EffectiveRoles/Sources/Groups/GroupsClient.cs index f629d3e40..0caffba37 100644 --- a/src/Auth0.ManagementApi/Users/EffectiveRoles/Sources/Groups/GroupsClient.cs +++ b/src/Auth0.ManagementApi/Users/EffectiveRoles/Sources/Groups/GroupsClient.cs @@ -78,7 +78,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -92,7 +92,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -105,15 +111,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -123,7 +179,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Users/Enrollments/EnrollmentsClient.cs b/src/Auth0.ManagementApi/Users/Enrollments/EnrollmentsClient.cs index 60e637c25..e2cf74a6d 100644 --- a/src/Auth0.ManagementApi/Users/Enrollments/EnrollmentsClient.cs +++ b/src/Auth0.ManagementApi/Users/Enrollments/EnrollmentsClient.cs @@ -19,6 +19,9 @@ private async Task>> GetAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -34,6 +37,7 @@ private async Task>> GetAsyncCore( "users/{0}/enrollments", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -53,7 +57,7 @@ private async Task>> GetAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -67,7 +71,13 @@ private async Task>> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -80,15 +90,65 @@ private async Task>> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -98,7 +158,13 @@ private async Task>> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Users/FederatedConnectionsTokensets/FederatedConnectionsTokensetsClient.cs b/src/Auth0.ManagementApi/Users/FederatedConnectionsTokensets/FederatedConnectionsTokensetsClient.cs index 41dd789a8..7a40872f2 100644 --- a/src/Auth0.ManagementApi/Users/FederatedConnectionsTokensets/FederatedConnectionsTokensetsClient.cs +++ b/src/Auth0.ManagementApi/Users/FederatedConnectionsTokensets/FederatedConnectionsTokensetsClient.cs @@ -19,6 +19,9 @@ private async Task>> Li CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -34,6 +37,7 @@ private async Task>> Li "users/{0}/federated-connections-tokensets", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -53,7 +57,7 @@ private async Task>> Li return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -67,7 +71,13 @@ private async Task>> Li "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -80,13 +90,53 @@ private async Task>> Li switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -96,38 +146,27 @@ private async Task>> Li throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// List active federated connections tokensets for a provided user - /// - /// - /// await client.Users.FederatedConnectionsTokensets.ListAsync("id"); - /// - public WithRawResponseTask> ListAsync( - string id, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - return new WithRawResponseTask>( - ListAsyncCore(id, options, cancellationToken) - ); - } - - /// - /// await client.Users.FederatedConnectionsTokensets.DeleteAsync("id", "tokenset_id"); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, string tokensetId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -144,6 +183,7 @@ public async Task DeleteAsync( ValueConvert.ToPathParameterString(id), ValueConvert.ToPathParameterString(tokensetId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -152,7 +192,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -163,13 +208,53 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -179,8 +264,44 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// List active federated connections tokensets for a provided user + /// + /// + /// await client.Users.FederatedConnectionsTokensets.ListAsync("id"); + /// + public WithRawResponseTask> ListAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask>( + ListAsyncCore(id, options, cancellationToken) + ); + } + + /// + /// await client.Users.FederatedConnectionsTokensets.DeleteAsync("id", "tokenset_id"); + /// + public WithRawResponseTask DeleteAsync( + string id, + string tokensetId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, tokensetId, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Users/FederatedConnectionsTokensets/IFederatedConnectionsTokensetsClient.cs b/src/Auth0.ManagementApi/Users/FederatedConnectionsTokensets/IFederatedConnectionsTokensetsClient.cs index 6b58d49ea..b48f53329 100644 --- a/src/Auth0.ManagementApi/Users/FederatedConnectionsTokensets/IFederatedConnectionsTokensetsClient.cs +++ b/src/Auth0.ManagementApi/Users/FederatedConnectionsTokensets/IFederatedConnectionsTokensetsClient.cs @@ -13,7 +13,7 @@ WithRawResponseTask> ListAsync( CancellationToken cancellationToken = default ); - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, string tokensetId, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Users/Groups/GroupsClient.cs b/src/Auth0.ManagementApi/Users/Groups/GroupsClient.cs index 0b0227e7a..cf62fd951 100644 --- a/src/Auth0.ManagementApi/Users/Groups/GroupsClient.cs +++ b/src/Auth0.ManagementApi/Users/Groups/GroupsClient.cs @@ -80,7 +80,7 @@ private async Task> GetIn return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -94,7 +94,13 @@ private async Task> GetIn "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -107,15 +113,65 @@ private async Task> GetIn switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -125,7 +181,13 @@ private async Task> GetIn throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Users/IUsersClient.cs b/src/Auth0.ManagementApi/Users/IUsersClient.cs index 799f9d4d4..c8ef67a0a 100644 --- a/src/Auth0.ManagementApi/Users/IUsersClient.cs +++ b/src/Auth0.ManagementApi/Users/IUsersClient.cs @@ -86,7 +86,7 @@ WithRawResponseTask GetAsync( /// /// Delete a user by user ID. This action cannot be undone. For Auth0 Dashboard instructions, see [Delete Users](https://auth0.com/docs/manage-users/user-accounts/delete-users). /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -204,7 +204,7 @@ WithRawResponseTask RegenerateRecove /// /// Revokes selected resources related to a user (sessions, refresh tokens, ...). /// - Task RevokeAccessAsync( + WithRawResponseTask RevokeAccessAsync( string id, RevokeUserAccessRequestContent request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Users/Identities/IdentitiesClient.cs b/src/Auth0.ManagementApi/Users/Identities/IdentitiesClient.cs index ca0455ed7..b4f3ec448 100644 --- a/src/Auth0.ManagementApi/Users/Identities/IdentitiesClient.cs +++ b/src/Auth0.ManagementApi/Users/Identities/IdentitiesClient.cs @@ -20,6 +20,9 @@ private async Task>> LinkAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -36,6 +39,7 @@ private async Task>> LinkAsyncCore( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -54,7 +58,7 @@ private async Task>> LinkAsyncCore( return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -68,7 +72,13 @@ private async Task>> LinkAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -81,15 +91,65 @@ private async Task>> LinkAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -99,7 +159,13 @@ private async Task>> LinkAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -114,6 +180,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -131,6 +200,7 @@ private async Task< ValueConvert.ToPathParameterString(provider), ValueConvert.ToPathParameterString(userId) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -150,7 +220,7 @@ private async Task< return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -164,7 +234,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -177,13 +253,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -193,7 +309,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Users/Logs/LogsClient.cs b/src/Auth0.ManagementApi/Users/Logs/LogsClient.cs index 40450fafa..344a066af 100644 --- a/src/Auth0.ManagementApi/Users/Logs/LogsClient.cs +++ b/src/Auth0.ManagementApi/Users/Logs/LogsClient.cs @@ -85,7 +85,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -99,7 +99,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -112,13 +118,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -128,7 +174,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Users/Multifactor/IMultifactorClient.cs b/src/Auth0.ManagementApi/Users/Multifactor/IMultifactorClient.cs index 15c652e56..ecbc9375f 100644 --- a/src/Auth0.ManagementApi/Users/Multifactor/IMultifactorClient.cs +++ b/src/Auth0.ManagementApi/Users/Multifactor/IMultifactorClient.cs @@ -7,7 +7,7 @@ public partial interface IMultifactorClient /// /// Invalidate all remembered browsers across all [authentication factors](https://auth0.com/docs/multifactor-authentication) for a user. /// - Task InvalidateRememberBrowserAsync( + WithRawResponseTask InvalidateRememberBrowserAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default @@ -16,7 +16,7 @@ Task InvalidateRememberBrowserAsync( /// /// Remove a [multifactor](https://auth0.com/docs/multifactor-authentication) authentication configuration from a user's account. This forces the user to manually reconfigure the multi-factor provider. /// - Task DeleteProviderAsync( + WithRawResponseTask DeleteProviderAsync( string id, UserMultifactorProviderEnum provider, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Users/Multifactor/MultifactorClient.cs b/src/Auth0.ManagementApi/Users/Multifactor/MultifactorClient.cs index 47ab8a78f..40bc908ca 100644 --- a/src/Auth0.ManagementApi/Users/Multifactor/MultifactorClient.cs +++ b/src/Auth0.ManagementApi/Users/Multifactor/MultifactorClient.cs @@ -13,18 +13,15 @@ internal MultifactorClient(RawClient client) _client = client; } - /// - /// Invalidate all remembered browsers across all [authentication factors](https://auth0.com/docs/multifactor-authentication) for a user. - /// - /// - /// await client.Users.Multifactor.InvalidateRememberBrowserAsync("id"); - /// - public async Task InvalidateRememberBrowserAsync( + private async Task InvalidateRememberBrowserAsyncCore( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -40,6 +37,7 @@ public async Task InvalidateRememberBrowserAsync( "users/{0}/multifactor/actions/invalidate-remember-browser", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -48,7 +46,12 @@ public async Task InvalidateRememberBrowserAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -59,11 +62,41 @@ public async Task InvalidateRememberBrowserAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -73,24 +106,27 @@ public async Task InvalidateRememberBrowserAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Remove a [multifactor](https://auth0.com/docs/multifactor-authentication) authentication configuration from a user's account. This forces the user to manually reconfigure the multi-factor provider. - /// - /// - /// await client.Users.Multifactor.DeleteProviderAsync("id", UserMultifactorProviderEnum.Duo); - /// - public async Task DeleteProviderAsync( + private async Task DeleteProviderAsyncCore( string id, UserMultifactorProviderEnum provider, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -107,6 +143,7 @@ public async Task DeleteProviderAsync( ValueConvert.ToPathParameterString(id), ValueConvert.ToPathParameterString(provider) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -115,7 +152,12 @@ public async Task DeleteProviderAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -126,15 +168,65 @@ public async Task DeleteProviderAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -144,8 +236,49 @@ public async Task DeleteProviderAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Invalidate all remembered browsers across all [authentication factors](https://auth0.com/docs/multifactor-authentication) for a user. + /// + /// + /// await client.Users.Multifactor.InvalidateRememberBrowserAsync("id"); + /// + public WithRawResponseTask InvalidateRememberBrowserAsync( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + InvalidateRememberBrowserAsyncCore(id, options, cancellationToken) + ); + } + + /// + /// Remove a [multifactor](https://auth0.com/docs/multifactor-authentication) authentication configuration from a user's account. This forces the user to manually reconfigure the multi-factor provider. + /// + /// + /// await client.Users.Multifactor.DeleteProviderAsync("id", UserMultifactorProviderEnum.Duo); + /// + public WithRawResponseTask DeleteProviderAsync( + string id, + UserMultifactorProviderEnum provider, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + DeleteProviderAsyncCore(id, provider, options, cancellationToken) + ); + } } diff --git a/src/Auth0.ManagementApi/Users/Organizations/OrganizationsClient.cs b/src/Auth0.ManagementApi/Users/Organizations/OrganizationsClient.cs index dce3ee9be..820d7aa41 100644 --- a/src/Auth0.ManagementApi/Users/Organizations/OrganizationsClient.cs +++ b/src/Auth0.ManagementApi/Users/Organizations/OrganizationsClient.cs @@ -82,7 +82,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -96,7 +96,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,13 +115,53 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -125,7 +171,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } diff --git a/src/Auth0.ManagementApi/Users/Permissions/IPermissionsClient.cs b/src/Auth0.ManagementApi/Users/Permissions/IPermissionsClient.cs index 43e2b98d1..440582bcb 100644 --- a/src/Auth0.ManagementApi/Users/Permissions/IPermissionsClient.cs +++ b/src/Auth0.ManagementApi/Users/Permissions/IPermissionsClient.cs @@ -18,7 +18,7 @@ Task> ListAsync( /// /// Assign permissions to a user. /// - Task CreateAsync( + WithRawResponseTask CreateAsync( string id, CreateUserPermissionsRequestContent request, RequestOptions? options = null, @@ -28,7 +28,7 @@ Task CreateAsync( /// /// Remove permissions from a user. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, DeleteUserPermissionsRequestContent request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Users/Permissions/PermissionsClient.cs b/src/Auth0.ManagementApi/Users/Permissions/PermissionsClient.cs index 32fbe6de5..27fd7e49a 100644 --- a/src/Auth0.ManagementApi/Users/Permissions/PermissionsClient.cs +++ b/src/Auth0.ManagementApi/Users/Permissions/PermissionsClient.cs @@ -82,7 +82,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -96,7 +96,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -109,15 +115,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -127,87 +183,27 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Retrieve all permissions associated with the user. - /// - /// - /// await client.Users.Permissions.ListAsync( - /// "id", - /// new ListUserPermissionsRequestParameters - /// { - /// PerPage = 1, - /// Page = 1, - /// IncludeTotals = true, - /// } - /// ); - /// - public async Task> ListAsync( - string id, - ListUserPermissionsRequestParameters request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - request = request with { }; - var pager = await OffsetPager< - ListUserPermissionsRequestParameters, - RequestOptions?, - ListUserPermissionsOffsetPaginatedResponseContent, - int?, - int?, - UserPermissionSchema - > - .CreateInstanceAsync( - request, - options, - async (request, options, cancellationToken) => - await ListInternalAsync(id, request, options, cancellationToken) - .WithRawResponse(), - request => request.Page.GetValueOrDefault(0), - (request, offset) => - { - request.Page = offset; - }, - null, - response => response.Permissions?.ToList(), - null, - cancellationToken - ) - .ConfigureAwait(false); - return pager; - } - - /// - /// Assign permissions to a user. - /// - /// - /// await client.Users.Permissions.CreateAsync( - /// "id", - /// new CreateUserPermissionsRequestContent - /// { - /// Permissions = new List<PermissionRequestPayload>() - /// { - /// new PermissionRequestPayload - /// { - /// ResourceServerIdentifier = "resource_server_identifier", - /// PermissionName = "permission_name", - /// }, - /// }, - /// } - /// ); - /// - public async Task CreateAsync( + private async Task CreateAsyncCore( string id, CreateUserPermissionsRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -224,6 +220,7 @@ public async Task CreateAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -233,7 +230,12 @@ public async Task CreateAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -244,15 +246,65 @@ public async Task CreateAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -262,37 +314,27 @@ public async Task CreateAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Remove permissions from a user. - /// - /// - /// await client.Users.Permissions.DeleteAsync( - /// "id", - /// new DeleteUserPermissionsRequestContent - /// { - /// Permissions = new List<PermissionRequestPayload>() - /// { - /// new PermissionRequestPayload - /// { - /// ResourceServerIdentifier = "resource_server_identifier", - /// PermissionName = "permission_name", - /// }, - /// }, - /// } - /// ); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, DeleteUserPermissionsRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -309,6 +351,7 @@ public async Task DeleteAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -318,7 +361,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -329,15 +377,65 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -347,8 +445,122 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Retrieve all permissions associated with the user. + /// + /// + /// await client.Users.Permissions.ListAsync( + /// "id", + /// new ListUserPermissionsRequestParameters + /// { + /// PerPage = 1, + /// Page = 1, + /// IncludeTotals = true, + /// } + /// ); + /// + public async Task> ListAsync( + string id, + ListUserPermissionsRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + request = request with { }; + var pager = await OffsetPager< + ListUserPermissionsRequestParameters, + RequestOptions?, + ListUserPermissionsOffsetPaginatedResponseContent, + int?, + int?, + UserPermissionSchema + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await ListInternalAsync(id, request, options, cancellationToken) + .WithRawResponse(), + request => request.Page.GetValueOrDefault(0), + (request, offset) => + { + request.Page = offset; + }, + null, + response => response.Permissions?.ToList(), + null, + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } + + /// + /// Assign permissions to a user. + /// + /// + /// await client.Users.Permissions.CreateAsync( + /// "id", + /// new CreateUserPermissionsRequestContent + /// { + /// Permissions = new List<PermissionRequestPayload>() + /// { + /// new PermissionRequestPayload + /// { + /// ResourceServerIdentifier = "resource_server_identifier", + /// PermissionName = "permission_name", + /// }, + /// }, + /// } + /// ); + /// + public WithRawResponseTask CreateAsync( + string id, + CreateUserPermissionsRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(CreateAsyncCore(id, request, options, cancellationToken)); + } + + /// + /// Remove permissions from a user. + /// + /// + /// await client.Users.Permissions.DeleteAsync( + /// "id", + /// new DeleteUserPermissionsRequestContent + /// { + /// Permissions = new List<PermissionRequestPayload>() + /// { + /// new PermissionRequestPayload + /// { + /// ResourceServerIdentifier = "resource_server_identifier", + /// PermissionName = "permission_name", + /// }, + /// }, + /// } + /// ); + /// + public WithRawResponseTask DeleteAsync( + string id, + DeleteUserPermissionsRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, request, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Users/RefreshToken/IRefreshTokenClient.cs b/src/Auth0.ManagementApi/Users/RefreshToken/IRefreshTokenClient.cs index d79e492b0..b140e17cc 100644 --- a/src/Auth0.ManagementApi/Users/RefreshToken/IRefreshTokenClient.cs +++ b/src/Auth0.ManagementApi/Users/RefreshToken/IRefreshTokenClient.cs @@ -18,7 +18,7 @@ Task> ListAsync( /// /// Delete all refresh tokens for a user. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string userId, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Users/RefreshToken/RefreshTokenClient.cs b/src/Auth0.ManagementApi/Users/RefreshToken/RefreshTokenClient.cs index e909e2ffd..a17961d1f 100644 --- a/src/Auth0.ManagementApi/Users/RefreshToken/RefreshTokenClient.cs +++ b/src/Auth0.ManagementApi/Users/RefreshToken/RefreshTokenClient.cs @@ -77,7 +77,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -91,7 +91,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -104,13 +110,53 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -120,7 +166,141 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string userId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "users/{0}/refresh-tokens", + ValueConvert.ToPathParameterString(userId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -176,66 +356,12 @@ await ListInternalAsync(userId, request, options, cancellationToken) /// /// await client.Users.RefreshToken.DeleteAsync("user_id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string userId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "users/{0}/refresh-tokens", - ValueConvert.ToPathParameterString(userId) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(userId, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/Users/RiskAssessments/IRiskAssessmentsClient.cs b/src/Auth0.ManagementApi/Users/RiskAssessments/IRiskAssessmentsClient.cs index 4eb387528..9c7a07df2 100644 --- a/src/Auth0.ManagementApi/Users/RiskAssessments/IRiskAssessmentsClient.cs +++ b/src/Auth0.ManagementApi/Users/RiskAssessments/IRiskAssessmentsClient.cs @@ -7,7 +7,7 @@ public partial interface IRiskAssessmentsClient /// /// Clear risk assessment assessors for a specific user /// - Task ClearAsync( + WithRawResponseTask ClearAsync( string id, ClearAssessorsRequestContent request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Users/RiskAssessments/RiskAssessmentsClient.cs b/src/Auth0.ManagementApi/Users/RiskAssessments/RiskAssessmentsClient.cs index 5e1090d9d..c1a687379 100644 --- a/src/Auth0.ManagementApi/Users/RiskAssessments/RiskAssessmentsClient.cs +++ b/src/Auth0.ManagementApi/Users/RiskAssessments/RiskAssessmentsClient.cs @@ -13,26 +13,16 @@ internal RiskAssessmentsClient(RawClient client) _client = client; } - /// - /// Clear risk assessment assessors for a specific user - /// - /// - /// await client.Users.RiskAssessments.ClearAsync( - /// "id", - /// new ClearAssessorsRequestContent - /// { - /// Connection = "connection", - /// Assessors = new List<AssessorsTypeEnum>() { AssessorsTypeEnum.NewDevice }, - /// } - /// ); - /// - public async Task ClearAsync( + private async Task ClearAsyncCore( string id, ClearAssessorsRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -49,6 +39,7 @@ public async Task ClearAsync( ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -58,7 +49,12 @@ public async Task ClearAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -69,13 +65,53 @@ public async Task ClearAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -85,8 +121,37 @@ public async Task ClearAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Clear risk assessment assessors for a specific user + /// + /// + /// await client.Users.RiskAssessments.ClearAsync( + /// "id", + /// new ClearAssessorsRequestContent + /// { + /// Connection = "connection", + /// Assessors = new List<AssessorsTypeEnum>() { AssessorsTypeEnum.NewDevice }, + /// } + /// ); + /// + public WithRawResponseTask ClearAsync( + string id, + ClearAssessorsRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(ClearAsyncCore(id, request, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Users/Roles/IRolesClient.cs b/src/Auth0.ManagementApi/Users/Roles/IRolesClient.cs index f2a8fea50..ccdf4c445 100644 --- a/src/Auth0.ManagementApi/Users/Roles/IRolesClient.cs +++ b/src/Auth0.ManagementApi/Users/Roles/IRolesClient.cs @@ -22,7 +22,7 @@ Task> ListAsync( /// /// **Note**: New roles cannot be created through this action. Additionally, this action is used to assign roles to a user in the context of your whole tenant. To assign roles in the context of a specific Organization, use the following endpoint: [Assign user roles to an Organization member](https://auth0.com/docs/api/management/v2/organizations/post-organization-member-roles). /// - Task AssignAsync( + WithRawResponseTask AssignAsync( string id, AssignUserRolesRequestContent request, RequestOptions? options = null, @@ -34,7 +34,7 @@ Task AssignAsync( /// /// **Note**: This action removes a role from a user in the context of your whole tenant. If you want to unassign a role from a user in the context of a specific Organization, use the following endpoint: [Delete user roles from an Organization member](https://auth0.com/docs/api/management/v2/organizations/delete-organization-member-roles). /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, DeleteUserRolesRequestContent request, RequestOptions? options = null, diff --git a/src/Auth0.ManagementApi/Users/Roles/RolesClient.cs b/src/Auth0.ManagementApi/Users/Roles/RolesClient.cs index 4a20beb77..f89d86daf 100644 --- a/src/Auth0.ManagementApi/Users/Roles/RolesClient.cs +++ b/src/Auth0.ManagementApi/Users/Roles/RolesClient.cs @@ -81,7 +81,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -95,7 +95,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -108,15 +114,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -126,81 +182,27 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Retrieve detailed list of all user roles currently assigned to a user. - /// - /// **Note**: This action retrieves all roles assigned to a user in the context of your whole tenant. To retrieve Organization-specific roles, use the following endpoint: [Get user roles assigned to an Organization member](https://auth0.com/docs/api/management/v2/organizations/get-organization-member-roles). - /// - /// - /// await client.Users.Roles.ListAsync( - /// "id", - /// new ListUserRolesRequestParameters - /// { - /// PerPage = 1, - /// Page = 1, - /// IncludeTotals = true, - /// } - /// ); - /// - public async Task> ListAsync( - string id, - ListUserRolesRequestParameters request, - RequestOptions? options = null, - CancellationToken cancellationToken = default - ) - { - request = request with { }; - var pager = await OffsetPager< - ListUserRolesRequestParameters, - RequestOptions?, - ListUserRolesOffsetPaginatedResponseContent, - int?, - int?, - Role - > - .CreateInstanceAsync( - request, - options, - async (request, options, cancellationToken) => - await ListInternalAsync(id, request, options, cancellationToken) - .WithRawResponse(), - request => request.Page.GetValueOrDefault(0), - (request, offset) => - { - request.Page = offset; - }, - null, - response => response.Roles?.ToList(), - null, - cancellationToken - ) - .ConfigureAwait(false); - return pager; - } - - /// - /// Assign one or more existing user roles to a user. For more information, review [Role-Based Access Control](https://auth0.com/docs/manage-users/access-control/rbac). - /// - /// **Note**: New roles cannot be created through this action. Additionally, this action is used to assign roles to a user in the context of your whole tenant. To assign roles in the context of a specific Organization, use the following endpoint: [Assign user roles to an Organization member](https://auth0.com/docs/api/management/v2/organizations/post-organization-member-roles). - /// - /// - /// await client.Users.Roles.AssignAsync( - /// "id", - /// new AssignUserRolesRequestContent { Roles = new List<string>() { "roles" } } - /// ); - /// - public async Task AssignAsync( + private async Task AssignAsyncCore( string id, AssignUserRolesRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -214,6 +216,7 @@ public async Task AssignAsync( Method = HttpMethod.Post, Path = string.Format("users/{0}/roles", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -223,7 +226,12 @@ public async Task AssignAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -234,15 +242,65 @@ public async Task AssignAsync( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -252,29 +310,27 @@ public async Task AssignAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } - /// - /// Remove one or more specified user roles assigned to a user. - /// - /// **Note**: This action removes a role from a user in the context of your whole tenant. If you want to unassign a role from a user in the context of a specific Organization, use the following endpoint: [Delete user roles from an Organization member](https://auth0.com/docs/api/management/v2/organizations/delete-organization-member-roles). - /// - /// - /// await client.Users.Roles.DeleteAsync( - /// "id", - /// new DeleteUserRolesRequestContent { Roles = new List<string>() { "roles" } } - /// ); - /// - public async Task DeleteAsync( + private async Task DeleteAsyncCore( string id, DeleteUserRolesRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -288,6 +344,7 @@ public async Task DeleteAsync( Method = HttpMethod.Delete, Path = string.Format("users/{0}/roles", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -297,7 +354,12 @@ public async Task DeleteAsync( .ConfigureAwait(false); if (response.StatusCode is >= 200 and < 400) { - return; + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; } { var responseBody = await response @@ -308,13 +370,53 @@ public async Task DeleteAsync( switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -324,8 +426,108 @@ public async Task DeleteAsync( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } + + /// + /// Retrieve detailed list of all user roles currently assigned to a user. + /// + /// **Note**: This action retrieves all roles assigned to a user in the context of your whole tenant. To retrieve Organization-specific roles, use the following endpoint: [Get user roles assigned to an Organization member](https://auth0.com/docs/api/management/v2/organizations/get-organization-member-roles). + /// + /// + /// await client.Users.Roles.ListAsync( + /// "id", + /// new ListUserRolesRequestParameters + /// { + /// PerPage = 1, + /// Page = 1, + /// IncludeTotals = true, + /// } + /// ); + /// + public async Task> ListAsync( + string id, + ListUserRolesRequestParameters request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + request = request with { }; + var pager = await OffsetPager< + ListUserRolesRequestParameters, + RequestOptions?, + ListUserRolesOffsetPaginatedResponseContent, + int?, + int?, + Role + > + .CreateInstanceAsync( + request, + options, + async (request, options, cancellationToken) => + await ListInternalAsync(id, request, options, cancellationToken) + .WithRawResponse(), + request => request.Page.GetValueOrDefault(0), + (request, offset) => + { + request.Page = offset; + }, + null, + response => response.Roles?.ToList(), + null, + cancellationToken + ) + .ConfigureAwait(false); + return pager; + } + + /// + /// Assign one or more existing user roles to a user. For more information, review [Role-Based Access Control](https://auth0.com/docs/manage-users/access-control/rbac). + /// + /// **Note**: New roles cannot be created through this action. Additionally, this action is used to assign roles to a user in the context of your whole tenant. To assign roles in the context of a specific Organization, use the following endpoint: [Assign user roles to an Organization member](https://auth0.com/docs/api/management/v2/organizations/post-organization-member-roles). + /// + /// + /// await client.Users.Roles.AssignAsync( + /// "id", + /// new AssignUserRolesRequestContent { Roles = new List<string>() { "roles" } } + /// ); + /// + public WithRawResponseTask AssignAsync( + string id, + AssignUserRolesRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(AssignAsyncCore(id, request, options, cancellationToken)); + } + + /// + /// Remove one or more specified user roles assigned to a user. + /// + /// **Note**: This action removes a role from a user in the context of your whole tenant. If you want to unassign a role from a user in the context of a specific Organization, use the following endpoint: [Delete user roles from an Organization member](https://auth0.com/docs/api/management/v2/organizations/delete-organization-member-roles). + /// + /// + /// await client.Users.Roles.DeleteAsync( + /// "id", + /// new DeleteUserRolesRequestContent { Roles = new List<string>() { "roles" } } + /// ); + /// + public WithRawResponseTask DeleteAsync( + string id, + DeleteUserRolesRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask(DeleteAsyncCore(id, request, options, cancellationToken)); + } } diff --git a/src/Auth0.ManagementApi/Users/Sessions/ISessionsClient.cs b/src/Auth0.ManagementApi/Users/Sessions/ISessionsClient.cs index 72e0f4173..1ee060712 100644 --- a/src/Auth0.ManagementApi/Users/Sessions/ISessionsClient.cs +++ b/src/Auth0.ManagementApi/Users/Sessions/ISessionsClient.cs @@ -18,7 +18,7 @@ Task> ListAsync( /// /// Delete all sessions for a user. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string userId, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/Users/Sessions/SessionsClient.cs b/src/Auth0.ManagementApi/Users/Sessions/SessionsClient.cs index 5b83dad59..d342c7b16 100644 --- a/src/Auth0.ManagementApi/Users/Sessions/SessionsClient.cs +++ b/src/Auth0.ManagementApi/Users/Sessions/SessionsClient.cs @@ -77,7 +77,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -91,7 +91,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -104,13 +110,53 @@ private async Task< switch (response.StatusCode) { case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -120,7 +166,141 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string userId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "users/{0}/sessions", + ValueConvert.ToPathParameterString(userId) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 404: + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -176,66 +356,12 @@ await ListInternalAsync(userId, request, options, cancellationToken) /// /// await client.Users.Sessions.DeleteAsync("user_id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string userId, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "users/{0}/sessions", - ValueConvert.ToPathParameterString(userId) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(userId, options, cancellationToken)); } } diff --git a/src/Auth0.ManagementApi/Users/UsersClient.cs b/src/Auth0.ManagementApi/Users/UsersClient.cs index a4cd97554..c4ea10fdb 100644 --- a/src/Auth0.ManagementApi/Users/UsersClient.cs +++ b/src/Auth0.ManagementApi/Users/UsersClient.cs @@ -160,7 +160,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -174,7 +174,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -187,16 +193,64 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 503: throw new ServiceUnavailableError( - JsonUtils.Deserialize(responseBody) + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -207,7 +261,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -218,6 +278,9 @@ private async Task> CreateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -231,6 +294,7 @@ private async Task> CreateAsyncCore( Method = HttpMethod.Post, Path = "users", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -249,7 +313,7 @@ private async Task> CreateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -263,7 +327,13 @@ private async Task> CreateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -276,15 +346,65 @@ private async Task> CreateAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -294,7 +414,13 @@ private async Task> CreateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -346,7 +472,7 @@ private async Task>> ListUsersBy return new WithRawResponse>() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -360,7 +486,13 @@ private async Task>> ListUsersBy "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -373,13 +505,53 @@ private async Task>> ListUsersBy switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -389,7 +561,13 @@ private async Task>> ListUsersBy throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -439,7 +617,7 @@ private async Task> GetAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -453,7 +631,13 @@ private async Task> GetAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -466,15 +650,65 @@ private async Task> GetAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -484,7 +718,126 @@ private async Task> GetAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format("users/{0}", ValueConvert.ToPathParameterString(id)), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -496,6 +849,9 @@ private async Task> UpdateAsyncCore( CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -509,6 +865,7 @@ private async Task> UpdateAsyncCore( Method = HttpMethodExtensions.Patch, Path = string.Format("users/{0}", ValueConvert.ToPathParameterString(id)), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -527,7 +884,7 @@ private async Task> UpdateAsyncCore( return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -541,7 +898,13 @@ private async Task> UpdateAsyncCore( "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -554,15 +917,65 @@ private async Task> UpdateAsyncCore( switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -572,7 +985,13 @@ private async Task> UpdateAsyncCore( throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -585,6 +1004,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -600,6 +1022,7 @@ private async Task< "users/{0}/recovery-code-regeneration", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -620,7 +1043,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -634,7 +1057,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -647,13 +1076,172 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task RevokeAccessAsyncCore( + string id, + RevokeUserAccessRequestContent request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Post, + Path = string.Format( + "users/{0}/revoke-access", + ValueConvert.ToPathParameterString(id) + ), + Body = request, + QueryString = _queryString, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -663,7 +1251,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -813,62 +1407,13 @@ public WithRawResponseTask GetAsync( /// /// await client.Users.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format("users/{0}", ValueConvert.ToPathParameterString(id)), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// @@ -1002,67 +1547,15 @@ public WithRawResponseTask Regenerat /// /// await client.Users.RevokeAccessAsync("id", new RevokeUserAccessRequestContent()); /// - public async Task RevokeAccessAsync( + public WithRawResponseTask RevokeAccessAsync( string id, RevokeUserAccessRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Post, - Path = string.Format( - "users/{0}/revoke-access", - ValueConvert.ToPathParameterString(id) - ), - Body = request, - Headers = _headers, - ContentType = "application/json", - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask( + RevokeAccessAsyncCore(id, request, options, cancellationToken) + ); } } diff --git a/src/Auth0.ManagementApi/VerifiableCredentials/Verification/Templates/ITemplatesClient.cs b/src/Auth0.ManagementApi/VerifiableCredentials/Verification/Templates/ITemplatesClient.cs index 83cf4362b..1bed47840 100644 --- a/src/Auth0.ManagementApi/VerifiableCredentials/Verification/Templates/ITemplatesClient.cs +++ b/src/Auth0.ManagementApi/VerifiableCredentials/Verification/Templates/ITemplatesClient.cs @@ -35,7 +35,7 @@ WithRawResponseTask GetAsync( /// /// Delete a verifiable credential template. /// - Task DeleteAsync( + WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default diff --git a/src/Auth0.ManagementApi/VerifiableCredentials/Verification/Templates/TemplatesClient.cs b/src/Auth0.ManagementApi/VerifiableCredentials/Verification/Templates/TemplatesClient.cs index fa33c0c6e..917b653df 100644 --- a/src/Auth0.ManagementApi/VerifiableCredentials/Verification/Templates/TemplatesClient.cs +++ b/src/Auth0.ManagementApi/VerifiableCredentials/Verification/Templates/TemplatesClient.cs @@ -73,7 +73,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -87,7 +87,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -100,13 +106,53 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -116,7 +162,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -129,6 +181,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -142,6 +197,7 @@ private async Task< Method = HttpMethod.Post, Path = "verifiable-credentials/verification/templates", Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -163,7 +219,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -177,7 +233,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -190,15 +252,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -208,7 +320,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -221,6 +339,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -236,6 +357,7 @@ private async Task< "verifiable-credentials/verification/templates/{0}", ValueConvert.ToPathParameterString(id) ), + QueryString = _queryString, Headers = _headers, Options = options, }, @@ -256,7 +378,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -270,7 +392,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -283,15 +411,181 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 404: - throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + throw new NotFoundError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 429: + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new ManagementApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + + private async Task DeleteAsyncCore( + string id, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "verifiable-credentials/verification/templates/{0}", + ValueConvert.ToPathParameterString(id) + ), + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + return new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }; + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 401: + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -301,7 +595,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -315,6 +615,9 @@ private async Task< CancellationToken cancellationToken = default ) { + var _queryString = new Auth0.ManagementApi.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() .Add(_client.Options.Headers) .Add(_client.Options.AdditionalHeaders) @@ -331,6 +634,7 @@ private async Task< ValueConvert.ToPathParameterString(id) ), Body = request, + QueryString = _queryString, Headers = _headers, ContentType = "application/json", Options = options, @@ -352,7 +656,7 @@ private async Task< return new WithRawResponse() { Data = responseData, - RawResponse = new RawResponse() + RawResponse = new Auth0.ManagementApi.RawResponse() { StatusCode = response.Raw.StatusCode, Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), @@ -366,7 +670,13 @@ private async Task< "Failed to deserialize response", response.StatusCode, null, - e + e, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -379,15 +689,65 @@ private async Task< switch (response.StatusCode) { case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + throw new UnauthorizedError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 409: - throw new ConflictError(JsonUtils.Deserialize(responseBody)); + throw new ConflictError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); + throw new TooManyRequestsError( + JsonUtils.Deserialize(responseBody), + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); } } catch (JsonException) @@ -397,7 +757,13 @@ private async Task< throw new ManagementApiException( $"Error with status code {response.StatusCode}", response.StatusCode, - responseBody + responseBody, + rawResponse: new Auth0.ManagementApi.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } ); } } @@ -499,65 +865,13 @@ public WithRawResponseTask GetAs /// /// await client.VerifiableCredentials.Verification.Templates.DeleteAsync("id"); /// - public async Task DeleteAsync( + public WithRawResponseTask DeleteAsync( string id, RequestOptions? options = null, CancellationToken cancellationToken = default ) { - var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder() - .Add(_client.Options.Headers) - .Add(_client.Options.AdditionalHeaders) - .Add(options?.AdditionalHeaders) - .BuildAsync() - .ConfigureAwait(false); - var response = await _client - .SendRequestAsync( - new JsonRequest - { - Method = HttpMethod.Delete, - Path = string.Format( - "verifiable-credentials/verification/templates/{0}", - ValueConvert.ToPathParameterString(id) - ), - Headers = _headers, - Options = options, - }, - cancellationToken - ) - .ConfigureAwait(false); - if (response.StatusCode is >= 200 and < 400) - { - return; - } - { - var responseBody = await response - .Raw.Content.ReadAsStringAsync(cancellationToken) - .ConfigureAwait(false); - try - { - switch (response.StatusCode) - { - case 400: - throw new BadRequestError(JsonUtils.Deserialize(responseBody)); - case 401: - throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); - case 403: - throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); - case 429: - throw new TooManyRequestsError(JsonUtils.Deserialize(responseBody)); - } - } - catch (JsonException) - { - // unable to map error response, throwing generic error - } - throw new ManagementApiException( - $"Error with status code {response.StatusCode}", - response.StatusCode, - responseBody - ); - } + return new WithRawResponseTask(DeleteAsyncCore(id, options, cancellationToken)); } /// diff --git a/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj b/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj index 3d3cef419..ab18c1f30 100644 --- a/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj +++ b/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj @@ -25,7 +25,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/Auth0.ManagementApi.Test/Core/RawClientTests/RetriesTests.cs b/tests/Auth0.ManagementApi.Test/Core/RawClientTests/RetriesTests.cs index e61d3727f..053144711 100644 --- a/tests/Auth0.ManagementApi.Test/Core/RawClientTests/RetriesTests.cs +++ b/tests/Auth0.ManagementApi.Test/Core/RawClientTests/RetriesTests.cs @@ -59,7 +59,7 @@ public async SystemTask SendRequestAsync_ShouldRetry_OnRetryableStatusCodes(int .WhenStateIs("Success") .RespondWith(WireMockResponse.Create().WithStatusCode(200).WithBody("Success")); - var request = new EmptyRequest + var request = new Auth0.ManagementApi.Core.EmptyRequest { BaseUrl = _baseUrl, Method = HttpMethod.Get, @@ -89,7 +89,7 @@ public async SystemTask SendRequestAsync_ShouldRetry_OnNonRetryableStatusCodes(i .WillSetStateTo("Server Error") .RespondWith(WireMockResponse.Create().WithStatusCode(statusCode).WithBody("Failure")); - var request = new JsonRequest + var request = new Auth0.ManagementApi.Core.JsonRequest { BaseUrl = _baseUrl, Method = HttpMethod.Get, @@ -118,7 +118,7 @@ public async SystemTask SendRequestAsync_ShouldNotRetry_WithStreamRequest() .WillSetStateTo("Server Error") .RespondWith(WireMockResponse.Create().WithStatusCode(429).WithBody("Failure")); - var request = new StreamRequest + var request = new Auth0.ManagementApi.Core.StreamRequest { BaseUrl = _baseUrl, Method = HttpMethod.Post, @@ -223,7 +223,7 @@ public async SystemTask SendRequestAsync_ShouldRespectRetryAfterHeader_WithSecon .WhenStateIs("Success") .RespondWith(WireMockResponse.Create().WithStatusCode(200).WithBody("Success")); - var request = new EmptyRequest + var request = new Auth0.ManagementApi.Core.EmptyRequest { BaseUrl = _baseUrl, Method = HttpMethod.Get, @@ -262,7 +262,7 @@ public async SystemTask SendRequestAsync_ShouldRespectRetryAfterHeader_WithHttpD .WhenStateIs("Success") .RespondWith(WireMockResponse.Create().WithStatusCode(200).WithBody("Success")); - var request = new EmptyRequest + var request = new Auth0.ManagementApi.Core.EmptyRequest { BaseUrl = _baseUrl, Method = HttpMethod.Get, @@ -301,7 +301,7 @@ public async SystemTask SendRequestAsync_ShouldRespectXRateLimitResetHeader() .WhenStateIs("Success") .RespondWith(WireMockResponse.Create().WithStatusCode(200).WithBody("Success")); - var request = new EmptyRequest + var request = new Auth0.ManagementApi.Core.EmptyRequest { BaseUrl = _baseUrl, Method = HttpMethod.Get, @@ -334,7 +334,7 @@ public async SystemTask SendRequestAsync_ShouldPreserveJsonBody_OnRetry() .WhenStateIs("Success") .RespondWith(WireMockResponse.Create().WithStatusCode(200).WithBody("Success")); - var request = new JsonRequest + var request = new Auth0.ManagementApi.Core.JsonRequest { BaseUrl = _baseUrl, Method = HttpMethod.Post, @@ -397,10 +397,144 @@ public async SystemTask SendRequestAsync_ShouldPreserveMultipartBody_OnRetry() } } + [Test] + public async SystemTask SendRequestAsync_ShouldRetry_WhenHandlerDisposesRequestContent() + { + // ContentDisposingHandler simulates HTTP/2's disposal of request.Content after send; + // WireMock's loopback HTTP/1.1 path does not exhibit that on its own. + _server + .Given(WireMockRequest.Create().WithPath("/test").UsingPost()) + .InScenario("DisposeContentRetry") + .WillSetStateTo("Success") + .RespondWith(WireMockResponse.Create().WithStatusCode(500)); + + _server + .Given(WireMockRequest.Create().WithPath("/test").UsingPost()) + .InScenario("DisposeContentRetry") + .WhenStateIs("Success") + .RespondWith(WireMockResponse.Create().WithStatusCode(200).WithBody("Success")); + + using var disposingClient = new HttpClient( + new ContentDisposingHandler(new HttpClientHandler()) + ); + var rawClient = new RawClient( + new ClientOptions { HttpClient = disposingClient, MaxRetries = MaxRetries } + ) + { + BaseRetryDelay = 0, + }; + + var request = new Auth0.ManagementApi.Core.JsonRequest + { + BaseUrl = _baseUrl, + Method = HttpMethod.Post, + Path = "/test", + Body = new { key = "value" }, + }; + + var response = await rawClient.SendRequestAsync(request); + Assert.That(response.StatusCode, Is.EqualTo(200)); + + var content = await response.Raw.Content.ReadAsStringAsync(); + using (Assert.EnterMultipleScope()) + { + Assert.That(content, Is.EqualTo("Success")); + Assert.That(_server.LogEntries, Has.Count.EqualTo(2)); + + var retriedEntry = _server.LogEntries.ElementAt(1); + using var actualJson = JsonDocument.Parse(retriedEntry.RequestMessage.Body!); + Assert.That(actualJson.RootElement.GetProperty("key").GetString(), Is.EqualTo("value")); + } + } + + [Test] + public async SystemTask SendRequestAsync_ShouldRetry_WhenHandlerDisposesRequestContent_AcrossMultipleRetries() + { + // Exercises 2nd and 3rd clones — the single-retry variant can pass if those break. + _server + .Given(WireMockRequest.Create().WithPath("/test").UsingPost()) + .InScenario("DisposeContentMultiRetry") + .WillSetStateTo("Second") + .RespondWith(WireMockResponse.Create().WithStatusCode(500)); + + _server + .Given(WireMockRequest.Create().WithPath("/test").UsingPost()) + .InScenario("DisposeContentMultiRetry") + .WhenStateIs("Second") + .WillSetStateTo("Third") + .RespondWith(WireMockResponse.Create().WithStatusCode(500)); + + _server + .Given(WireMockRequest.Create().WithPath("/test").UsingPost()) + .InScenario("DisposeContentMultiRetry") + .WhenStateIs("Third") + .WillSetStateTo("Success") + .RespondWith(WireMockResponse.Create().WithStatusCode(500)); + + _server + .Given(WireMockRequest.Create().WithPath("/test").UsingPost()) + .InScenario("DisposeContentMultiRetry") + .WhenStateIs("Success") + .RespondWith(WireMockResponse.Create().WithStatusCode(200).WithBody("Success")); + + using var disposingClient = new HttpClient( + new ContentDisposingHandler(new HttpClientHandler()) + ); + var rawClient = new RawClient( + new ClientOptions { HttpClient = disposingClient, MaxRetries = MaxRetries } + ) + { + BaseRetryDelay = 0, + }; + + var request = new Auth0.ManagementApi.Core.JsonRequest + { + BaseUrl = _baseUrl, + Method = HttpMethod.Post, + Path = "/test", + Body = new { key = "value" }, + }; + + var response = await rawClient.SendRequestAsync(request); + Assert.That(response.StatusCode, Is.EqualTo(200)); + + using (Assert.EnterMultipleScope()) + { + // Initial attempt + 3 retries == 4 requests reaching the server. + Assert.That(_server.LogEntries, Has.Count.EqualTo(MaxRetries + 1)); + + // Every retried request must have preserved the original body. + foreach (var entry in _server.LogEntries) + { + using var actualJson = JsonDocument.Parse(entry.RequestMessage.Body!); + Assert.That( + actualJson.RootElement.GetProperty("key").GetString(), + Is.EqualTo("value") + ); + } + } + } + [TearDown] public void TearDown() { _server.Dispose(); _httpClient.Dispose(); } + + private sealed class ContentDisposingHandler : DelegatingHandler + { + public ContentDisposingHandler(HttpMessageHandler inner) + : base(inner) { } + + protected override async global::System.Threading.Tasks.Task SendAsync( + HttpRequestMessage request, + CancellationToken cancellationToken + ) + { + var response = await base.SendAsync(request, cancellationToken).ConfigureAwait(false); + request.Content?.Dispose(); + return response; + } + } } diff --git a/tests/Auth0.ManagementApi.Test/Core/Sse/SseReconnectHelperTests.cs b/tests/Auth0.ManagementApi.Test/Core/Sse/SseReconnectHelperTests.cs new file mode 100644 index 000000000..c6009d9b4 --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Core/Sse/SseReconnectHelperTests.cs @@ -0,0 +1,539 @@ +using Auth0.ManagementApi.Core; +using global::System.IO; +using global::System.Net; +using global::System.Net.ServerSentEvents; +using global::System.Text; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Core.Sse; + +/// +/// Unit and integration tests for . +/// Exercises reconnection behaviors: terminator gating, default backoff, +/// last-dispatched-id correctness, reconnect cap with reset, cancellation, +/// disableReconnection flag, and null-body handling. +/// +[TestFixture] +[Parallelizable(ParallelScope.Children)] +public class SseReconnectHelperTests +{ + // ─── Helpers ───────────────────────────────────────────────────────── + + /// + /// Creates a minimal wrapping the given SSE text. + /// + private static ApiResponse CreateSseResponse(string sseText) + { + var content = new StringContent(sseText, Encoding.UTF8, "text/event-stream"); + var httpResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = content }; + return new ApiResponse { StatusCode = 200, Raw = httpResponse }; + } + + /// + /// Creates an whose content stream throws + /// on read (simulates a dropped connection). + /// + private static ApiResponse CreateDroppedResponse(string sseTextBeforeDrop) + { + var stream = new DroppingStream(sseTextBeforeDrop); + var content = new StreamContent(stream); + content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue( + "text/event-stream" + ); + var httpResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = content }; + return new ApiResponse { StatusCode = 200, Raw = httpResponse }; + } + + /// + /// A stream that returns the initial text then throws IOException (simulating a drop). + /// + private sealed class DroppingStream : Stream + { + private readonly byte[] _data; + private int _position; + + public DroppingStream(string initialText) + { + _data = Encoding.UTF8.GetBytes(initialText); + } + + public override bool CanRead => true; + public override bool CanSeek => false; + public override bool CanWrite => false; + public override long Length => _data.Length; + public override long Position + { + get => _position; + set => throw new NotSupportedException(); + } + + public override int Read(byte[] buffer, int offset, int count) + { + var remaining = _data.Length - _position; + if (remaining <= 0) + { + throw new IOException("Connection dropped"); + } + var toCopy = Math.Min(count, remaining); + Array.Copy(_data, _position, buffer, offset, toCopy); + _position += toCopy; + return toCopy; + } + + public override Task ReadAsync( + byte[] buffer, + int offset, + int count, + CancellationToken cancellationToken + ) + { + var remaining = _data.Length - _position; + if (remaining <= 0) + { + throw new IOException("Connection dropped"); + } + var toCopy = Math.Min(count, remaining); + Array.Copy(_data, _position, buffer, offset, toCopy); + _position += toCopy; + return Task.FromResult(toCopy); + } + +#if NET5_0_OR_GREATER + public override ValueTask ReadAsync( + Memory buffer, + CancellationToken cancellationToken = default + ) + { + var remaining = _data.Length - _position; + if (remaining <= 0) + { + throw new IOException("Connection dropped"); + } + var toCopy = Math.Min(buffer.Length, remaining); + _data.AsSpan(_position, toCopy).CopyTo(buffer.Span); + _position += toCopy; + return new ValueTask(toCopy); + } +#endif + + public override void Flush() { } + + public override long Seek(long offset, SeekOrigin origin) => + throw new NotSupportedException(); + + public override void SetLength(long value) => throw new NotSupportedException(); + + public override void Write(byte[] buffer, int offset, int count) => + throw new NotSupportedException(); + } + + // ─── Test: No terminator → no reconnect ───────────────────────────── + + [Test] + public async Task NoTerminator_DoesNotReconnect_StreamEndsOnEof() + { + // When terminator is null, the helper cannot distinguish a completed + // stream from a dropped connection, so it must NOT reconnect. + var sseText = "id: evt-1\ndata: {\"value\":1}\n\nid: evt-2\ndata: {\"value\":2}\n\n"; + var initialResponse = CreateSseResponse(sseText); + var reconnectCalled = false; + + var items = new List(); + await foreach ( + var item in SseReconnectHelper.EnumerateWithReconnectAsync( + initialResponse, + (lastId, ct) => + { + reconnectCalled = true; + return Task.FromResult(CreateSseResponse("id: evt-3\ndata: {\"value\":3}\n\n")); + }, + maxReconnectAttempts: 5, + disableReconnection: false, + terminator: null // No terminator! + ) + ) + { + items.Add(item.Data); + } + + Assert.That(reconnectCalled, Is.False, "Should not reconnect when terminator is null"); + Assert.That(items, Has.Count.EqualTo(2)); + Assert.That(items[0], Is.EqualTo("{\"value\":1}")); + Assert.That(items[1], Is.EqualTo("{\"value\":2}")); + } + + // ─── Test: Default 1s backoff when no retry: directive ─────────────── + + [Test] + public async Task DefaultBackoff_WaitsAtLeast900ms_WhenNoRetryDirective() + { + // Without a server retry: directive, the helper should wait ~1s + // (DefaultReconnectDelay) before reconnecting — NOT zero. + var sseText1 = "id: evt-1\ndata: {\"value\":1}\n\n"; + var sseText2 = "id: evt-2\ndata: {\"value\":2}\n\ndata: [DONE]\n\n"; + var initialResponse = CreateSseResponse(sseText1); + var sw = System.Diagnostics.Stopwatch.StartNew(); + + var items = new List(); + await foreach ( + var item in SseReconnectHelper.EnumerateWithReconnectAsync( + initialResponse, + (lastId, ct) => Task.FromResult(CreateSseResponse(sseText2)), + maxReconnectAttempts: 3, + disableReconnection: false, + terminator: "[DONE]" + ) + ) + { + items.Add(item.Data); + } + + sw.Stop(); + Assert.That(items, Has.Count.EqualTo(2)); + Assert.That( + sw.ElapsedMilliseconds, + Is.GreaterThanOrEqualTo(900), + $"Expected >= 900ms delay before reconnect, got {sw.ElapsedMilliseconds}ms" + ); + } + + // ─── Test: Server retry: directive is respected and clamped ────────── + + [Test] + public async Task ServerRetry_IsRespectedAndClamped() + { + // Server sends retry: 200; helper should wait ~200ms before reconnect. + var sseText1 = "retry: 200\nid: evt-1\ndata: {\"value\":1}\n\n"; + var sseText2 = "id: evt-2\ndata: {\"value\":2}\n\ndata: [DONE]\n\n"; + var initialResponse = CreateSseResponse(sseText1); + var sw = System.Diagnostics.Stopwatch.StartNew(); + + var items = new List(); + await foreach ( + var item in SseReconnectHelper.EnumerateWithReconnectAsync( + initialResponse, + (lastId, ct) => Task.FromResult(CreateSseResponse(sseText2)), + maxReconnectAttempts: 3, + disableReconnection: false, + terminator: "[DONE]" + ) + ) + { + items.Add(item.Data); + } + + sw.Stop(); + Assert.That(items, Has.Count.EqualTo(2)); + Assert.That( + sw.ElapsedMilliseconds, + Is.GreaterThanOrEqualTo(150), + $"Expected >= 150ms (server retry: 200), got {sw.ElapsedMilliseconds}ms" + ); + } + + // ─── Test: Mid-event drop sends Last-Event-ID from last dispatched ── + + [Test] + public async Task MidEventDrop_ReconnectsWithLastDispatchedId_NotParsedId() + { + // evt-1 is fully dispatched. Then id: evt-2 is parsed but the + // connection drops before evt-2's data/blank line. Reconnection + // must use "evt-1" (last dispatched), NOT "evt-2" (last parsed). + var sseTextWithDrop = "id: evt-1\ndata: {\"value\":1}\n\nid: evt-2\n"; + var initialResponse = CreateDroppedResponse(sseTextWithDrop); + string? receivedLastEventId = null; + var sseText2 = "id: evt-2\ndata: {\"value\":2}\n\ndata: [DONE]\n\n"; + + var items = new List(); + await foreach ( + var item in SseReconnectHelper.EnumerateWithReconnectAsync( + initialResponse, + (lastId, ct) => + { + receivedLastEventId = lastId; + return Task.FromResult(CreateSseResponse(sseText2)); + }, + maxReconnectAttempts: 3, + disableReconnection: false, + terminator: "[DONE]" + ) + ) + { + items.Add(item.Data); + } + + Assert.That( + receivedLastEventId, + Is.EqualTo("evt-1"), + "Should reconnect with last *dispatched* id, not the parsed-but-undispatched id" + ); + Assert.That(items, Has.Count.EqualTo(2)); + Assert.That(items[0], Is.EqualTo("{\"value\":1}")); + Assert.That(items[1], Is.EqualTo("{\"value\":2}")); + } + + // ─── Test: maxReconnectAttempts caps consecutive failures ──────────── + + [Test] + public async Task MaxReconnectAttempts_CapsConsecutiveFailures() + { + // Set maxReconnectAttempts=2. Each reconnect returns an empty body + // (no events, no terminator) so attempts accumulate until the cap. + var sseText1 = "id: evt-1\ndata: {\"value\":1}\n\n"; + var emptyResponse = ""; // No events + var initialResponse = CreateSseResponse(sseText1); + var reconnectCount = 0; + + var items = new List(); + await foreach ( + var item in SseReconnectHelper.EnumerateWithReconnectAsync( + initialResponse, + (lastId, ct) => + { + reconnectCount++; + return Task.FromResult(CreateSseResponse(emptyResponse)); + }, + maxReconnectAttempts: 2, + disableReconnection: false, + terminator: "[DONE]" + ) + ) + { + items.Add(item.Data); + } + + // Got only the initial event + Assert.That(items, Has.Count.EqualTo(1)); + Assert.That(items[0], Is.EqualTo("{\"value\":1}")); + // Reconnected exactly 2 times before giving up + Assert.That(reconnectCount, Is.EqualTo(2)); + } + + // ─── Test: disableReconnection prevents reconnection ──────────────── + + [Test] + public async Task DisableReconnection_PreventsReconnect() + { + var sseText = "id: evt-1\ndata: {\"value\":1}\n\n"; + var initialResponse = CreateSseResponse(sseText); + var reconnectCalled = false; + + var items = new List(); + await foreach ( + var item in SseReconnectHelper.EnumerateWithReconnectAsync( + initialResponse, + (lastId, ct) => + { + reconnectCalled = true; + return Task.FromResult( + CreateSseResponse("id: evt-2\ndata: {\"value\":2}\n\ndata: [DONE]\n\n") + ); + }, + maxReconnectAttempts: 5, + disableReconnection: true, // Disabled! + terminator: "[DONE]" + ) + ) + { + items.Add(item.Data); + } + + Assert.That(reconnectCalled, Is.False, "Should not reconnect when disabled"); + Assert.That(items, Has.Count.EqualTo(1)); + } + + // ─── Test: Cancellation during backoff stops promptly ─────────────── + + [Test] + public async Task Cancellation_DuringBackoff_StopsPromptly() + { + var sseText = "id: evt-1\ndata: {\"value\":1}\n\n"; + var initialResponse = CreateSseResponse(sseText); + using var cts = new CancellationTokenSource(); + + var items = new List(); + var sw = System.Diagnostics.Stopwatch.StartNew(); + + // Cancel after 200ms (well before the 1s default backoff completes) + cts.CancelAfter(TimeSpan.FromMilliseconds(200)); + + try + { + await foreach ( + var item in SseReconnectHelper.EnumerateWithReconnectAsync( + initialResponse, + (lastId, ct) => + { + // Should not be reached because cancellation fires during delay + return Task.FromResult( + CreateSseResponse("id: evt-2\ndata: {\"value\":2}\n\ndata: [DONE]\n\n") + ); + }, + maxReconnectAttempts: 5, + disableReconnection: false, + terminator: "[DONE]", + cancellationToken: cts.Token + ) + ) + { + items.Add(item.Data); + } + Assert.Fail("Expected OperationCanceledException"); + } + catch (OperationCanceledException) + { + // Expected — Task.Delay throws on cancellation + } + + sw.Stop(); + Assert.That(items, Has.Count.EqualTo(1)); + // Should have stopped well before the full 1s delay + Assert.That( + sw.ElapsedMilliseconds, + Is.LessThan(800), + $"Cancellation should stop promptly, took {sw.ElapsedMilliseconds}ms" + ); + } + + // ─── Test: Reconnect function failure throws after exhausting cap ──── + + [Test] + public void ReconnectFnThrows_SurfacesIOException_AfterExhaustingCap() + { + var sseText = "id: evt-1\ndata: {\"value\":1}\n\n"; + var initialResponse = CreateSseResponse(sseText); + var reconnectCount = 0; + + var items = new List(); + var ex = Assert.ThrowsAsync(async () => + { + await foreach ( + var item in SseReconnectHelper.EnumerateWithReconnectAsync( + initialResponse, + (lastId, ct) => + { + reconnectCount++; + throw new HttpRequestException("Server returned 500"); + }, + maxReconnectAttempts: 2, + disableReconnection: false, + terminator: "[DONE]" + ) + ) + { + items.Add(item.Data); + } + }); + + Assert.That(items, Has.Count.EqualTo(1)); + Assert.That(items[0], Is.EqualTo("{\"value\":1}")); + // Should have retried up to the max + Assert.That(reconnectCount, Is.EqualTo(2)); + // Inner exception should be the last reconnect failure + Assert.That(ex!.InnerException, Is.TypeOf()); + Assert.That(ex.Message, Does.Contain("failed after exhausting all attempts")); + } + + // ─── Test: Cancellation in reconnectFn propagates immediately ───────── + + [Test] + public void Cancellation_InReconnectFn_PropagatesImmediately() + { + var sseText = "id: evt-1\ndata: {\"value\":1}\n\n"; + var initialResponse = CreateSseResponse(sseText); + using var cts = new CancellationTokenSource(); + + var items = new List(); + Assert.ThrowsAsync(async () => + { + await foreach ( + var item in SseReconnectHelper.EnumerateWithReconnectAsync( + initialResponse, + (lastId, ct) => + { + cts.Cancel(); + throw new OperationCanceledException(ct); + }, + maxReconnectAttempts: 5, + disableReconnection: false, + terminator: "[DONE]", + cancellationToken: cts.Token + ) + ) + { + items.Add(item.Data); + } + }); + + Assert.That(items, Has.Count.EqualTo(1)); + } + + // ─── Test: Normal reconnection works end-to-end ───────────────────── + + [Test] + public async Task Reconnection_EndToEnd_AllEventsReceived() + { + var sseText1 = "id: evt-1\ndata: {\"value\":1}\n\nid: evt-2\ndata: {\"value\":2}\n\n"; + var sseText2 = + "id: evt-3\ndata: {\"value\":3}\n\nid: evt-4\ndata: {\"value\":4}\n\ndata: [DONE]\n\n"; + var initialResponse = CreateSseResponse(sseText1); + string? receivedLastEventId = null; + + var items = new List(); + await foreach ( + var item in SseReconnectHelper.EnumerateWithReconnectAsync( + initialResponse, + (lastId, ct) => + { + receivedLastEventId = lastId; + return Task.FromResult(CreateSseResponse(sseText2)); + }, + maxReconnectAttempts: 3, + disableReconnection: false, + terminator: "[DONE]" + ) + ) + { + items.Add(item.Data); + } + + Assert.That(receivedLastEventId, Is.EqualTo("evt-2")); + Assert.That(items, Has.Count.EqualTo(4)); + Assert.That(items[0], Is.EqualTo("{\"value\":1}")); + Assert.That(items[1], Is.EqualTo("{\"value\":2}")); + Assert.That(items[2], Is.EqualTo("{\"value\":3}")); + Assert.That(items[3], Is.EqualTo("{\"value\":4}")); + } + + // ─── Test: Terminator stops stream without reconnection ───────────── + + [Test] + public async Task Terminator_StopsStream_NoReconnection() + { + var sseText = + "id: evt-1\ndata: {\"value\":1}\n\nid: evt-2\ndata: {\"value\":2}\n\ndata: [DONE]\n\n"; + var initialResponse = CreateSseResponse(sseText); + var reconnectCalled = false; + + var items = new List(); + await foreach ( + var item in SseReconnectHelper.EnumerateWithReconnectAsync( + initialResponse, + (lastId, ct) => + { + reconnectCalled = true; + return Task.FromResult(CreateSseResponse("")); + }, + maxReconnectAttempts: 5, + disableReconnection: false, + terminator: "[DONE]" + ) + ) + { + items.Add(item.Data); + } + + Assert.That(reconnectCalled, Is.False, "Should not reconnect when terminator is reached"); + Assert.That(items, Has.Count.EqualTo(2)); + } +} diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/ClientGrants/Organizations/ListTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/ClientGrants/Organizations/ListTest.cs index 7a6c0b278..e50ddaa94 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/ClientGrants/Organizations/ListTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/ClientGrants/Organizations/ListTest.cs @@ -21,7 +21,8 @@ public async Task MockServerTest() "display_name": "display_name", "token_quota": { "client_credentials": {} - } + }, + "third_party_client_access": "block" } ] } diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/CreateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/CreateTest.cs index 6839744db..8b8a26c44 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/CreateTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/CreateTest.cs @@ -361,6 +361,14 @@ public async Task MockServerTest() ], "ip_allowlist": [ "ip_allowlist" + ], + "grants": [ + { + "connection": "connection", + "scopes": [ + "scopes" + ] + } ] }, "compliance_level": "none", diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/GetTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/GetTest.cs index f79e274ee..2f8f0c92f 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/GetTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/GetTest.cs @@ -355,6 +355,14 @@ public async Task MockServerTest() ], "ip_allowlist": [ "ip_allowlist" + ], + "grants": [ + { + "connection": "connection", + "scopes": [ + "scopes" + ] + } ] }, "compliance_level": "none", diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/RotateSecretTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/RotateSecretTest.cs index c73ef63c3..e6f12c207 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/RotateSecretTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/RotateSecretTest.cs @@ -354,6 +354,14 @@ public async Task MockServerTest() ], "ip_allowlist": [ "ip_allowlist" + ], + "grants": [ + { + "connection": "connection", + "scopes": [ + "scopes" + ] + } ] }, "compliance_level": "none", diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/UpdateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/UpdateTest.cs index 6945667e4..66429a6fa 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/UpdateTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Clients/UpdateTest.cs @@ -359,6 +359,14 @@ public async Task MockServerTest() ], "ip_allowlist": [ "ip_allowlist" + ], + "grants": [ + { + "connection": "connection", + "scopes": [ + "scopes" + ] + } ] }, "compliance_level": "none", diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Deliveries/GetHistoryTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Deliveries/GetHistoryTest.cs index 0c8f09507..6b23df103 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Deliveries/GetHistoryTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Deliveries/GetHistoryTest.cs @@ -16,7 +16,7 @@ public async Task MockServerTest() "id": "id", "event_stream_id": "event_stream_id", "status": "failed", - "event_type": "group.created", + "event_type": "connection.created", "attempts": [ { "status": "failed", diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Deliveries/ListTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Deliveries/ListTest.cs index 9beefa699..137b98353 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Deliveries/ListTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Deliveries/ListTest.cs @@ -18,7 +18,7 @@ public async Task MockServerTest() "id": "id", "event_stream_id": "event_stream_id", "status": "failed", - "event_type": "group.created", + "event_type": "connection.created", "attempts": [ { "status": "failed", diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Redeliveries/CreateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Redeliveries/CreateTest.cs index 6c4fe628e..040a9e69f 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Redeliveries/CreateTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/Redeliveries/CreateTest.cs @@ -24,7 +24,7 @@ public async Task MockServerTest() "failed" ], "event_types": [ - "group.created" + "connection.created" ] } """; diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/TestTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/TestTest.cs index 405183961..a87abf0af 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/TestTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/EventStreams/TestTest.cs @@ -14,7 +14,7 @@ public async Task MockServerTest() { const string requestJson = """ { - "event_type": "group.created" + "event_type": "connection.created" } """; @@ -23,7 +23,7 @@ public async Task MockServerTest() "id": "id", "event_stream_id": "event_stream_id", "status": "failed", - "event_type": "group.created", + "event_type": "connection.created", "attempts": [ { "status": "failed", @@ -62,7 +62,7 @@ public async Task MockServerTest() "id", new CreateEventStreamTestEventRequestContent { - EventType = EventStreamTestEventTypeEnum.GroupCreated, + EventType = EventStreamTestEventTypeEnum.ConnectionCreated, } ); JsonAssert.AreEqual(response, mockResponse); diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/CreateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/CreateTest.cs index 498e69399..0cc460265 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/CreateTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/CreateTest.cs @@ -40,6 +40,7 @@ public async Task MockServerTest() "per_hour": 1 } }, + "third_party_client_access": "block", "enabled_connections": [ { "connection_id": "connection_id", diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/GetByNameTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/GetByNameTest.cs index d82c34b58..de6cd3207 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/GetByNameTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/GetByNameTest.cs @@ -32,7 +32,8 @@ public async Task MockServerTest() "per_day": 1, "per_hour": 1 } - } + }, + "third_party_client_access": "block" } """; diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/GetTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/GetTest.cs index 05c9ccd19..1f028e47f 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/GetTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/GetTest.cs @@ -32,7 +32,8 @@ public async Task MockServerTest() "per_day": 1, "per_hour": 1 } - } + }, + "third_party_client_access": "block" } """; diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/ListTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/ListTest.cs index 7aecb1ea9..b8fbb9c63 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/ListTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/ListTest.cs @@ -21,7 +21,8 @@ public async Task MockServerTest() "display_name": "display_name", "token_quota": { "client_credentials": {} - } + }, + "third_party_client_access": "block" } ] } diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Roles/Members/ListTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Roles/Members/ListTest.cs new file mode 100644 index 000000000..364997e76 --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/Roles/Members/ListTest.cs @@ -0,0 +1,62 @@ +using Auth0.ManagementApi.Organizations.Roles; +using Auth0.ManagementApi.Test.Unit.MockServer; +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.MockServer.Organizations.Roles.Members; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "members": [ + { + "user_id": "user_id", + "picture": "picture", + "name": "name", + "email": "email" + } + ], + "next": "next" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/organizations/id/roles/role_id/members") + .WithParam("from", "from") + .WithParam("take", "1") + .WithParam("fields", "fields") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Organizations.Roles.Members.ListAsync( + "id", + "role_id", + new ListOrganizationRoleMembersRequestParameters + { + From = "from", + Take = 1, + Fields = "fields", + IncludeFields = true, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/UpdateTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/UpdateTest.cs index c79be41aa..ae5392530 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/UpdateTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Organizations/UpdateTest.cs @@ -37,7 +37,8 @@ public async Task MockServerTest() "per_day": 1, "per_hour": 1 } - } + }, + "third_party_client_access": "block" } """; diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/UserGrants/ListTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/UserGrants/ListTest.cs index cbb930e7b..864977886 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/UserGrants/ListTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/UserGrants/ListTest.cs @@ -24,7 +24,8 @@ public async Task MockServerTest() "audience": "audience", "scope": [ "scope" - ] + ], + "organization_id": "organization_id" } ] } diff --git a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Users/Organizations/ListTest.cs b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Users/Organizations/ListTest.cs index fb09403cf..e0c970e25 100644 --- a/tests/Auth0.ManagementApi.Test/Unit/MockServer/Users/Organizations/ListTest.cs +++ b/tests/Auth0.ManagementApi.Test/Unit/MockServer/Users/Organizations/ListTest.cs @@ -23,7 +23,8 @@ public async Task MockServerTest() "display_name": "display_name", "token_quota": { "client_credentials": {} - } + }, + "third_party_client_access": "block" } ] } From 27575758440f7b07c1a1eead588cc812c8a2e7e3 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2026 14:50:42 +0000 Subject: [PATCH 2/3] [fern-replay] Applied customizations Patches applied (2): - patch-4a7a2c3e: Adds extension to convert UserDateSchema to DateTime - patch-composite-f898e213: Customer customizations (composite) --- .fern/replay.lock | 12 ++- .../Core/JsonConfiguration.cs | 1 + .../Auth0.ManagementApi.Test.csproj | 2 +- .../UserDateSchemaExtensionsTest.cs | 95 +++++++++++++++++++ 4 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 tests/Auth0.ManagementApi.Test/Unit/Extensions/UserDateSchemaExtensionsTest.cs diff --git a/.fern/replay.lock b/.fern/replay.lock index 21a553009..6c36b8793 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -24,14 +24,20 @@ generations: cli_version: unknown generator_versions: fernapi/fern-csharp-sdk: 2.66.5 -current_generation: a512bdbe19d2fd38306aa649d016526a518ecc14 + - commit_sha: 25e621a6eb7584bd0761ac10041190771fa2b388 + tree_hash: 74a7cf305bf2f1a90799bc45819649f1a36146c5 + timestamp: 2026-07-08T14:50:39.416Z + cli_version: unknown + generator_versions: + fernapi/fern-csharp-sdk: 2.72.1 +current_generation: 25e621a6eb7584bd0761ac10041190771fa2b388 patches: - id: patch-4a7a2c3e content_hash: sha256:afae223b4593598543491ca12e36149571f886b494dcf4311dcea092548f7bd0 original_commit: 4a7a2c3e44bfc06c1f164a3c6ef0ae748ce3075b original_message: Adds extension to convert UserDateSchema to DateTime original_author: Kailash B - base_generation: a512bdbe19d2fd38306aa649d016526a518ecc14 + base_generation: 25e621a6eb7584bd0761ac10041190771fa2b388 files: - tests/Auth0.ManagementApi.Test/Unit/Extensions/UserDateSchemaExtensionsTest.cs patch_content: | @@ -239,7 +245,7 @@ patches: original_commit: f898e213a3bde5c59096e7f5eb940e6fd76c26d8 original_message: Customer customizations (composite) original_author: composite - base_generation: a512bdbe19d2fd38306aa649d016526a518ecc14 + base_generation: 25e621a6eb7584bd0761ac10041190771fa2b388 files: - src/Auth0.ManagementApi/Core/JsonConfiguration.cs - tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj diff --git a/src/Auth0.ManagementApi/Core/JsonConfiguration.cs b/src/Auth0.ManagementApi/Core/JsonConfiguration.cs index 2ef97a37a..7588e83c1 100644 --- a/src/Auth0.ManagementApi/Core/JsonConfiguration.cs +++ b/src/Auth0.ManagementApi/Core/JsonConfiguration.cs @@ -17,6 +17,7 @@ static JsonOptions() var options = new JsonSerializerOptions { Converters = { new DateTimeSerializer(), + new BooleanStringConverter(), #if USE_PORTABLE_DATE_ONLY new DateOnlyConverter(), #endif diff --git a/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj b/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj index ab18c1f30..63c4abb22 100644 --- a/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj +++ b/tests/Auth0.ManagementApi.Test/Auth0.ManagementApi.Test.csproj @@ -25,7 +25,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/Auth0.ManagementApi.Test/Unit/Extensions/UserDateSchemaExtensionsTest.cs b/tests/Auth0.ManagementApi.Test/Unit/Extensions/UserDateSchemaExtensionsTest.cs new file mode 100644 index 000000000..7d867ca66 --- /dev/null +++ b/tests/Auth0.ManagementApi.Test/Unit/Extensions/UserDateSchemaExtensionsTest.cs @@ -0,0 +1,95 @@ +using NUnit.Framework; + +namespace Auth0.ManagementApi.Test.Unit.Extensions; + +[TestFixture] +public class UserDateSchemaExtensionsTest +{ + [Test] + public void ToDateTime_WithValidIso8601String_ReturnsUtcDateTime() + { + var schema = UserDateSchema.FromString("2024-03-15T10:30:00.000Z"); + + var result = schema.ToDateTime(); + + Assert.That(result, Is.Not.Null); + Assert.That(result!.Value, Is.EqualTo(new DateTime(2024, 3, 15, 10, 30, 0, DateTimeKind.Utc))); + Assert.That(result.Value.Kind, Is.EqualTo(DateTimeKind.Utc)); + } + + [Test] + public void ToDateTime_WithNull_ReturnsNull() + { + UserDateSchema? schema = null; + + var result = schema.ToDateTime(); + + Assert.That(result, Is.Null); + } + + [Test] + public void ToDateTime_WithMapType_ReturnsNull() + { + var schema = UserDateSchema.FromMapOfStringToUnknown(new Dictionary + { + { "some_key", "some_value" } + }); + + var result = schema.ToDateTime(); + + Assert.That(result, Is.Null); + } + + [Test] + public void ToDateTime_WithMalformedString_ReturnsNull() + { + var schema = UserDateSchema.FromString("not-a-date"); + + var result = schema.ToDateTime(); + + Assert.That(result, Is.Null); + } + + [Test] + public void ToDateTime_WithOffsetString_PreservesLocalKind() + { + var schema = UserDateSchema.FromString("2024-06-20T14:00:00.000+05:30"); + + var result = schema.ToDateTime(); + var expectedLocal = new DateTimeOffset(2024, 6, 20, 14, 0, 0, TimeSpan.FromMinutes(330)).LocalDateTime; + + Assert.That(result, Is.Not.Null); + Assert.That(result!.Value, Is.EqualTo(expectedLocal)); + Assert.That(result.Value.Kind, Is.EqualTo(DateTimeKind.Local)); + } + + [Test] + public void ToDateTime_WithDateTimeOffset_ReturnsUtcConverted() + { + var schema = UserDateSchema.FromString("2024-06-20T14:00:00.000+05:30"); + + var result = schema.ToDateTime(TimeZoneInfo.Utc); + + Assert.That(result, Is.Not.Null); + Assert.That(result!.Value.Kind, Is.EqualTo(DateTimeKind.Utc)); + Assert.That(result.Value, Is.EqualTo(new DateTime(2024, 6, 20, 8, 30, 0, DateTimeKind.Utc))); + } + + [Test] + public void ToDateTime_WithMalformedStringAndTargetTimeZone_ReturnsNull() + { + var schema = UserDateSchema.FromString("not-a-date"); + + var result = schema.ToDateTime(TimeZoneInfo.Utc); + + Assert.That(result, Is.Null); + } + + [Test] + public void ToDateTime_WithNullTargetTimeZone_ThrowsArgumentNullException() + { + var schema = UserDateSchema.FromString("2024-03-15T10:30:00.000Z"); + + Assert.Throws(() => schema.ToDateTime(null!)); + } +} From c8bd0ce3f7315162453529be3b9926f6481dcd79 Mon Sep 17 00:00:00 2001 From: Kailash B Date: Mon, 13 Jul 2026 12:52:29 +0530 Subject: [PATCH 3/3] build: Fix Integration tests --- .../DatabaseConnectionTests.cs | 6 +- .../UserDateSchemaExtensionsTest.cs | 95 ------------------- 2 files changed, 3 insertions(+), 98 deletions(-) delete mode 100644 tests/Auth0.ManagementApi.Test/Unit/Extensions/UserDateSchemaExtensionsTest.cs diff --git a/tests/Auth0.AuthenticationApi.IntegrationTests/DatabaseConnectionTests.cs b/tests/Auth0.AuthenticationApi.IntegrationTests/DatabaseConnectionTests.cs index 8f5addd61..fda85eeec 100644 --- a/tests/Auth0.AuthenticationApi.IntegrationTests/DatabaseConnectionTests.cs +++ b/tests/Auth0.AuthenticationApi.IntegrationTests/DatabaseConnectionTests.cs @@ -161,7 +161,7 @@ private ConnectionPropertiesOptions GetConnectionOptionsRequest() Email = new EmailAttribute() { ProfileRequired = false, - Identifier = new ConnectionAttributeIdentifier() + Identifier = new EmailAttributeIdentifier() { Active = true }, @@ -177,7 +177,7 @@ private ConnectionPropertiesOptions GetConnectionOptionsRequest() PhoneNumber = new PhoneAttribute() { ProfileRequired = true, - Identifier = new ConnectionAttributeIdentifier() + Identifier = new PhoneAttributeIdentifier() { Active = true }, @@ -193,7 +193,7 @@ private ConnectionPropertiesOptions GetConnectionOptionsRequest() Username = new UsernameAttribute() { ProfileRequired = true, - Identifier = new ConnectionAttributeIdentifier() + Identifier = new UsernameAttributeIdentifier() { Active = true }, diff --git a/tests/Auth0.ManagementApi.Test/Unit/Extensions/UserDateSchemaExtensionsTest.cs b/tests/Auth0.ManagementApi.Test/Unit/Extensions/UserDateSchemaExtensionsTest.cs deleted file mode 100644 index 7d867ca66..000000000 --- a/tests/Auth0.ManagementApi.Test/Unit/Extensions/UserDateSchemaExtensionsTest.cs +++ /dev/null @@ -1,95 +0,0 @@ -using NUnit.Framework; - -namespace Auth0.ManagementApi.Test.Unit.Extensions; - -[TestFixture] -public class UserDateSchemaExtensionsTest -{ - [Test] - public void ToDateTime_WithValidIso8601String_ReturnsUtcDateTime() - { - var schema = UserDateSchema.FromString("2024-03-15T10:30:00.000Z"); - - var result = schema.ToDateTime(); - - Assert.That(result, Is.Not.Null); - Assert.That(result!.Value, Is.EqualTo(new DateTime(2024, 3, 15, 10, 30, 0, DateTimeKind.Utc))); - Assert.That(result.Value.Kind, Is.EqualTo(DateTimeKind.Utc)); - } - - [Test] - public void ToDateTime_WithNull_ReturnsNull() - { - UserDateSchema? schema = null; - - var result = schema.ToDateTime(); - - Assert.That(result, Is.Null); - } - - [Test] - public void ToDateTime_WithMapType_ReturnsNull() - { - var schema = UserDateSchema.FromMapOfStringToUnknown(new Dictionary - { - { "some_key", "some_value" } - }); - - var result = schema.ToDateTime(); - - Assert.That(result, Is.Null); - } - - [Test] - public void ToDateTime_WithMalformedString_ReturnsNull() - { - var schema = UserDateSchema.FromString("not-a-date"); - - var result = schema.ToDateTime(); - - Assert.That(result, Is.Null); - } - - [Test] - public void ToDateTime_WithOffsetString_PreservesLocalKind() - { - var schema = UserDateSchema.FromString("2024-06-20T14:00:00.000+05:30"); - - var result = schema.ToDateTime(); - var expectedLocal = new DateTimeOffset(2024, 6, 20, 14, 0, 0, TimeSpan.FromMinutes(330)).LocalDateTime; - - Assert.That(result, Is.Not.Null); - Assert.That(result!.Value, Is.EqualTo(expectedLocal)); - Assert.That(result.Value.Kind, Is.EqualTo(DateTimeKind.Local)); - } - - [Test] - public void ToDateTime_WithDateTimeOffset_ReturnsUtcConverted() - { - var schema = UserDateSchema.FromString("2024-06-20T14:00:00.000+05:30"); - - var result = schema.ToDateTime(TimeZoneInfo.Utc); - - Assert.That(result, Is.Not.Null); - Assert.That(result!.Value.Kind, Is.EqualTo(DateTimeKind.Utc)); - Assert.That(result.Value, Is.EqualTo(new DateTime(2024, 6, 20, 8, 30, 0, DateTimeKind.Utc))); - } - - [Test] - public void ToDateTime_WithMalformedStringAndTargetTimeZone_ReturnsNull() - { - var schema = UserDateSchema.FromString("not-a-date"); - - var result = schema.ToDateTime(TimeZoneInfo.Utc); - - Assert.That(result, Is.Null); - } - - [Test] - public void ToDateTime_WithNullTargetTimeZone_ThrowsArgumentNullException() - { - var schema = UserDateSchema.FromString("2024-03-15T10:30:00.000Z"); - - Assert.Throws(() => schema.ToDateTime(null!)); - } -}