From 64589f6db862e607a0f195094fc95d0ef21481b9 Mon Sep 17 00:00:00 2001 From: jorgechav Date: Mon, 11 Aug 2025 07:37:32 -0600 Subject: [PATCH 1/6] Create Virtual Enclaves SDK --- .../Azure.ResourceManager.VirtualEnclaves.sln | 65 + .../CHANGELOG.md | 19 + .../Directory.Build.props | 6 + .../README.md | 80 ++ .../assets.json | 6 + ...urceManager.VirtualEnclaves.Samples.csproj | 10 + ...ure.ResourceManager.VirtualEnclaves.csproj | 9 + .../ApprovalResource.Serialization.cs | 29 + .../src/Generated/ApprovalResource.cs | 438 +++++++ .../Generated/ApprovalResourceCollection.cs | 483 ++++++++ .../ApprovalResourceData.Serialization.cs | 156 +++ .../src/Generated/ApprovalResourceData.cs | 75 ++ .../ArmVirtualEnclavesModelFactory.cs | 562 +++++++++ ...CommunityEndpointResource.Serialization.cs | 29 + .../Generated/CommunityEndpointResource.cs | 891 ++++++++++++++ .../CommunityEndpointResourceCollection.cs | 493 ++++++++ ...unityEndpointResourceData.Serialization.cs | 179 +++ .../CommunityEndpointResourceData.cs | 83 ++ .../CommunityResource.Serialization.cs | 29 + .../src/Generated/CommunityResource.cs | 929 ++++++++++++++ .../Generated/CommunityResourceCollection.cs | 494 ++++++++ .../CommunityResourceData.Serialization.cs | 195 +++ .../src/Generated/CommunityResourceData.cs | 87 ++ ...EnclaveConnectionResource.Serialization.cs | 29 + .../Generated/EnclaveConnectionResource.cs | 891 ++++++++++++++ .../EnclaveConnectionResourceCollection.cs | 494 ++++++++ ...aveConnectionResourceData.Serialization.cs | 179 +++ .../EnclaveConnectionResourceData.cs | 83 ++ .../EnclaveEndpointResource.Serialization.cs | 29 + .../src/Generated/EnclaveEndpointResource.cs | 891 ++++++++++++++ .../EnclaveEndpointResourceCollection.cs | 493 ++++++++ ...claveEndpointResourceData.Serialization.cs | 179 +++ .../Generated/EnclaveEndpointResourceData.cs | 83 ++ .../EnclaveResource.Serialization.cs | 29 + .../src/Generated/EnclaveResource.cs | 1029 ++++++++++++++++ .../Generated/EnclaveResourceCollection.cs | 494 ++++++++ .../EnclaveResourceData.Serialization.cs | 195 +++ .../src/Generated/EnclaveResourceData.cs | 87 ++ .../MockableVirtualEnclavesArmClient.cs | 208 ++++ ...bleVirtualEnclavesResourceGroupResource.cs | 243 ++++ ...ableVirtualEnclavesSubscriptionResource.cs | 527 ++++++++ .../Extensions/VirtualEnclavesExtensions.cs | 1082 +++++++++++++++++ .../src/Generated/Internal/Argument.cs | 129 ++ .../Internal/ChangeTrackingDictionary.cs | 167 +++ .../Generated/Internal/ChangeTrackingList.cs | 153 +++ .../Internal/ModelSerializationExtensions.cs | 409 +++++++ .../src/Generated/Internal/Optional.cs | 51 + .../Internal/Utf8JsonRequestContent.cs | 55 + .../ApprovalActionResponseOperationSource.cs | 30 + .../ApprovalResourceOperationSource.cs | 36 + ...ommunityEndpointResourceOperationSource.cs | 36 + .../CommunityResourceOperationSource.cs | 36 + ...nclaveConnectionResourceOperationSource.cs | 36 + .../EnclaveEndpointResourceOperationSource.cs | 36 + .../EnclaveResourceOperationSource.cs | 36 + .../TransitHubResourceOperationSource.cs | 36 + .../VirtualEnclavesArmOperation.cs | 96 ++ .../VirtualEnclavesArmOperationOfT.cs | 102 ++ .../WorkloadResourceOperationSource.cs | 36 + .../src/Generated/Models/ActionPerformed.cs | 51 + .../ApprovalActionContent.Serialization.cs | 126 ++ .../Generated/Models/ApprovalActionContent.cs | 72 ++ .../ApprovalActionRequestApprovalStatus.cs | 51 + .../ApprovalActionResponse.Serialization.cs | 126 ++ .../Models/ApprovalActionResponse.cs | 75 ++ .../ApprovalCallbackRequest.Serialization.cs | 145 +++ .../Models/ApprovalCallbackRequest.cs | 82 ++ .../ApprovalCallbackRequestApprovalStatus.cs | 51 + ...valCallbackRequestResourceRequestAction.cs | 57 + ...alDeletionCallbackRequest.Serialization.cs | 126 ++ .../Models/ApprovalDeletionCallbackRequest.cs | 72 ++ ...ionCallbackRequestResourceRequestAction.cs | 54 + .../ApprovalPatchProperties.Serialization.cs | 230 ++++ .../Models/ApprovalPatchProperties.cs | 101 ++ .../src/Generated/Models/ApprovalPolicy.cs | 51 + .../ApprovalProperties.Serialization.cs | 246 ++++ .../Generated/Models/ApprovalProperties.cs | 105 ++ ...pprovalResourceListResult.Serialization.cs | 151 +++ .../Models/ApprovalResourceListResult.cs | 80 ++ .../ApprovalResourcePatch.Serialization.cs | 133 ++ .../Generated/Models/ApprovalResourcePatch.cs | 65 + .../Models/ApprovalSettings.Serialization.cs | 369 ++++++ .../src/Generated/Models/ApprovalSettings.cs | 122 ++ ...alSettingsPatchProperties.Serialization.cs | 143 +++ .../Models/ApprovalSettingsPatchProperties.cs | 66 + .../src/Generated/Models/ApprovalStatus.cs | 60 + .../Models/Approver.Serialization.cs | 149 +++ .../src/Generated/Models/Approver.cs | 85 ++ ...reResourceManagerVirtualEnclavesContext.cs | 102 ++ ...sSpaceAvailabilityContent.Serialization.cs | 134 ++ .../CheckAddressSpaceAvailabilityContent.cs | 83 ++ ...SpaceAvailabilityResponse.Serialization.cs | 126 ++ .../CheckAddressSpaceAvailabilityResponse.cs | 72 ++ ...tyEndpointDestinationRule.Serialization.cs | 213 ++++ .../CommunityEndpointDestinationRule.cs | 87 ++ ...tyEndpointPatchProperties.Serialization.cs | 136 +++ .../CommunityEndpointPatchProperties.cs | 76 ++ ...mmunityEndpointProperties.Serialization.cs | 188 +++ .../Models/CommunityEndpointProperties.cs | 86 ++ .../Models/CommunityEndpointProtocol.cs | 69 ++ ...ndpointResourceListResult.Serialization.cs | 151 +++ .../CommunityEndpointResourceListResult.cs | 80 ++ ...nityEndpointResourcePatch.Serialization.cs | 159 +++ .../Models/CommunityEndpointResourcePatch.cs | 77 ++ .../CommunityPatchProperties.Serialization.cs | 261 ++++ .../Models/CommunityPatchProperties.cs | 103 ++ .../CommunityProperties.Serialization.cs | 355 ++++++ .../Generated/Models/CommunityProperties.cs | 121 ++ .../CommunityPropertiesPolicyOverride.cs | 51 + ...mmunityResourceListResult.Serialization.cs | 151 +++ .../Models/CommunityResourceListResult.cs | 80 ++ .../CommunityResourcePatch.Serialization.cs | 176 +++ .../Models/CommunityResourcePatch.cs | 75 ++ .../src/Generated/Models/DestinationType.cs | 57 + .../Generated/Models/DiagnosticDestination.cs | 54 + ...EnclaveAddressSpacesModel.Serialization.cs | 140 +++ .../Models/EnclaveAddressSpacesModel.cs | 69 ++ ...ConnectionPatchProperties.Serialization.cs | 129 ++ .../EnclaveConnectionPatchProperties.cs | 65 + ...claveConnectionProperties.Serialization.cs | 228 ++++ .../Models/EnclaveConnectionProperties.cs | 107 ++ ...nectionResourceListResult.Serialization.cs | 151 +++ .../EnclaveConnectionResourceListResult.cs | 80 ++ ...veConnectionResourcePatch.Serialization.cs | 159 +++ .../Models/EnclaveConnectionResourcePatch.cs | 82 ++ .../Models/EnclaveConnectionState.cs | 66 + ...claveDefaultSettingsModel.Serialization.cs | 200 +++ .../Models/EnclaveDefaultSettingsModel.cs | 79 ++ ...DefaultSettingsPatchModel.Serialization.cs | 133 ++ .../EnclaveDefaultSettingsPatchModel.cs | 65 + ...veEndpointDestinationRule.Serialization.cs | 176 +++ .../Models/EnclaveEndpointDestinationRule.cs | 78 ++ ...veEndpointPatchProperties.Serialization.cs | 136 +++ .../Models/EnclaveEndpointPatchProperties.cs | 76 ++ ...EnclaveEndpointProperties.Serialization.cs | 188 +++ .../Models/EnclaveEndpointProperties.cs | 86 ++ .../Models/EnclaveEndpointProtocol.cs | 63 + ...ndpointResourceListResult.Serialization.cs | 151 +++ .../EnclaveEndpointResourceListResult.cs | 80 ++ ...laveEndpointResourcePatch.Serialization.cs | 159 +++ .../Models/EnclaveEndpointResourcePatch.cs | 77 ++ ...EnclaveResourceListResult.Serialization.cs | 151 +++ .../Models/EnclaveResourceListResult.cs | 80 ++ .../EnclaveResourcePatch.Serialization.cs | 176 +++ .../Generated/Models/EnclaveResourcePatch.cs | 75 ++ ...nclaveVirtualNetworkModel.Serialization.cs | 197 +++ .../Models/EnclaveVirtualNetworkModel.cs | 82 ++ .../src/Generated/Models/FirewallSKU.cs | 54 + .../GovernedServiceItem.Serialization.cs | 214 ++++ .../Generated/Models/GovernedServiceItem.cs | 93 ++ .../Models/GovernedServiceItemEnforcement.cs | 51 + .../Models/GovernedServiceItemOption.cs | 57 + .../Models/GovernedServiceItemPolicyAction.cs | 54 + ...nceModeConfigurationModel.Serialization.cs | 166 +++ .../MaintenanceModeConfigurationModel.cs | 81 ++ ...anceModeConfigurationModelJustification.cs | 54 + .../MaintenanceModeConfigurationModelMode.cs | 60 + ...deConfigurationPatchModel.Serialization.cs | 166 +++ .../MaintenanceModeConfigurationPatchModel.cs | 81 ++ ...edOnBehalfOfConfiguration.Serialization.cs | 145 +++ .../Models/ManagedOnBehalfOfConfiguration.cs | 67 + .../Models/MandatoryApprover.Serialization.cs | 126 ++ .../src/Generated/Models/MandatoryApprover.cs | 75 ++ .../Models/Principal.Serialization.cs | 134 ++ .../src/Generated/Models/Principal.cs | 81 ++ .../src/Generated/Models/PrincipalType.cs | 54 + .../src/Generated/Models/ProvisioningState.cs | 72 ++ .../Models/RequestMetadata.Serialization.cs | 163 +++ .../src/Generated/Models/RequestMetadata.cs | 87 ++ ...tadataUpdatableProperties.Serialization.cs | 163 +++ .../RequestMetadataUpdatableProperties.cs | 87 ++ .../RoleAssignmentItem.Serialization.cs | 151 +++ .../Generated/Models/RoleAssignmentItem.cs | 80 ++ .../src/Generated/Models/ServiceIdentifier.cs | 90 ++ .../SubnetConfiguration.Serialization.cs | 193 +++ .../Generated/Models/SubnetConfiguration.cs | 98 ++ ...TransitHubPatchProperties.Serialization.cs | 148 +++ .../Models/TransitHubPatchProperties.cs | 69 ++ .../TransitHubProperties.Serialization.cs | 200 +++ .../Generated/Models/TransitHubProperties.cs | 79 ++ ...nsitHubResourceListResult.Serialization.cs | 151 +++ .../Models/TransitHubResourceListResult.cs | 80 ++ .../TransitHubResourcePatch.Serialization.cs | 159 +++ .../Models/TransitHubResourcePatch.cs | 70 ++ .../src/Generated/Models/TransitHubState.cs | 60 + .../Models/TransitOption.Serialization.cs | 148 +++ .../src/Generated/Models/TransitOption.cs | 69 ++ .../TransitOptionParams.Serialization.cs | 148 +++ .../Generated/Models/TransitOptionParams.cs | 70 ++ .../src/Generated/Models/TransitOptionType.cs | 54 + ...ualEnclavePatchProperties.Serialization.cs | 254 ++++ .../Models/VirtualEnclavePatchProperties.cs | 114 ++ .../VirtualEnclaveProperties.Serialization.cs | 361 ++++++ .../Models/VirtualEnclaveProperties.cs | 138 +++ .../WorkloadPatchProperties.Serialization.cs | 143 +++ .../Models/WorkloadPatchProperties.cs | 66 + .../WorkloadProperties.Serialization.cs | 173 +++ .../Generated/Models/WorkloadProperties.cs | 80 ++ ...orkloadResourceListResult.Serialization.cs | 151 +++ .../Models/WorkloadResourceListResult.cs | 80 ++ .../WorkloadResourcePatch.Serialization.cs | 159 +++ .../Generated/Models/WorkloadResourcePatch.cs | 81 ++ .../src/Generated/ProviderConstants.cs | 16 + .../RestOperations/ApprovalRestOperations.cs | 607 +++++++++ .../CommunityEndpointsRestOperations.cs | 983 +++++++++++++++ .../RestOperations/CommunityRestOperations.cs | 825 +++++++++++++ .../EnclaveConnectionRestOperations.cs | 911 ++++++++++++++ .../EnclaveEndpointsRestOperations.cs | 983 +++++++++++++++ .../TransitHubRestOperations.cs | 779 ++++++++++++ .../VirtualEnclaveRestOperations.cs | 911 ++++++++++++++ .../RestOperations/WorkloadRestOperations.cs | 779 ++++++++++++ .../TransitHubResource.Serialization.cs | 29 + .../src/Generated/TransitHubResource.cs | 708 +++++++++++ .../Generated/TransitHubResourceCollection.cs | 493 ++++++++ .../TransitHubResourceData.Serialization.cs | 179 +++ .../src/Generated/TransitHubResourceData.cs | 83 ++ .../WorkloadResource.Serialization.cs | 29 + .../src/Generated/WorkloadResource.cs | 707 +++++++++++ .../Generated/WorkloadResourceCollection.cs | 493 ++++++++ .../WorkloadResourceData.Serialization.cs | 179 +++ .../src/Generated/WorkloadResourceData.cs | 83 ++ .../src/Properties/AssemblyInfo.cs | 9 + ...sourceManager.VirtualEnclaves.Tests.csproj | 5 + .../Samples/Sample_ApprovalResource.cs | 150 +++ .../Sample_ApprovalResourceCollection.cs | 181 +++ .../Sample_CommunityEndpointResource.cs | 182 +++ ...ple_CommunityEndpointResourceCollection.cs | 214 ++++ .../Samples/Sample_CommunityResource.cs | 233 ++++ .../Sample_CommunityResourceCollection.cs | 319 +++++ .../Sample_EnclaveConnectionResource.cs | 173 +++ ...ple_EnclaveConnectionResourceCollection.cs | 203 ++++ .../Samples/Sample_EnclaveEndpointResource.cs | 181 +++ ...ample_EnclaveEndpointResourceCollection.cs | 213 ++++ .../Samples/Sample_EnclaveResource.cs | 202 +++ .../Sample_EnclaveResourceCollection.cs | 240 ++++ .../Sample_SubscriptionResourceExtensions.cs | 240 ++++ .../Samples/Sample_TransitHubResource.cs | 128 ++ .../Sample_TransitHubResourceCollection.cs | 215 ++++ .../Samples/Sample_WorkloadResource.cs | 117 ++ .../Sample_WorkloadResourceCollection.cs | 207 ++++ .../tests/Scenario/CommunityScenarioTests.cs | 97 ++ .../VirtualEnclavesManagementTestBase.cs | 43 + ...irtualEnclavesManagementTestEnvironment.cs | 11 + .../tsp-location.yaml | 3 + sdk/virtualenclaves/ci.mgmt.yml | 24 + 245 files changed, 44092 insertions(+) create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/Azure.ResourceManager.VirtualEnclaves.sln create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/CHANGELOG.md create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/Directory.Build.props create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/README.md create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/assets.json create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Azure.ResourceManager.VirtualEnclaves.csproj create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResource.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceData.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceData.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ArmVirtualEnclavesModelFactory.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResource.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceData.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceData.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResource.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceData.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceData.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResource.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceData.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceData.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResource.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceData.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceData.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResource.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceData.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceData.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesArmClient.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesResourceGroupResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesSubscriptionResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/VirtualEnclavesExtensions.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Argument.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ChangeTrackingList.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ModelSerializationExtensions.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Optional.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Utf8JsonRequestContent.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/ApprovalActionResponseOperationSource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/ApprovalResourceOperationSource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/CommunityEndpointResourceOperationSource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/CommunityResourceOperationSource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveConnectionResourceOperationSource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveEndpointResourceOperationSource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveResourceOperationSource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/TransitHubResourceOperationSource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/VirtualEnclavesArmOperation.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/VirtualEnclavesArmOperationOfT.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/WorkloadResourceOperationSource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ActionPerformed.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionContent.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionContent.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionRequestApprovalStatus.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionResponse.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionResponse.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequest.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequest.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequestApprovalStatus.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequestResourceRequestAction.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequest.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequest.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequestResourceRequestAction.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPatchProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPatchProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPolicy.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourceListResult.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourceListResult.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourcePatch.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourcePatch.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettings.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettings.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettingsPatchProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettingsPatchProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalStatus.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Approver.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Approver.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/AzureResourceManagerVirtualEnclavesContext.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityContent.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityContent.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityResponse.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityResponse.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointDestinationRule.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointDestinationRule.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointPatchProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointPatchProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProtocol.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourceListResult.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourceListResult.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourcePatch.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourcePatch.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPatchProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPatchProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPropertiesPolicyOverride.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourceListResult.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourceListResult.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourcePatch.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourcePatch.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/DestinationType.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/DiagnosticDestination.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveAddressSpacesModel.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveAddressSpacesModel.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionPatchProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionPatchProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourceListResult.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourceListResult.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourcePatch.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourcePatch.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionState.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsModel.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsModel.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsPatchModel.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsPatchModel.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointDestinationRule.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointDestinationRule.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointPatchProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointPatchProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProtocol.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourceListResult.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourceListResult.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourcePatch.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourcePatch.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourceListResult.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourceListResult.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourcePatch.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourcePatch.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveVirtualNetworkModel.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveVirtualNetworkModel.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/FirewallSKU.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItem.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItem.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemEnforcement.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemOption.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemPolicyAction.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModel.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModel.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModelJustification.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModelMode.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationPatchModel.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationPatchModel.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ManagedOnBehalfOfConfiguration.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ManagedOnBehalfOfConfiguration.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MandatoryApprover.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MandatoryApprover.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Principal.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Principal.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/PrincipalType.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ProvisioningState.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadata.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadata.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadataUpdatableProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadataUpdatableProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RoleAssignmentItem.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RoleAssignmentItem.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ServiceIdentifier.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/SubnetConfiguration.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/SubnetConfiguration.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubPatchProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubPatchProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourceListResult.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourceListResult.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourcePatch.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourcePatch.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubState.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOption.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOption.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionParams.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionParams.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionType.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclavePatchProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclavePatchProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclaveProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclaveProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadPatchProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadPatchProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadProperties.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadProperties.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourceListResult.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourceListResult.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourcePatch.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourcePatch.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ProviderConstants.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/ApprovalRestOperations.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/CommunityEndpointsRestOperations.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/CommunityRestOperations.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/EnclaveConnectionRestOperations.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/EnclaveEndpointsRestOperations.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/TransitHubRestOperations.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/VirtualEnclaveRestOperations.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/WorkloadRestOperations.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResource.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceData.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceData.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResource.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceData.Serialization.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceData.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Properties/AssemblyInfo.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Azure.ResourceManager.VirtualEnclaves.Tests.csproj create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_ApprovalResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_ApprovalResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityEndpointResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityEndpointResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveConnectionResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveConnectionResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveEndpointResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveEndpointResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_TransitHubResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_TransitHubResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_WorkloadResource.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_WorkloadResourceCollection.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Scenario/CommunityScenarioTests.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/VirtualEnclavesManagementTestBase.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/VirtualEnclavesManagementTestEnvironment.cs create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tsp-location.yaml create mode 100644 sdk/virtualenclaves/ci.mgmt.yml diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/Azure.ResourceManager.VirtualEnclaves.sln b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/Azure.ResourceManager.VirtualEnclaves.sln new file mode 100644 index 000000000000..37aa9333cde9 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/Azure.ResourceManager.VirtualEnclaves.sln @@ -0,0 +1,65 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30309.148 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{7DC62A36-7488-49E0-98B0-BCA292B9AA9B}") = "Azure.ResourceManager.VirtualEnclaves", "src\Azure.ResourceManager.VirtualEnclaves.csproj", "{673B38FB-4D42-43E4-BF91-3413C03BCD28}" +EndProject +Project("{7DC62A36-7488-49E0-98B0-BCA292B9AA9B}") = "Azure.ResourceManager.VirtualEnclaves.Tests", "tests\Azure.ResourceManager.VirtualEnclaves.Tests.csproj", "{C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}" +EndProject +Project("{7DC62A36-7488-49E0-98B0-BCA292B9AA9B}") = "Azure.ResourceManager.VirtualEnclaves.Samples", "samples\Azure.ResourceManager.VirtualEnclaves.Samples.csproj", "{B21B4156-A1F9-47C2-8960-A4F4644857C1}" +EndProject +Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7B5F25F2-D050-4B7C-8816-38873D77FE09} + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Debug|Any CPU.Build.0 = Debug|Any CPU + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Debug|x64.ActiveCfg = Debug|Any CPU + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Debug|x64.Build.0 = Debug|Any CPU + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Debug|x86.ActiveCfg = Debug|Any CPU + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Debug|x86.Build.0 = Debug|Any CPU + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Release|Any CPU.ActiveCfg = Release|Any CPU + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Release|Any CPU.Build.0 = Release|Any CPU + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Release|x64.ActiveCfg = Release|Any CPU + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Release|x64.Build.0 = Release|Any CPU + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Release|x86.ActiveCfg = Release|Any CPU + {673B38FB-4D42-43E4-BF91-3413C03BCD28}.Release|x86.Build.0 = Release|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Debug|x64.ActiveCfg = Debug|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Debug|x64.Build.0 = Debug|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Debug|x86.ActiveCfg = Debug|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Debug|x86.Build.0 = Debug|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Release|Any CPU.Build.0 = Release|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Release|x64.ActiveCfg = Release|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Release|x64.Build.0 = Release|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Release|x86.ActiveCfg = Release|Any CPU + {C7DAA011-2AF0-453B-B88D-D1C9C6FF5222}.Release|x86.Build.0 = Release|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Debug|x64.ActiveCfg = Debug|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Debug|x64.Build.0 = Debug|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Debug|x86.ActiveCfg = Debug|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Debug|x86.Build.0 = Debug|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Release|Any CPU.Build.0 = Release|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Release|x64.ActiveCfg = Release|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Release|x64.Build.0 = Release|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Release|x86.ActiveCfg = Release|Any CPU + {B21B4156-A1F9-47C2-8960-A4F4644857C1}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/CHANGELOG.md b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/CHANGELOG.md new file mode 100644 index 000000000000..1a85987a15b9 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/CHANGELOG.md @@ -0,0 +1,19 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + + + +### Features Added + +This package follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +This package is a Public Preview version, so expect incompatible changes in subsequent releases as we improve the product. To provide feedback, submit an issue in our [Azure SDK for .NET GitHub repo](https://github.com/Azure/azure-sdk-for-net/issues). + +> NOTE: For more information about unified authentication, please refer to [Microsoft Azure Identity documentation for .NET](https://docs.microsoft.com//dotnet/api/overview/azure/identity-readme?view=azure-dotnet). \ No newline at end of file diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/Directory.Build.props b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/Directory.Build.props new file mode 100644 index 000000000000..1a9611bd4924 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/README.md b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/README.md new file mode 100644 index 000000000000..383f27c07c85 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure VirtualEnclaves management client library for .NET + +**[Describe the service briefly first.]** + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Microsoft Azure VirtualEnclaves management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.VirtualEnclaves --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://docs.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ \ No newline at end of file diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/assets.json b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/assets.json new file mode 100644 index 000000000000..61a40753d2df --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/virtualenclaves/Azure.ResourceManager.VirtualEnclaves", + "Tag": "" +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj new file mode 100644 index 000000000000..9a8a60e50745 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Azure.ResourceManager.VirtualEnclaves.csproj b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Azure.ResourceManager.VirtualEnclaves.csproj new file mode 100644 index 000000000000..a2d2bfb775c7 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Azure.ResourceManager.VirtualEnclaves.csproj @@ -0,0 +1,9 @@ + + + 1.0.0-beta.1 + Azure.ResourceManager.VirtualEnclaves + Azure Resource Manager client SDK for Azure resource provider VirtualEnclaves. + azure;management;arm;resource manager;virtualenclaves + AZC0030,AZC0012,AZC0034 + + diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResource.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResource.Serialization.cs new file mode 100644 index 000000000000..3e1615a05936 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResource.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class ApprovalResource : IJsonModel + { + private static ApprovalResourceData s_dataDeserializationInstance; + private static ApprovalResourceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + ApprovalResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + ApprovalResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResource.cs new file mode 100644 index 000000000000..3fb190d4bdfc --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResource.cs @@ -0,0 +1,438 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A Class representing an ApprovalResource along with the instance operations that can be performed on it. + /// If you have a you can construct an + /// from an instance of using the GetApprovalResource method. + /// Otherwise you can get one from its parent resource using the GetApprovalResource method. + /// + public partial class ApprovalResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The resourceUri. + /// The approvalName. + public static ResourceIdentifier CreateResourceIdentifier(string resourceUri, string approvalName) + { + var resourceId = $"{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _approvalResourceApprovalClientDiagnostics; + private readonly ApprovalRestOperations _approvalResourceApprovalRestClient; + private readonly ApprovalResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Mission/approvals"; + + /// Initializes a new instance of the class for mocking. + public ApprovalResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ApprovalResource(ArmClient client, ApprovalResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ApprovalResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _approvalResourceApprovalClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string approvalResourceApprovalApiVersion); + _approvalResourceApprovalRestClient = new ApprovalRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, approvalResourceApprovalApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual ApprovalResourceData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResource.Get"); + scope.Start(); + try + { + var response = await _approvalResourceApprovalRestClient.GetAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ApprovalResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResource.Get"); + scope.Start(); + try + { + var response = _approvalResourceApprovalRestClient.Get(Id.Parent, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ApprovalResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResource.Delete"); + scope.Start(); + try + { + var response = await _approvalResourceApprovalRestClient.DeleteAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(_approvalResourceApprovalClientDiagnostics, Pipeline, _approvalResourceApprovalRestClient.CreateDeleteRequest(Id.Parent, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResource.Delete"); + scope.Start(); + try + { + var response = _approvalResourceApprovalRestClient.Delete(Id.Parent, Id.Name, cancellationToken); + var operation = new VirtualEnclavesArmOperation(_approvalResourceApprovalClientDiagnostics, Pipeline, _approvalResourceApprovalRestClient.CreateDeleteRequest(Id.Parent, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ApprovalResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResource.Update"); + scope.Start(); + try + { + var response = await _approvalResourceApprovalRestClient.UpdateAsync(Id.Parent, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new ApprovalResourceOperationSource(Client), _approvalResourceApprovalClientDiagnostics, Pipeline, _approvalResourceApprovalRestClient.CreateUpdateRequest(Id.Parent, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ApprovalResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResource.Update"); + scope.Start(); + try + { + var response = _approvalResourceApprovalRestClient.Update(Id.Parent, Id.Name, patch, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new ApprovalResourceOperationSource(Client), _approvalResourceApprovalClientDiagnostics, Pipeline, _approvalResourceApprovalRestClient.CreateUpdateRequest(Id.Parent, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Upon receiving approval or rejection from approver, this facilitates actions on approval resource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName}/notifyInitiator + /// + /// + /// Operation Id + /// Approval_NotifyInitiator + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> NotifyInitiatorAsync(WaitUntil waitUntil, ApprovalActionContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResource.NotifyInitiator"); + scope.Start(); + try + { + var response = await _approvalResourceApprovalRestClient.NotifyInitiatorAsync(Id.Parent, Id.Name, content, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _approvalResourceApprovalClientDiagnostics, Pipeline, _approvalResourceApprovalRestClient.CreateNotifyInitiatorRequest(Id.Parent, Id.Name, content).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Upon receiving approval or rejection from approver, this facilitates actions on approval resource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName}/notifyInitiator + /// + /// + /// Operation Id + /// Approval_NotifyInitiator + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation NotifyInitiator(WaitUntil waitUntil, ApprovalActionContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResource.NotifyInitiator"); + scope.Start(); + try + { + var response = _approvalResourceApprovalRestClient.NotifyInitiator(Id.Parent, Id.Name, content, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _approvalResourceApprovalClientDiagnostics, Pipeline, _approvalResourceApprovalRestClient.CreateNotifyInitiatorRequest(Id.Parent, Id.Name, content).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceCollection.cs new file mode 100644 index 000000000000..2e27eafe801d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceCollection.cs @@ -0,0 +1,483 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get an instance call the GetApprovalResources method from an instance of . + /// + public partial class ApprovalResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _approvalResourceApprovalClientDiagnostics; + private readonly ApprovalRestOperations _approvalResourceApprovalRestClient; + + /// Initializes a new instance of the class for mocking. + protected ApprovalResourceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal ApprovalResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _approvalResourceApprovalClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", ApprovalResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ApprovalResource.ResourceType, out string approvalResourceApprovalApiVersion); + _approvalResourceApprovalRestClient = new ApprovalRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, approvalResourceApprovalApiVersion); + } + + /// + /// Create a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the approvals resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string approvalName, ApprovalResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _approvalResourceApprovalRestClient.CreateOrUpdateAsync(Id, approvalName, data, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new ApprovalResourceOperationSource(Client), _approvalResourceApprovalClientDiagnostics, Pipeline, _approvalResourceApprovalRestClient.CreateCreateOrUpdateRequest(Id, approvalName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the approvals resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string approvalName, ApprovalResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _approvalResourceApprovalRestClient.CreateOrUpdate(Id, approvalName, data, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new ApprovalResourceOperationSource(Client), _approvalResourceApprovalClientDiagnostics, Pipeline, _approvalResourceApprovalRestClient.CreateCreateOrUpdateRequest(Id, approvalName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the approvals resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResourceCollection.Get"); + scope.Start(); + try + { + var response = await _approvalResourceApprovalRestClient.GetAsync(Id, approvalName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ApprovalResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the approvals resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResourceCollection.Get"); + scope.Start(); + try + { + var response = _approvalResourceApprovalRestClient.Get(Id, approvalName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ApprovalResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List ApprovalResource resources by parent + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals + /// + /// + /// Operation Id + /// ApprovalResource_ListByParent + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _approvalResourceApprovalRestClient.CreateListByParentRequest(Id); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _approvalResourceApprovalRestClient.CreateListByParentNextPageRequest(nextLink, Id); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ApprovalResource(Client, ApprovalResourceData.DeserializeApprovalResourceData(e)), _approvalResourceApprovalClientDiagnostics, Pipeline, "ApprovalResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List ApprovalResource resources by parent + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals + /// + /// + /// Operation Id + /// ApprovalResource_ListByParent + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _approvalResourceApprovalRestClient.CreateListByParentRequest(Id); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _approvalResourceApprovalRestClient.CreateListByParentNextPageRequest(nextLink, Id); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ApprovalResource(Client, ApprovalResourceData.DeserializeApprovalResourceData(e)), _approvalResourceApprovalClientDiagnostics, Pipeline, "ApprovalResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the approvals resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _approvalResourceApprovalRestClient.GetAsync(Id, approvalName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the approvals resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResourceCollection.Exists"); + scope.Start(); + try + { + var response = _approvalResourceApprovalRestClient.Get(Id, approvalName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the approvals resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _approvalResourceApprovalRestClient.GetAsync(Id, approvalName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ApprovalResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the approvals resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + + using var scope = _approvalResourceApprovalClientDiagnostics.CreateScope("ApprovalResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _approvalResourceApprovalRestClient.Get(Id, approvalName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ApprovalResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceData.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceData.Serialization.cs new file mode 100644 index 000000000000..0a59761c5862 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceData.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class ApprovalResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + ApprovalResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApprovalResourceData(document.RootElement, options); + } + + internal static ApprovalResourceData DeserializeApprovalResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ApprovalProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ApprovalProperties.DeserializeApprovalProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApprovalResourceData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(ApprovalResourceData)} does not support writing '{options.Format}' format."); + } + } + + ApprovalResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApprovalResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApprovalResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceData.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceData.cs new file mode 100644 index 000000000000..f769fb656fe8 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ApprovalResourceData.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing the ApprovalResource data model. + /// Approval Model Resource + /// + public partial class ApprovalResourceData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ApprovalResourceData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal ApprovalResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ApprovalProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public ApprovalProperties Properties { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ArmVirtualEnclavesModelFactory.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ArmVirtualEnclavesModelFactory.cs new file mode 100644 index 000000000000..bd87cb39386d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ArmVirtualEnclavesModelFactory.cs @@ -0,0 +1,562 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Model factory for models. + public static partial class ArmVirtualEnclavesModelFactory + { + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static WorkloadResourceData WorkloadResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, WorkloadProperties properties = null) + { + tags ??= new Dictionary(); + + return new WorkloadResourceData( + id, + name, + resourceType, + systemData, + tags, + location, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Provisioning State. + /// List of resource group ids. + /// Managed On Behalf Of Configuration. + /// A new instance for mocking. + public static WorkloadProperties WorkloadProperties(ProvisioningState? provisioningState = null, IEnumerable resourceGroupCollection = null, IEnumerable managedOnBehalfOfMoboBrokerResources = null) + { + resourceGroupCollection ??= new List(); + managedOnBehalfOfMoboBrokerResources ??= new List(); + + return new WorkloadProperties(provisioningState, resourceGroupCollection?.ToList(), managedOnBehalfOfMoboBrokerResources != null ? new ManagedOnBehalfOfConfiguration(managedOnBehalfOfMoboBrokerResources?.ToList(), serializedAdditionalRawData: null) : null, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// The managed service identities assigned to this resource. + /// A new instance for mocking. + public static EnclaveResourceData EnclaveResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, VirtualEnclaveProperties properties = null, ManagedServiceIdentity identity = null) + { + tags ??= new Dictionary(); + + return new EnclaveResourceData( + id, + name, + resourceType, + systemData, + tags, + location, + properties, + identity, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Provisioning State. + /// Virtual Network. + /// Enclave Address Spaces. + /// Community Resource Id. + /// List of resource ids created by Virtual Enclave. + /// Managed resource group name. + /// Managed On Behalf Of Configuration. + /// Deploy Bastion service (True or False). + /// Enclave role assignments. + /// Workload role assignments. + /// Enclave specific policies. + /// Enclave default settings. + /// Maintenance Mode configuration. + /// A new instance for mocking. + public static VirtualEnclaveProperties VirtualEnclaveProperties(ProvisioningState? provisioningState = null, EnclaveVirtualNetworkModel enclaveVirtualNetwork = null, EnclaveAddressSpacesModel enclaveAddressSpaces = null, ResourceIdentifier communityResourceId = null, IEnumerable resourceCollection = null, string managedResourceGroupName = null, IEnumerable managedOnBehalfOfMoboBrokerResources = null, bool? bastionEnabled = null, IEnumerable enclaveRoleAssignments = null, IEnumerable workloadRoleAssignments = null, IEnumerable governedServiceList = null, EnclaveDefaultSettingsModel enclaveDefaultSettings = null, MaintenanceModeConfigurationModel maintenanceModeConfiguration = null) + { + resourceCollection ??= new List(); + managedOnBehalfOfMoboBrokerResources ??= new List(); + enclaveRoleAssignments ??= new List(); + workloadRoleAssignments ??= new List(); + governedServiceList ??= new List(); + + return new VirtualEnclaveProperties( + provisioningState, + enclaveVirtualNetwork, + enclaveAddressSpaces, + communityResourceId, + resourceCollection?.ToList(), + managedResourceGroupName, + managedOnBehalfOfMoboBrokerResources != null ? new ManagedOnBehalfOfConfiguration(managedOnBehalfOfMoboBrokerResources?.ToList(), serializedAdditionalRawData: null) : null, + bastionEnabled, + enclaveRoleAssignments?.ToList(), + workloadRoleAssignments?.ToList(), + governedServiceList?.ToList(), + enclaveDefaultSettings, + maintenanceModeConfiguration, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Subnet name. + /// Subnet Resource ID. + /// Network prefix size. + /// Subnet delegation. + /// Address prefix. + /// Network security group ID. + /// A new instance for mocking. + public static SubnetConfiguration SubnetConfiguration(string subnetName = null, ResourceIdentifier subnetResourceId = null, int networkPrefixSize = default, string subnetDelegation = null, string addressPrefix = null, ResourceIdentifier networkSecurityGroupResourceId = null) + { + return new SubnetConfiguration( + subnetName, + subnetResourceId, + networkPrefixSize, + subnetDelegation, + addressPrefix, + networkSecurityGroupResourceId, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Enclave Address Space. + /// Managed Address Space. + /// A new instance for mocking. + public static EnclaveAddressSpacesModel EnclaveAddressSpacesModel(string enclaveAddressSpace = null, string managedAddressSpace = null) + { + return new EnclaveAddressSpacesModel(enclaveAddressSpace, managedAddressSpace, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Service ID. + /// Service name. + /// Governance option for this service (Allow, Deny, ExceptionOnly, or NotApplicable). + /// Initiative enforcement (Enabled or Disabled). + /// Enforcement mode for policy. AuditOnly, Enforce, or None. + /// Initiatives associated with this service. + /// A new instance for mocking. + public static GovernedServiceItem GovernedServiceItem(ServiceIdentifier serviceId = default, string serviceName = null, GovernedServiceItemOption? option = null, GovernedServiceItemEnforcement? enforcement = null, GovernedServiceItemPolicyAction? policyAction = null, IEnumerable initiatives = null) + { + initiatives ??= new List(); + + return new GovernedServiceItem( + serviceId, + serviceName, + option, + enforcement, + policyAction, + initiatives?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Key Vault Resource Id. + /// Storage Account Resource Id. + /// Log Analytics Resource Ids. + /// Diagnostic Destination. + /// A new instance for mocking. + public static EnclaveDefaultSettingsModel EnclaveDefaultSettingsModel(ResourceIdentifier keyVaultResourceId = null, ResourceIdentifier storageAccountResourceId = null, IEnumerable logAnalyticsResourceIdCollection = null, DiagnosticDestination? diagnosticDestination = null) + { + logAnalyticsResourceIdCollection ??= new List(); + + return new EnclaveDefaultSettingsModel(keyVaultResourceId, storageAccountResourceId, logAnalyticsResourceIdCollection?.ToList(), diagnosticDestination, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Virtual Network. + /// Deploy Bastion service (True or False). + /// Enclave role assignments. + /// Workload role assignments. + /// Enclave specific policies. + /// Enclave default settings. + /// Maintenance Mode configuration. + /// A new instance for mocking. + public static VirtualEnclavePatchProperties VirtualEnclavePatchProperties(EnclaveVirtualNetworkModel enclaveVirtualNetwork = null, bool? bastionEnabled = null, IEnumerable enclaveRoleAssignments = null, IEnumerable workloadRoleAssignments = null, IEnumerable governedServiceList = null, DiagnosticDestination? enclaveDefaultDiagnosticDestination = null, MaintenanceModeConfigurationPatchModel maintenanceModeConfiguration = null) + { + enclaveRoleAssignments ??= new List(); + workloadRoleAssignments ??= new List(); + governedServiceList ??= new List(); + + return new VirtualEnclavePatchProperties( + enclaveVirtualNetwork, + bastionEnabled, + enclaveRoleAssignments?.ToList(), + workloadRoleAssignments?.ToList(), + governedServiceList?.ToList(), + enclaveDefaultDiagnosticDestination != null ? new EnclaveDefaultSettingsPatchModel(enclaveDefaultDiagnosticDestination, serializedAdditionalRawData: null) : null, + maintenanceModeConfiguration, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Current mode of Maintenance Mode Configuration. + /// The user, group or service principal object affected by Maintenance Mode. + /// Justification for entering or exiting Maintenance Mode. + /// A new instance for mocking. + public static MaintenanceModeConfigurationPatchModel MaintenanceModeConfigurationPatchModel(MaintenanceModeConfigurationModelMode mode = default, IEnumerable principals = null, MaintenanceModeConfigurationModelJustification? justification = null) + { + principals ??= new List(); + + return new MaintenanceModeConfigurationPatchModel(mode, principals?.ToList(), justification, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Resource request action indicating action which needed to be performed upon calling approval-callback post action. + /// Approval status indicating 'Approved' or 'Rejected'. + /// Payload requested by client upon approval action. + /// A new instance for mocking. + public static ApprovalCallbackRequest ApprovalCallbackRequest(ApprovalCallbackRequestResourceRequestAction resourceRequestAction = default, ApprovalCallbackRequestApprovalStatus approvalStatus = default, string approvalCallbackPayload = null) + { + return new ApprovalCallbackRequest(resourceRequestAction, approvalStatus, approvalCallbackPayload, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Confirmation message indicating the result of the operation. + /// A new instance for mocking. + public static ApprovalActionResponse ApprovalActionResponse(string message = null) + { + return new ApprovalActionResponse(message, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// The managed service identities assigned to this resource. + /// A new instance for mocking. + public static CommunityResourceData CommunityResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, CommunityProperties properties = null, ManagedServiceIdentity identity = null) + { + tags ??= new Dictionary(); + + return new CommunityResourceData( + id, + name, + resourceType, + systemData, + tags, + location, + properties, + identity, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Address Space. + /// DNS Servers. + /// Provisioning State. + /// List of resource ids created by communities. + /// Managed resource group name. + /// Managed On Behalf Of Configuration. + /// List of services governed by a community. + /// Policy override setting for the community. Specifies whether to apply enclave-specific policies or disable policy enforcement. + /// Community role assignments. + /// SKU of the community's Azure Firewall (Basic, Standard, Premium). Standard is the default. + /// Approval requirements for various actions on the community's resources. + /// Maintenance Mode configuration. + /// A new instance for mocking. + public static CommunityProperties CommunityProperties(string addressSpace = null, IEnumerable dnsServers = null, ProvisioningState? provisioningState = null, IEnumerable resourceCollection = null, string managedResourceGroupName = null, IEnumerable managedOnBehalfOfMoboBrokerResources = null, IEnumerable governedServiceList = null, CommunityPropertiesPolicyOverride? policyOverride = null, IEnumerable communityRoleAssignments = null, FirewallSKU? firewallSku = null, ApprovalSettings approvalSettings = null, MaintenanceModeConfigurationModel maintenanceModeConfiguration = null) + { + dnsServers ??= new List(); + resourceCollection ??= new List(); + managedOnBehalfOfMoboBrokerResources ??= new List(); + governedServiceList ??= new List(); + communityRoleAssignments ??= new List(); + + return new CommunityProperties( + addressSpace, + dnsServers?.ToList(), + provisioningState, + resourceCollection?.ToList(), + managedResourceGroupName, + managedOnBehalfOfMoboBrokerResources != null ? new ManagedOnBehalfOfConfiguration(managedOnBehalfOfMoboBrokerResources?.ToList(), serializedAdditionalRawData: null) : null, + governedServiceList?.ToList(), + policyOverride, + communityRoleAssignments?.ToList(), + firewallSku, + approvalSettings, + maintenanceModeConfiguration, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Boolean representing whether the address space is available. + /// A new instance for mocking. + public static CheckAddressSpaceAvailabilityResponse CheckAddressSpaceAvailabilityResponse(bool value = default) + { + return new CheckAddressSpaceAvailabilityResponse(value, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static TransitHubResourceData TransitHubResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, TransitHubProperties properties = null) + { + tags ??= new Dictionary(); + + return new TransitHubResourceData( + id, + name, + resourceType, + systemData, + tags, + location, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// The state of the transitHub. + /// The TransitOption of the transitHub. + /// List of resource ids modified by transitHubs. + /// A new instance for mocking. + public static TransitHubProperties TransitHubProperties(ProvisioningState? provisioningState = null, TransitHubState? state = null, TransitOption transitOption = null, IEnumerable resourceCollection = null) + { + resourceCollection ??= new List(); + + return new TransitHubProperties(provisioningState, state, transitOption, resourceCollection?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static EnclaveConnectionResourceData EnclaveConnectionResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, EnclaveConnectionProperties properties = null) + { + tags ??= new Dictionary(); + + return new EnclaveConnectionResourceData( + id, + name, + resourceType, + systemData, + tags, + location, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The state of the enclaveConnection. + /// Community Resource Id. + /// Source Resource Id. + /// Source CIDR. + /// Destination Endpoint Resource Id. + /// Provisioning State. + /// List of resource ids modified by enclave Connections. + /// A new instance for mocking. + public static EnclaveConnectionProperties EnclaveConnectionProperties(EnclaveConnectionState? state = null, ResourceIdentifier communityResourceId = null, ResourceIdentifier sourceResourceId = null, string sourceCidr = null, ResourceIdentifier destinationEndpointId = null, ProvisioningState? provisioningState = null, IEnumerable resourceCollection = null) + { + resourceCollection ??= new List(); + + return new EnclaveConnectionProperties( + state, + communityResourceId, + sourceResourceId, + sourceCidr, + destinationEndpointId, + provisioningState, + resourceCollection?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static EnclaveEndpointResourceData EnclaveEndpointResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, EnclaveEndpointProperties properties = null) + { + tags ??= new Dictionary(); + + return new EnclaveEndpointResourceData( + id, + name, + resourceType, + systemData, + tags, + location, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Enclave Endpoint Rule Collection. + /// List of resource ids created by community endpoint. + /// Provisioning State. + /// A new instance for mocking. + public static EnclaveEndpointProperties EnclaveEndpointProperties(IEnumerable ruleCollection = null, IEnumerable resourceCollection = null, ProvisioningState? provisioningState = null) + { + ruleCollection ??= new List(); + resourceCollection ??= new List(); + + return new EnclaveEndpointProperties(ruleCollection?.ToList(), resourceCollection?.ToList(), provisioningState, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static CommunityEndpointResourceData CommunityEndpointResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, CommunityEndpointProperties properties = null) + { + tags ??= new Dictionary(); + + return new CommunityEndpointResourceData( + id, + name, + resourceType, + systemData, + tags, + location, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Community Endpoint Rule Collection. + /// List of resource ids created by community endpoint. + /// Provisioning State. + /// A new instance for mocking. + public static CommunityEndpointProperties CommunityEndpointProperties(IEnumerable ruleCollection = null, IEnumerable resourceCollection = null, ProvisioningState? provisioningState = null) + { + ruleCollection ??= new List(); + resourceCollection ??= new List(); + + return new CommunityEndpointProperties(ruleCollection?.ToList(), resourceCollection?.ToList(), provisioningState, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static ApprovalResourceData ApprovalResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ApprovalProperties properties = null) + { + return new ApprovalResourceData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of for mocking. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + /// A new instance for mocking. + public static ApprovalResource ApprovalResource(ArmClient client = null, ApprovalResourceData data = null) + { + return new ApprovalResource(client, data); + } + + /// Initializes a new instance of . + /// Provisioning State. + /// Parameter for optimizing query results. + /// Parameter for optimizing query results. + /// List of approvers for the approval request. + /// Ticket ID for the approval request. + /// Approval request creation time. + /// Approval request state change time, time at which approval request state changed from pending to approved or rejected. + /// Request metadata for the approval request. + /// A new instance for mocking. + public static ApprovalProperties ApprovalProperties(ProvisioningState? provisioningState = null, ResourceIdentifier parentResourceId = null, ResourceIdentifier grandparentResourceId = null, IEnumerable approvers = null, string ticketId = null, DateTimeOffset? createdOn = null, DateTimeOffset? stateChangedOn = null, RequestMetadata requestMetadata = null) + { + approvers ??= new List(); + + return new ApprovalProperties( + provisioningState, + parentResourceId, + grandparentResourceId, + approvers?.ToList(), + ticketId, + createdOn, + stateChangedOn, + requestMetadata, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Parameter for optimizing query results. + /// Parameter for optimizing query results. + /// List of approvers for the approval request. + /// Ticket ID for the approval request. + /// Approval request creation time. + /// Approval request state change time, time at which approval request state changed from pending to approved or rejected. + /// Request metadata for the approval request. + /// A new instance for mocking. + public static ApprovalPatchProperties ApprovalPatchProperties(ResourceIdentifier parentResourceId = null, ResourceIdentifier grandparentResourceId = null, IEnumerable approvers = null, string ticketId = null, DateTimeOffset? createdOn = null, DateTimeOffset? stateChangedOn = null, RequestMetadataUpdatableProperties requestMetadata = null) + { + approvers ??= new List(); + + return new ApprovalPatchProperties( + parentResourceId, + grandparentResourceId, + approvers?.ToList(), + ticketId, + createdOn, + stateChangedOn, + requestMetadata, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Resource Action of the item being approved or declined. + /// Route name for the approval callback. + /// Payload to be sent upon any action on approval request. + /// Status of the approval. Uses ApprovalStatus enum. + /// A new instance for mocking. + public static RequestMetadataUpdatableProperties RequestMetadataUpdatableProperties(string resourceAction = null, string approvalCallbackRoute = null, string approvalCallbackPayload = null, ApprovalStatus? approvalStatus = null) + { + return new RequestMetadataUpdatableProperties(resourceAction, approvalCallbackRoute, approvalCallbackPayload, approvalStatus, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResource.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResource.Serialization.cs new file mode 100644 index 000000000000..555c21173fec --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResource.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class CommunityEndpointResource : IJsonModel + { + private static CommunityEndpointResourceData s_dataDeserializationInstance; + private static CommunityEndpointResourceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + CommunityEndpointResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + CommunityEndpointResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResource.cs new file mode 100644 index 000000000000..44fc9fa80a25 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResource.cs @@ -0,0 +1,891 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A Class representing a CommunityEndpointResource along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetCommunityEndpointResource method. + /// Otherwise you can get one from its parent resource using the GetCommunityEndpointResource method. + /// + public partial class CommunityEndpointResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The communityName. + /// The communityEndpointName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _communityEndpointResourceCommunityEndpointsClientDiagnostics; + private readonly CommunityEndpointsRestOperations _communityEndpointResourceCommunityEndpointsRestClient; + private readonly CommunityEndpointResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Mission/communities/communityEndpoints"; + + /// Initializes a new instance of the class for mocking. + public CommunityEndpointResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal CommunityEndpointResource(ArmClient client, CommunityEndpointResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal CommunityEndpointResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _communityEndpointResourceCommunityEndpointsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string communityEndpointResourceCommunityEndpointsApiVersion); + _communityEndpointResourceCommunityEndpointsRestClient = new CommunityEndpointsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, communityEndpointResourceCommunityEndpointsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual CommunityEndpointResourceData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.Get"); + scope.Start(); + try + { + var response = await _communityEndpointResourceCommunityEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunityEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.Get"); + scope.Start(); + try + { + var response = _communityEndpointResourceCommunityEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunityEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.Delete"); + scope.Start(); + try + { + var response = await _communityEndpointResourceCommunityEndpointsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(_communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, _communityEndpointResourceCommunityEndpointsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.Delete"); + scope.Start(); + try + { + var response = _communityEndpointResourceCommunityEndpointsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new VirtualEnclavesArmOperation(_communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, _communityEndpointResourceCommunityEndpointsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, CommunityEndpointResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.Update"); + scope.Start(); + try + { + var response = await _communityEndpointResourceCommunityEndpointsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new CommunityEndpointResourceOperationSource(Client), _communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, _communityEndpointResourceCommunityEndpointsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, CommunityEndpointResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.Update"); + scope.Start(); + try + { + var response = _communityEndpointResourceCommunityEndpointsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new CommunityEndpointResourceOperationSource(Client), _communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, _communityEndpointResourceCommunityEndpointsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName}/handleApprovalCreation + /// + /// + /// Operation Id + /// CommunityEndpoints_HandleApprovalCreation + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> HandleApprovalCreationAsync(WaitUntil waitUntil, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.HandleApprovalCreation"); + scope.Start(); + try + { + var response = await _communityEndpointResourceCommunityEndpointsRestClient.HandleApprovalCreationAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, _communityEndpointResourceCommunityEndpointsRestClient.CreateHandleApprovalCreationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName}/handleApprovalCreation + /// + /// + /// Operation Id + /// CommunityEndpoints_HandleApprovalCreation + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation HandleApprovalCreation(WaitUntil waitUntil, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.HandleApprovalCreation"); + scope.Start(); + try + { + var response = _communityEndpointResourceCommunityEndpointsRestClient.HandleApprovalCreation(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, _communityEndpointResourceCommunityEndpointsRestClient.CreateHandleApprovalCreationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval deletion state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName}/handleApprovalDeletion + /// + /// + /// Operation Id + /// CommunityEndpoints_HandleApprovalDeletion + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> HandleApprovalDeletionAsync(WaitUntil waitUntil, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.HandleApprovalDeletion"); + scope.Start(); + try + { + var response = await _communityEndpointResourceCommunityEndpointsRestClient.HandleApprovalDeletionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, _communityEndpointResourceCommunityEndpointsRestClient.CreateHandleApprovalDeletionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval deletion state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName}/handleApprovalDeletion + /// + /// + /// Operation Id + /// CommunityEndpoints_HandleApprovalDeletion + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation HandleApprovalDeletion(WaitUntil waitUntil, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.HandleApprovalDeletion"); + scope.Start(); + try + { + var response = _communityEndpointResourceCommunityEndpointsRestClient.HandleApprovalDeletion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, _communityEndpointResourceCommunityEndpointsRestClient.CreateHandleApprovalDeletionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _communityEndpointResourceCommunityEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommunityEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CommunityEndpointResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _communityEndpointResourceCommunityEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new CommunityEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CommunityEndpointResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _communityEndpointResourceCommunityEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommunityEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CommunityEndpointResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _communityEndpointResourceCommunityEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new CommunityEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CommunityEndpointResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _communityEndpointResourceCommunityEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommunityEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CommunityEndpointResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _communityEndpointResourceCommunityEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new CommunityEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CommunityEndpointResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceCollection.cs new file mode 100644 index 000000000000..f4b5c8322fb1 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceCollection.cs @@ -0,0 +1,493 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetCommunityEndpointResources method from an instance of . + /// + public partial class CommunityEndpointResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _communityEndpointResourceCommunityEndpointsClientDiagnostics; + private readonly CommunityEndpointsRestOperations _communityEndpointResourceCommunityEndpointsRestClient; + + /// Initializes a new instance of the class for mocking. + protected CommunityEndpointResourceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal CommunityEndpointResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _communityEndpointResourceCommunityEndpointsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", CommunityEndpointResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(CommunityEndpointResource.ResourceType, out string communityEndpointResourceCommunityEndpointsApiVersion); + _communityEndpointResourceCommunityEndpointsRestClient = new CommunityEndpointsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, communityEndpointResourceCommunityEndpointsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CommunityResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CommunityResource.ResourceType), nameof(id)); + } + + /// + /// Create a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Community Endpoint Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string communityEndpointName, CommunityEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _communityEndpointResourceCommunityEndpointsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, communityEndpointName, data, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new CommunityEndpointResourceOperationSource(Client), _communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, _communityEndpointResourceCommunityEndpointsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, communityEndpointName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Community Endpoint Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string communityEndpointName, CommunityEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _communityEndpointResourceCommunityEndpointsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, communityEndpointName, data, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new CommunityEndpointResourceOperationSource(Client), _communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, _communityEndpointResourceCommunityEndpointsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, communityEndpointName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string communityEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResourceCollection.Get"); + scope.Start(); + try + { + var response = await _communityEndpointResourceCommunityEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, communityEndpointName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunityEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string communityEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResourceCollection.Get"); + scope.Start(); + try + { + var response = _communityEndpointResourceCommunityEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, communityEndpointName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunityEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List CommunityEndpointResource resources by CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints + /// + /// + /// Operation Id + /// CommunityEndpointResource_ListByCommunityResource + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _communityEndpointResourceCommunityEndpointsRestClient.CreateListByCommunityResourceRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _communityEndpointResourceCommunityEndpointsRestClient.CreateListByCommunityResourceNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new CommunityEndpointResource(Client, CommunityEndpointResourceData.DeserializeCommunityEndpointResourceData(e)), _communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, "CommunityEndpointResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List CommunityEndpointResource resources by CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints + /// + /// + /// Operation Id + /// CommunityEndpointResource_ListByCommunityResource + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _communityEndpointResourceCommunityEndpointsRestClient.CreateListByCommunityResourceRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _communityEndpointResourceCommunityEndpointsRestClient.CreateListByCommunityResourceNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new CommunityEndpointResource(Client, CommunityEndpointResourceData.DeserializeCommunityEndpointResourceData(e)), _communityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, "CommunityEndpointResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string communityEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _communityEndpointResourceCommunityEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, communityEndpointName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string communityEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResourceCollection.Exists"); + scope.Start(); + try + { + var response = _communityEndpointResourceCommunityEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, communityEndpointName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string communityEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _communityEndpointResourceCommunityEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, communityEndpointName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new CommunityEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string communityEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + + using var scope = _communityEndpointResourceCommunityEndpointsClientDiagnostics.CreateScope("CommunityEndpointResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _communityEndpointResourceCommunityEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, communityEndpointName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new CommunityEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceData.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceData.Serialization.cs new file mode 100644 index 000000000000..8e7f322b1469 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceData.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class CommunityEndpointResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + CommunityEndpointResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommunityEndpointResourceData(document.RootElement, options); + } + + internal static CommunityEndpointResourceData DeserializeCommunityEndpointResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CommunityEndpointProperties properties = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = CommunityEndpointProperties.DeserializeCommunityEndpointProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommunityEndpointResourceData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CommunityEndpointResourceData)} does not support writing '{options.Format}' format."); + } + } + + CommunityEndpointResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCommunityEndpointResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommunityEndpointResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceData.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceData.cs new file mode 100644 index 000000000000..a1493b1adf6a --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityEndpointResourceData.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing the CommunityEndpointResource data model. + /// CommunityEndpoint Model Resource + /// + public partial class CommunityEndpointResourceData : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + public CommunityEndpointResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal CommunityEndpointResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, CommunityEndpointProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CommunityEndpointResourceData() + { + } + + /// The resource-specific properties for this resource. + public CommunityEndpointProperties Properties { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResource.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResource.Serialization.cs new file mode 100644 index 000000000000..9d10d0afc0ea --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResource.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class CommunityResource : IJsonModel + { + private static CommunityResourceData s_dataDeserializationInstance; + private static CommunityResourceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + CommunityResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + CommunityResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResource.cs new file mode 100644 index 000000000000..a5e6e454b471 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResource.cs @@ -0,0 +1,929 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A Class representing a CommunityResource along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetCommunityResource method. + /// Otherwise you can get one from its parent resource using the GetCommunityResource method. + /// + public partial class CommunityResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The communityName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string communityName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _communityResourceCommunityClientDiagnostics; + private readonly CommunityRestOperations _communityResourceCommunityRestClient; + private readonly CommunityResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Mission/communities"; + + /// Initializes a new instance of the class for mocking. + public CommunityResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal CommunityResource(ArmClient client, CommunityResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal CommunityResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _communityResourceCommunityClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string communityResourceCommunityApiVersion); + _communityResourceCommunityRestClient = new CommunityRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, communityResourceCommunityApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual CommunityResourceData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// Gets a collection of TransitHubResources in the CommunityResource. + /// An object representing collection of TransitHubResources and their operations over a TransitHubResource. + public virtual TransitHubResourceCollection GetTransitHubResources() + { + return GetCachedClient(client => new TransitHubResourceCollection(client, Id)); + } + + /// + /// Get a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTransitHubResourceAsync(string transitHubName, CancellationToken cancellationToken = default) + { + return await GetTransitHubResources().GetAsync(transitHubName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTransitHubResource(string transitHubName, CancellationToken cancellationToken = default) + { + return GetTransitHubResources().Get(transitHubName, cancellationToken); + } + + /// Gets a collection of CommunityEndpointResources in the CommunityResource. + /// An object representing collection of CommunityEndpointResources and their operations over a CommunityEndpointResource. + public virtual CommunityEndpointResourceCollection GetCommunityEndpointResources() + { + return GetCachedClient(client => new CommunityEndpointResourceCollection(client, Id)); + } + + /// + /// Get a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetCommunityEndpointResourceAsync(string communityEndpointName, CancellationToken cancellationToken = default) + { + return await GetCommunityEndpointResources().GetAsync(communityEndpointName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a CommunityEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName} + /// + /// + /// Operation Id + /// CommunityEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetCommunityEndpointResource(string communityEndpointName, CancellationToken cancellationToken = default) + { + return GetCommunityEndpointResources().Get(communityEndpointName, cancellationToken); + } + + /// + /// Get a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.Get"); + scope.Start(); + try + { + var response = await _communityResourceCommunityRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunityResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.Get"); + scope.Start(); + try + { + var response = _communityResourceCommunityRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunityResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.Delete"); + scope.Start(); + try + { + var response = await _communityResourceCommunityRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(_communityResourceCommunityClientDiagnostics, Pipeline, _communityResourceCommunityRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.Delete"); + scope.Start(); + try + { + var response = _communityResourceCommunityRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new VirtualEnclavesArmOperation(_communityResourceCommunityClientDiagnostics, Pipeline, _communityResourceCommunityRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, CommunityResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.Update"); + scope.Start(); + try + { + var response = await _communityResourceCommunityRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new CommunityResourceOperationSource(Client), _communityResourceCommunityClientDiagnostics, Pipeline, _communityResourceCommunityRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, CommunityResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.Update"); + scope.Start(); + try + { + var response = _communityResourceCommunityRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new CommunityResourceOperationSource(Client), _communityResourceCommunityClientDiagnostics, Pipeline, _communityResourceCommunityRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks that the IP Address Space to be allocated for this Community is available. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/checkAddressSpaceAvailability + /// + /// + /// Operation Id + /// Community_CheckAddressSpaceAvailability + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Check IP Address Space request body. + /// The cancellation token to use. + /// is null. + public virtual async Task> CheckAddressSpaceAvailabilityAsync(CheckAddressSpaceAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.CheckAddressSpaceAvailability"); + scope.Start(); + try + { + var response = await _communityResourceCommunityRestClient.CheckAddressSpaceAvailabilityAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks that the IP Address Space to be allocated for this Community is available. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/checkAddressSpaceAvailability + /// + /// + /// Operation Id + /// Community_CheckAddressSpaceAvailability + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Check IP Address Space request body. + /// The cancellation token to use. + /// is null. + public virtual Response CheckAddressSpaceAvailability(CheckAddressSpaceAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.CheckAddressSpaceAvailability"); + scope.Start(); + try + { + var response = _communityResourceCommunityRestClient.CheckAddressSpaceAvailability(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _communityResourceCommunityRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommunityResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CommunityResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _communityResourceCommunityRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CommunityResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CommunityResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _communityResourceCommunityRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommunityResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CommunityResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _communityResourceCommunityRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CommunityResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CommunityResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _communityResourceCommunityRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommunityResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CommunityResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _communityResourceCommunityRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CommunityResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CommunityResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceCollection.cs new file mode 100644 index 000000000000..10c75c61bd3d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceCollection.cs @@ -0,0 +1,494 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetCommunityResources method from an instance of . + /// + public partial class CommunityResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _communityResourceCommunityClientDiagnostics; + private readonly CommunityRestOperations _communityResourceCommunityRestClient; + + /// Initializes a new instance of the class for mocking. + protected CommunityResourceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal CommunityResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _communityResourceCommunityClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", CommunityResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(CommunityResource.ResourceType, out string communityResourceCommunityApiVersion); + _communityResourceCommunityRestClient = new CommunityRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, communityResourceCommunityApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + } + + /// + /// Create a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the communityResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string communityName, CommunityResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _communityResourceCommunityRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, communityName, data, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new CommunityResourceOperationSource(Client), _communityResourceCommunityClientDiagnostics, Pipeline, _communityResourceCommunityRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, communityName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the communityResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string communityName, CommunityResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _communityResourceCommunityRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, communityName, data, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new CommunityResourceOperationSource(Client), _communityResourceCommunityClientDiagnostics, Pipeline, _communityResourceCommunityRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, communityName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResourceCollection.Get"); + scope.Start(); + try + { + var response = await _communityResourceCommunityRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, communityName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunityResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResourceCollection.Get"); + scope.Start(); + try + { + var response = _communityResourceCommunityRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, communityName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunityResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List CommunityResource resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities + /// + /// + /// Operation Id + /// CommunityResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _communityResourceCommunityRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _communityResourceCommunityRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new CommunityResource(Client, CommunityResourceData.DeserializeCommunityResourceData(e)), _communityResourceCommunityClientDiagnostics, Pipeline, "CommunityResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List CommunityResource resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities + /// + /// + /// Operation Id + /// CommunityResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _communityResourceCommunityRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _communityResourceCommunityRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new CommunityResource(Client, CommunityResourceData.DeserializeCommunityResourceData(e)), _communityResourceCommunityClientDiagnostics, Pipeline, "CommunityResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _communityResourceCommunityRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, communityName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResourceCollection.Exists"); + scope.Start(); + try + { + var response = _communityResourceCommunityRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, communityName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _communityResourceCommunityRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, communityName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new CommunityResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var scope = _communityResourceCommunityClientDiagnostics.CreateScope("CommunityResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _communityResourceCommunityRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, communityName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new CommunityResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceData.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceData.Serialization.cs new file mode 100644 index 000000000000..c805ae1f8d02 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceData.Serialization.cs @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class CommunityResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireV3Options); + } + } + + CommunityResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommunityResourceData(document.RootElement, options); + } + + internal static CommunityResourceData DeserializeCommunityResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CommunityProperties properties = default; + ManagedServiceIdentity identity = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = CommunityProperties.DeserializeCommunityProperties(property.Value, options); + continue; + } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireV3Options, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommunityResourceData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + identity, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CommunityResourceData)} does not support writing '{options.Format}' format."); + } + } + + CommunityResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCommunityResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommunityResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceData.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceData.cs new file mode 100644 index 000000000000..207366bbcc63 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/CommunityResourceData.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing the CommunityResource data model. + /// Community Model Resource + /// + public partial class CommunityResourceData : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + public CommunityResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// The managed service identities assigned to this resource. + /// Keeps track of any properties unknown to the library. + internal CommunityResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, CommunityProperties properties, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Properties = properties; + Identity = identity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CommunityResourceData() + { + } + + /// The resource-specific properties for this resource. + public CommunityProperties Properties { get; set; } + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResource.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResource.Serialization.cs new file mode 100644 index 000000000000..6a0db4caaa36 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResource.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class EnclaveConnectionResource : IJsonModel + { + private static EnclaveConnectionResourceData s_dataDeserializationInstance; + private static EnclaveConnectionResourceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + EnclaveConnectionResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + EnclaveConnectionResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResource.cs new file mode 100644 index 000000000000..67c681eb3fa6 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResource.cs @@ -0,0 +1,891 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A Class representing an EnclaveConnectionResource along with the instance operations that can be performed on it. + /// If you have a you can construct an + /// from an instance of using the GetEnclaveConnectionResource method. + /// Otherwise you can get one from its parent resource using the GetEnclaveConnectionResource method. + /// + public partial class EnclaveConnectionResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The enclaveConnectionName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string enclaveConnectionName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _enclaveConnectionResourceEnclaveConnectionClientDiagnostics; + private readonly EnclaveConnectionRestOperations _enclaveConnectionResourceEnclaveConnectionRestClient; + private readonly EnclaveConnectionResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Mission/enclaveConnections"; + + /// Initializes a new instance of the class for mocking. + public EnclaveConnectionResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal EnclaveConnectionResource(ArmClient client, EnclaveConnectionResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal EnclaveConnectionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _enclaveConnectionResourceEnclaveConnectionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string enclaveConnectionResourceEnclaveConnectionApiVersion); + _enclaveConnectionResourceEnclaveConnectionRestClient = new EnclaveConnectionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, enclaveConnectionResourceEnclaveConnectionApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual EnclaveConnectionResourceData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.Get"); + scope.Start(); + try + { + var response = await _enclaveConnectionResourceEnclaveConnectionRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.Get"); + scope.Start(); + try + { + var response = _enclaveConnectionResourceEnclaveConnectionRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.Delete"); + scope.Start(); + try + { + var response = await _enclaveConnectionResourceEnclaveConnectionRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(_enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, _enclaveConnectionResourceEnclaveConnectionRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.Delete"); + scope.Start(); + try + { + var response = _enclaveConnectionResourceEnclaveConnectionRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new VirtualEnclavesArmOperation(_enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, _enclaveConnectionResourceEnclaveConnectionRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, EnclaveConnectionResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.Update"); + scope.Start(); + try + { + var response = await _enclaveConnectionResourceEnclaveConnectionRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new EnclaveConnectionResourceOperationSource(Client), _enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, _enclaveConnectionResourceEnclaveConnectionRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, EnclaveConnectionResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.Update"); + scope.Start(); + try + { + var response = _enclaveConnectionResourceEnclaveConnectionRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new EnclaveConnectionResourceOperationSource(Client), _enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, _enclaveConnectionResourceEnclaveConnectionRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName}/handleApprovalCreation + /// + /// + /// Operation Id + /// EnclaveConnection_HandleApprovalCreation + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> HandleApprovalCreationAsync(WaitUntil waitUntil, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.HandleApprovalCreation"); + scope.Start(); + try + { + var response = await _enclaveConnectionResourceEnclaveConnectionRestClient.HandleApprovalCreationAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, _enclaveConnectionResourceEnclaveConnectionRestClient.CreateHandleApprovalCreationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName}/handleApprovalCreation + /// + /// + /// Operation Id + /// EnclaveConnection_HandleApprovalCreation + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation HandleApprovalCreation(WaitUntil waitUntil, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.HandleApprovalCreation"); + scope.Start(); + try + { + var response = _enclaveConnectionResourceEnclaveConnectionRestClient.HandleApprovalCreation(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, _enclaveConnectionResourceEnclaveConnectionRestClient.CreateHandleApprovalCreationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval deletion state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName}/handleApprovalDeletion + /// + /// + /// Operation Id + /// EnclaveConnection_HandleApprovalDeletion + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> HandleApprovalDeletionAsync(WaitUntil waitUntil, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.HandleApprovalDeletion"); + scope.Start(); + try + { + var response = await _enclaveConnectionResourceEnclaveConnectionRestClient.HandleApprovalDeletionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, _enclaveConnectionResourceEnclaveConnectionRestClient.CreateHandleApprovalDeletionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval deletion state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName}/handleApprovalDeletion + /// + /// + /// Operation Id + /// EnclaveConnection_HandleApprovalDeletion + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation HandleApprovalDeletion(WaitUntil waitUntil, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.HandleApprovalDeletion"); + scope.Start(); + try + { + var response = _enclaveConnectionResourceEnclaveConnectionRestClient.HandleApprovalDeletion(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, _enclaveConnectionResourceEnclaveConnectionRestClient.CreateHandleApprovalDeletionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _enclaveConnectionResourceEnclaveConnectionRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EnclaveConnectionResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new EnclaveConnectionResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _enclaveConnectionResourceEnclaveConnectionRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new EnclaveConnectionResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new EnclaveConnectionResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _enclaveConnectionResourceEnclaveConnectionRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EnclaveConnectionResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new EnclaveConnectionResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _enclaveConnectionResourceEnclaveConnectionRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new EnclaveConnectionResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new EnclaveConnectionResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _enclaveConnectionResourceEnclaveConnectionRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EnclaveConnectionResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new EnclaveConnectionResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _enclaveConnectionResourceEnclaveConnectionRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new EnclaveConnectionResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new EnclaveConnectionResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceCollection.cs new file mode 100644 index 000000000000..1f84cbc5b365 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceCollection.cs @@ -0,0 +1,494 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get an instance call the GetEnclaveConnectionResources method from an instance of . + /// + public partial class EnclaveConnectionResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _enclaveConnectionResourceEnclaveConnectionClientDiagnostics; + private readonly EnclaveConnectionRestOperations _enclaveConnectionResourceEnclaveConnectionRestClient; + + /// Initializes a new instance of the class for mocking. + protected EnclaveConnectionResourceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal EnclaveConnectionResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _enclaveConnectionResourceEnclaveConnectionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", EnclaveConnectionResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(EnclaveConnectionResource.ResourceType, out string enclaveConnectionResourceEnclaveConnectionApiVersion); + _enclaveConnectionResourceEnclaveConnectionRestClient = new EnclaveConnectionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, enclaveConnectionResourceEnclaveConnectionApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + } + + /// + /// Create a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Enclave Connection Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string enclaveConnectionName, EnclaveConnectionResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _enclaveConnectionResourceEnclaveConnectionRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, enclaveConnectionName, data, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new EnclaveConnectionResourceOperationSource(Client), _enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, _enclaveConnectionResourceEnclaveConnectionRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, enclaveConnectionName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Enclave Connection Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string enclaveConnectionName, EnclaveConnectionResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _enclaveConnectionResourceEnclaveConnectionRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, enclaveConnectionName, data, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new EnclaveConnectionResourceOperationSource(Client), _enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, _enclaveConnectionResourceEnclaveConnectionRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, enclaveConnectionName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResourceCollection.Get"); + scope.Start(); + try + { + var response = await _enclaveConnectionResourceEnclaveConnectionRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, enclaveConnectionName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResourceCollection.Get"); + scope.Start(); + try + { + var response = _enclaveConnectionResourceEnclaveConnectionRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, enclaveConnectionName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List EnclaveConnectionResource resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections + /// + /// + /// Operation Id + /// EnclaveConnectionResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _enclaveConnectionResourceEnclaveConnectionRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _enclaveConnectionResourceEnclaveConnectionRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new EnclaveConnectionResource(Client, EnclaveConnectionResourceData.DeserializeEnclaveConnectionResourceData(e)), _enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, "EnclaveConnectionResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List EnclaveConnectionResource resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections + /// + /// + /// Operation Id + /// EnclaveConnectionResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _enclaveConnectionResourceEnclaveConnectionRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _enclaveConnectionResourceEnclaveConnectionRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new EnclaveConnectionResource(Client, EnclaveConnectionResourceData.DeserializeEnclaveConnectionResourceData(e)), _enclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, "EnclaveConnectionResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _enclaveConnectionResourceEnclaveConnectionRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, enclaveConnectionName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResourceCollection.Exists"); + scope.Start(); + try + { + var response = _enclaveConnectionResourceEnclaveConnectionRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, enclaveConnectionName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _enclaveConnectionResourceEnclaveConnectionRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, enclaveConnectionName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new EnclaveConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + + using var scope = _enclaveConnectionResourceEnclaveConnectionClientDiagnostics.CreateScope("EnclaveConnectionResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _enclaveConnectionResourceEnclaveConnectionRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, enclaveConnectionName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new EnclaveConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceData.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceData.Serialization.cs new file mode 100644 index 000000000000..5b53bb64402f --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceData.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class EnclaveConnectionResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveConnectionResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + EnclaveConnectionResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveConnectionResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveConnectionResourceData(document.RootElement, options); + } + + internal static EnclaveConnectionResourceData DeserializeEnclaveConnectionResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EnclaveConnectionProperties properties = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = EnclaveConnectionProperties.DeserializeEnclaveConnectionProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveConnectionResourceData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveConnectionResourceData)} does not support writing '{options.Format}' format."); + } + } + + EnclaveConnectionResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveConnectionResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveConnectionResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceData.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceData.cs new file mode 100644 index 000000000000..78816d13cdde --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveConnectionResourceData.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing the EnclaveConnectionResource data model. + /// EnclaveConnection Model Resource + /// + public partial class EnclaveConnectionResourceData : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + public EnclaveConnectionResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal EnclaveConnectionResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, EnclaveConnectionProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EnclaveConnectionResourceData() + { + } + + /// The resource-specific properties for this resource. + public EnclaveConnectionProperties Properties { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResource.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResource.Serialization.cs new file mode 100644 index 000000000000..5236f6a711bc --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResource.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class EnclaveEndpointResource : IJsonModel + { + private static EnclaveEndpointResourceData s_dataDeserializationInstance; + private static EnclaveEndpointResourceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + EnclaveEndpointResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + EnclaveEndpointResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResource.cs new file mode 100644 index 000000000000..7a0368773420 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResource.cs @@ -0,0 +1,891 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A Class representing an EnclaveEndpointResource along with the instance operations that can be performed on it. + /// If you have a you can construct an + /// from an instance of using the GetEnclaveEndpointResource method. + /// Otherwise you can get one from its parent resource using the GetEnclaveEndpointResource method. + /// + public partial class EnclaveEndpointResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The virtualEnclaveName. + /// The enclaveEndpointName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics; + private readonly EnclaveEndpointsRestOperations _enclaveEndpointResourceEnclaveEndpointsRestClient; + private readonly EnclaveEndpointResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Mission/virtualEnclaves/enclaveEndpoints"; + + /// Initializes a new instance of the class for mocking. + public EnclaveEndpointResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal EnclaveEndpointResource(ArmClient client, EnclaveEndpointResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal EnclaveEndpointResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string enclaveEndpointResourceEnclaveEndpointsApiVersion); + _enclaveEndpointResourceEnclaveEndpointsRestClient = new EnclaveEndpointsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, enclaveEndpointResourceEnclaveEndpointsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual EnclaveEndpointResourceData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.Get"); + scope.Start(); + try + { + var response = await _enclaveEndpointResourceEnclaveEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.Get"); + scope.Start(); + try + { + var response = _enclaveEndpointResourceEnclaveEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.Delete"); + scope.Start(); + try + { + var response = await _enclaveEndpointResourceEnclaveEndpointsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(_enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.Delete"); + scope.Start(); + try + { + var response = _enclaveEndpointResourceEnclaveEndpointsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new VirtualEnclavesArmOperation(_enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, EnclaveEndpointResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.Update"); + scope.Start(); + try + { + var response = await _enclaveEndpointResourceEnclaveEndpointsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new EnclaveEndpointResourceOperationSource(Client), _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, EnclaveEndpointResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.Update"); + scope.Start(); + try + { + var response = _enclaveEndpointResourceEnclaveEndpointsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new EnclaveEndpointResourceOperationSource(Client), _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName}/handleApprovalCreation + /// + /// + /// Operation Id + /// EnclaveEndpoints_HandleApprovalCreation + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> HandleApprovalCreationAsync(WaitUntil waitUntil, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.HandleApprovalCreation"); + scope.Start(); + try + { + var response = await _enclaveEndpointResourceEnclaveEndpointsRestClient.HandleApprovalCreationAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateHandleApprovalCreationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName}/handleApprovalCreation + /// + /// + /// Operation Id + /// EnclaveEndpoints_HandleApprovalCreation + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation HandleApprovalCreation(WaitUntil waitUntil, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.HandleApprovalCreation"); + scope.Start(); + try + { + var response = _enclaveEndpointResourceEnclaveEndpointsRestClient.HandleApprovalCreation(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateHandleApprovalCreationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval deletion state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName}/handleApprovalDeletion + /// + /// + /// Operation Id + /// EnclaveEndpoints_HandleApprovalDeletion + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> HandleApprovalDeletionAsync(WaitUntil waitUntil, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.HandleApprovalDeletion"); + scope.Start(); + try + { + var response = await _enclaveEndpointResourceEnclaveEndpointsRestClient.HandleApprovalDeletionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateHandleApprovalDeletionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval deletion state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName}/handleApprovalDeletion + /// + /// + /// Operation Id + /// EnclaveEndpoints_HandleApprovalDeletion + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation HandleApprovalDeletion(WaitUntil waitUntil, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.HandleApprovalDeletion"); + scope.Start(); + try + { + var response = _enclaveEndpointResourceEnclaveEndpointsRestClient.HandleApprovalDeletion(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateHandleApprovalDeletionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _enclaveEndpointResourceEnclaveEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EnclaveEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new EnclaveEndpointResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _enclaveEndpointResourceEnclaveEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new EnclaveEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new EnclaveEndpointResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _enclaveEndpointResourceEnclaveEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EnclaveEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new EnclaveEndpointResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _enclaveEndpointResourceEnclaveEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new EnclaveEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new EnclaveEndpointResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _enclaveEndpointResourceEnclaveEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EnclaveEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new EnclaveEndpointResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _enclaveEndpointResourceEnclaveEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new EnclaveEndpointResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new EnclaveEndpointResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceCollection.cs new file mode 100644 index 000000000000..1b2a8795687f --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceCollection.cs @@ -0,0 +1,493 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get an instance call the GetEnclaveEndpointResources method from an instance of . + /// + public partial class EnclaveEndpointResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics; + private readonly EnclaveEndpointsRestOperations _enclaveEndpointResourceEnclaveEndpointsRestClient; + + /// Initializes a new instance of the class for mocking. + protected EnclaveEndpointResourceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal EnclaveEndpointResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", EnclaveEndpointResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(EnclaveEndpointResource.ResourceType, out string enclaveEndpointResourceEnclaveEndpointsApiVersion); + _enclaveEndpointResourceEnclaveEndpointsRestClient = new EnclaveEndpointsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, enclaveEndpointResourceEnclaveEndpointsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != EnclaveResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, EnclaveResource.ResourceType), nameof(id)); + } + + /// + /// Create a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Enclave Endpoint Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string enclaveEndpointName, EnclaveEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, enclaveEndpointName, data, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new EnclaveEndpointResourceOperationSource(Client), _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, enclaveEndpointName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Enclave Endpoint Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string enclaveEndpointName, EnclaveEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, enclaveEndpointName, data, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new EnclaveEndpointResourceOperationSource(Client), _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, enclaveEndpointName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string enclaveEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResourceCollection.Get"); + scope.Start(); + try + { + var response = await _enclaveEndpointResourceEnclaveEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, enclaveEndpointName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string enclaveEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResourceCollection.Get"); + scope.Start(); + try + { + var response = _enclaveEndpointResourceEnclaveEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, enclaveEndpointName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List EnclaveEndpointResource resources by EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints + /// + /// + /// Operation Id + /// EnclaveEndpointResource_ListByEnclaveResource + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateListByEnclaveResourceRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateListByEnclaveResourceNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new EnclaveEndpointResource(Client, EnclaveEndpointResourceData.DeserializeEnclaveEndpointResourceData(e)), _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, "EnclaveEndpointResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List EnclaveEndpointResource resources by EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints + /// + /// + /// Operation Id + /// EnclaveEndpointResource_ListByEnclaveResource + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateListByEnclaveResourceRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _enclaveEndpointResourceEnclaveEndpointsRestClient.CreateListByEnclaveResourceNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new EnclaveEndpointResource(Client, EnclaveEndpointResourceData.DeserializeEnclaveEndpointResourceData(e)), _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, "EnclaveEndpointResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string enclaveEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _enclaveEndpointResourceEnclaveEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, enclaveEndpointName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string enclaveEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResourceCollection.Exists"); + scope.Start(); + try + { + var response = _enclaveEndpointResourceEnclaveEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, enclaveEndpointName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string enclaveEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _enclaveEndpointResourceEnclaveEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, enclaveEndpointName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new EnclaveEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string enclaveEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + + using var scope = _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics.CreateScope("EnclaveEndpointResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _enclaveEndpointResourceEnclaveEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, enclaveEndpointName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new EnclaveEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceData.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceData.Serialization.cs new file mode 100644 index 000000000000..2cde2b15fb68 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceData.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class EnclaveEndpointResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + EnclaveEndpointResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveEndpointResourceData(document.RootElement, options); + } + + internal static EnclaveEndpointResourceData DeserializeEnclaveEndpointResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EnclaveEndpointProperties properties = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = EnclaveEndpointProperties.DeserializeEnclaveEndpointProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveEndpointResourceData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveEndpointResourceData)} does not support writing '{options.Format}' format."); + } + } + + EnclaveEndpointResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveEndpointResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveEndpointResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceData.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceData.cs new file mode 100644 index 000000000000..41e4a8786ff1 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveEndpointResourceData.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing the EnclaveEndpointResource data model. + /// EnclaveEndpoint Model Resource + /// + public partial class EnclaveEndpointResourceData : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + public EnclaveEndpointResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal EnclaveEndpointResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, EnclaveEndpointProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EnclaveEndpointResourceData() + { + } + + /// The resource-specific properties for this resource. + public EnclaveEndpointProperties Properties { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResource.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResource.Serialization.cs new file mode 100644 index 000000000000..6dc6d50eb767 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResource.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class EnclaveResource : IJsonModel + { + private static EnclaveResourceData s_dataDeserializationInstance; + private static EnclaveResourceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + EnclaveResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + EnclaveResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResource.cs new file mode 100644 index 000000000000..216385e06854 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResource.cs @@ -0,0 +1,1029 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A Class representing an EnclaveResource along with the instance operations that can be performed on it. + /// If you have a you can construct an + /// from an instance of using the GetEnclaveResource method. + /// Otherwise you can get one from its parent resource using the GetEnclaveResource method. + /// + public partial class EnclaveResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The virtualEnclaveName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _enclaveResourceVirtualEnclaveClientDiagnostics; + private readonly VirtualEnclaveRestOperations _enclaveResourceVirtualEnclaveRestClient; + private readonly EnclaveResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Mission/virtualEnclaves"; + + /// Initializes a new instance of the class for mocking. + public EnclaveResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal EnclaveResource(ArmClient client, EnclaveResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal EnclaveResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _enclaveResourceVirtualEnclaveClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string enclaveResourceVirtualEnclaveApiVersion); + _enclaveResourceVirtualEnclaveRestClient = new VirtualEnclaveRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, enclaveResourceVirtualEnclaveApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual EnclaveResourceData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// Gets a collection of WorkloadResources in the EnclaveResource. + /// An object representing collection of WorkloadResources and their operations over a WorkloadResource. + public virtual WorkloadResourceCollection GetWorkloadResources() + { + return GetCachedClient(client => new WorkloadResourceCollection(client, Id)); + } + + /// + /// Get a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetWorkloadResourceAsync(string workloadName, CancellationToken cancellationToken = default) + { + return await GetWorkloadResources().GetAsync(workloadName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetWorkloadResource(string workloadName, CancellationToken cancellationToken = default) + { + return GetWorkloadResources().Get(workloadName, cancellationToken); + } + + /// Gets a collection of EnclaveEndpointResources in the EnclaveResource. + /// An object representing collection of EnclaveEndpointResources and their operations over a EnclaveEndpointResource. + public virtual EnclaveEndpointResourceCollection GetEnclaveEndpointResources() + { + return GetCachedClient(client => new EnclaveEndpointResourceCollection(client, Id)); + } + + /// + /// Get a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetEnclaveEndpointResourceAsync(string enclaveEndpointName, CancellationToken cancellationToken = default) + { + return await GetEnclaveEndpointResources().GetAsync(enclaveEndpointName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a EnclaveEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName} + /// + /// + /// Operation Id + /// EnclaveEndpointResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetEnclaveEndpointResource(string enclaveEndpointName, CancellationToken cancellationToken = default) + { + return GetEnclaveEndpointResources().Get(enclaveEndpointName, cancellationToken); + } + + /// + /// Get a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.Get"); + scope.Start(); + try + { + var response = await _enclaveResourceVirtualEnclaveRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.Get"); + scope.Start(); + try + { + var response = _enclaveResourceVirtualEnclaveRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.Delete"); + scope.Start(); + try + { + var response = await _enclaveResourceVirtualEnclaveRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(_enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, _enclaveResourceVirtualEnclaveRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.Delete"); + scope.Start(); + try + { + var response = _enclaveResourceVirtualEnclaveRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new VirtualEnclavesArmOperation(_enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, _enclaveResourceVirtualEnclaveRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, EnclaveResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.Update"); + scope.Start(); + try + { + var response = await _enclaveResourceVirtualEnclaveRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new EnclaveResourceOperationSource(Client), _enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, _enclaveResourceVirtualEnclaveRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, EnclaveResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.Update"); + scope.Start(); + try + { + var response = _enclaveResourceVirtualEnclaveRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new EnclaveResourceOperationSource(Client), _enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, _enclaveResourceVirtualEnclaveRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/handleApprovalCreation + /// + /// + /// Operation Id + /// VirtualEnclave_HandleApprovalCreation + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> HandleApprovalCreationAsync(WaitUntil waitUntil, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.HandleApprovalCreation"); + scope.Start(); + try + { + var response = await _enclaveResourceVirtualEnclaveRestClient.HandleApprovalCreationAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, _enclaveResourceVirtualEnclaveRestClient.CreateHandleApprovalCreationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/handleApprovalCreation + /// + /// + /// Operation Id + /// VirtualEnclave_HandleApprovalCreation + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation HandleApprovalCreation(WaitUntil waitUntil, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.HandleApprovalCreation"); + scope.Start(); + try + { + var response = _enclaveResourceVirtualEnclaveRestClient.HandleApprovalCreation(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, _enclaveResourceVirtualEnclaveRestClient.CreateHandleApprovalCreationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval deletion state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/handleApprovalDeletion + /// + /// + /// Operation Id + /// VirtualEnclave_HandleApprovalDeletion + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> HandleApprovalDeletionAsync(WaitUntil waitUntil, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.HandleApprovalDeletion"); + scope.Start(); + try + { + var response = await _enclaveResourceVirtualEnclaveRestClient.HandleApprovalDeletionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, _enclaveResourceVirtualEnclaveRestClient.CreateHandleApprovalDeletionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Callback that triggers on approval deletion state change. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/handleApprovalDeletion + /// + /// + /// Operation Id + /// VirtualEnclave_HandleApprovalDeletion + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation HandleApprovalDeletion(WaitUntil waitUntil, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.HandleApprovalDeletion"); + scope.Start(); + try + { + var response = _enclaveResourceVirtualEnclaveRestClient.HandleApprovalDeletion(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new ApprovalActionResponseOperationSource(), _enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, _enclaveResourceVirtualEnclaveRestClient.CreateHandleApprovalDeletionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _enclaveResourceVirtualEnclaveRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EnclaveResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new EnclaveResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _enclaveResourceVirtualEnclaveRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new EnclaveResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new EnclaveResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _enclaveResourceVirtualEnclaveRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EnclaveResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new EnclaveResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _enclaveResourceVirtualEnclaveRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new EnclaveResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new EnclaveResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _enclaveResourceVirtualEnclaveRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EnclaveResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new EnclaveResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _enclaveResourceVirtualEnclaveRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new EnclaveResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new EnclaveResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceCollection.cs new file mode 100644 index 000000000000..549df20680bc --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceCollection.cs @@ -0,0 +1,494 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get an instance call the GetEnclaveResources method from an instance of . + /// + public partial class EnclaveResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _enclaveResourceVirtualEnclaveClientDiagnostics; + private readonly VirtualEnclaveRestOperations _enclaveResourceVirtualEnclaveRestClient; + + /// Initializes a new instance of the class for mocking. + protected EnclaveResourceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal EnclaveResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _enclaveResourceVirtualEnclaveClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", EnclaveResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(EnclaveResource.ResourceType, out string enclaveResourceVirtualEnclaveApiVersion); + _enclaveResourceVirtualEnclaveRestClient = new VirtualEnclaveRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, enclaveResourceVirtualEnclaveApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + } + + /// + /// Create a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the enclaveResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string virtualEnclaveName, EnclaveResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _enclaveResourceVirtualEnclaveRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, virtualEnclaveName, data, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new EnclaveResourceOperationSource(Client), _enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, _enclaveResourceVirtualEnclaveRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, virtualEnclaveName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the enclaveResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string virtualEnclaveName, EnclaveResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _enclaveResourceVirtualEnclaveRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, virtualEnclaveName, data, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new EnclaveResourceOperationSource(Client), _enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, _enclaveResourceVirtualEnclaveRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, virtualEnclaveName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResourceCollection.Get"); + scope.Start(); + try + { + var response = await _enclaveResourceVirtualEnclaveRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, virtualEnclaveName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResourceCollection.Get"); + scope.Start(); + try + { + var response = _enclaveResourceVirtualEnclaveRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, virtualEnclaveName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EnclaveResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List EnclaveResource resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves + /// + /// + /// Operation Id + /// EnclaveResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _enclaveResourceVirtualEnclaveRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _enclaveResourceVirtualEnclaveRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new EnclaveResource(Client, EnclaveResourceData.DeserializeEnclaveResourceData(e)), _enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, "EnclaveResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List EnclaveResource resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves + /// + /// + /// Operation Id + /// EnclaveResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _enclaveResourceVirtualEnclaveRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _enclaveResourceVirtualEnclaveRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new EnclaveResource(Client, EnclaveResourceData.DeserializeEnclaveResourceData(e)), _enclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, "EnclaveResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _enclaveResourceVirtualEnclaveRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, virtualEnclaveName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResourceCollection.Exists"); + scope.Start(); + try + { + var response = _enclaveResourceVirtualEnclaveRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, virtualEnclaveName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _enclaveResourceVirtualEnclaveRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, virtualEnclaveName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new EnclaveResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var scope = _enclaveResourceVirtualEnclaveClientDiagnostics.CreateScope("EnclaveResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _enclaveResourceVirtualEnclaveRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, virtualEnclaveName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new EnclaveResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceData.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceData.Serialization.cs new file mode 100644 index 000000000000..7041e5fc4419 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceData.Serialization.cs @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class EnclaveResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireV3Options); + } + } + + EnclaveResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveResourceData(document.RootElement, options); + } + + internal static EnclaveResourceData DeserializeEnclaveResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VirtualEnclaveProperties properties = default; + ManagedServiceIdentity identity = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = VirtualEnclaveProperties.DeserializeVirtualEnclaveProperties(property.Value, options); + continue; + } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireV3Options, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveResourceData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + identity, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveResourceData)} does not support writing '{options.Format}' format."); + } + } + + EnclaveResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceData.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceData.cs new file mode 100644 index 000000000000..c531d1d96336 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/EnclaveResourceData.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing the EnclaveResource data model. + /// Virtual Enclave Model Resource + /// + public partial class EnclaveResourceData : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + public EnclaveResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// The managed service identities assigned to this resource. + /// Keeps track of any properties unknown to the library. + internal EnclaveResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, VirtualEnclaveProperties properties, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Properties = properties; + Identity = identity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EnclaveResourceData() + { + } + + /// The resource-specific properties for this resource. + public VirtualEnclaveProperties Properties { get; set; } + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesArmClient.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesArmClient.cs new file mode 100644 index 000000000000..b123e0373cdd --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesArmClient.cs @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableVirtualEnclavesArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableVirtualEnclavesArmClient() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableVirtualEnclavesArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableVirtualEnclavesArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of ApprovalResources in the ArmClient. + /// The scope that the resource will apply against. + /// An object representing collection of ApprovalResources and their operations over a ApprovalResource. + public virtual ApprovalResourceCollection GetApprovalResources(ResourceIdentifier scope) + { + return new ApprovalResourceCollection(Client, scope); + } + + /// + /// Get a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the approvals resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetApprovalResourceAsync(ResourceIdentifier scope, string approvalName, CancellationToken cancellationToken = default) + { + return await GetApprovalResources(scope).GetAsync(approvalName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the approvals resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetApprovalResource(ResourceIdentifier scope, string approvalName, CancellationToken cancellationToken = default) + { + return GetApprovalResources(scope).Get(approvalName, cancellationToken); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual WorkloadResource GetWorkloadResource(ResourceIdentifier id) + { + WorkloadResource.ValidateResourceId(id); + return new WorkloadResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual EnclaveResource GetEnclaveResource(ResourceIdentifier id) + { + EnclaveResource.ValidateResourceId(id); + return new EnclaveResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual CommunityResource GetCommunityResource(ResourceIdentifier id) + { + CommunityResource.ValidateResourceId(id); + return new CommunityResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual TransitHubResource GetTransitHubResource(ResourceIdentifier id) + { + TransitHubResource.ValidateResourceId(id); + return new TransitHubResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual EnclaveConnectionResource GetEnclaveConnectionResource(ResourceIdentifier id) + { + EnclaveConnectionResource.ValidateResourceId(id); + return new EnclaveConnectionResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual EnclaveEndpointResource GetEnclaveEndpointResource(ResourceIdentifier id) + { + EnclaveEndpointResource.ValidateResourceId(id); + return new EnclaveEndpointResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual CommunityEndpointResource GetCommunityEndpointResource(ResourceIdentifier id) + { + CommunityEndpointResource.ValidateResourceId(id); + return new CommunityEndpointResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ApprovalResource GetApprovalResource(ResourceIdentifier id) + { + ApprovalResource.ValidateResourceId(id); + return new ApprovalResource(Client, id); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesResourceGroupResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesResourceGroupResource.cs new file mode 100644 index 000000000000..9733609d7cf4 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesResourceGroupResource.cs @@ -0,0 +1,243 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableVirtualEnclavesResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableVirtualEnclavesResourceGroupResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableVirtualEnclavesResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of EnclaveResources in the ResourceGroupResource. + /// An object representing collection of EnclaveResources and their operations over a EnclaveResource. + public virtual EnclaveResourceCollection GetEnclaveResources() + { + return GetCachedClient(client => new EnclaveResourceCollection(client, Id)); + } + + /// + /// Get a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetEnclaveResourceAsync(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + return await GetEnclaveResources().GetAsync(virtualEnclaveName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetEnclaveResource(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + return GetEnclaveResources().Get(virtualEnclaveName, cancellationToken); + } + + /// Gets a collection of CommunityResources in the ResourceGroupResource. + /// An object representing collection of CommunityResources and their operations over a CommunityResource. + public virtual CommunityResourceCollection GetCommunityResources() + { + return GetCachedClient(client => new CommunityResourceCollection(client, Id)); + } + + /// + /// Get a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetCommunityResourceAsync(string communityName, CancellationToken cancellationToken = default) + { + return await GetCommunityResources().GetAsync(communityName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetCommunityResource(string communityName, CancellationToken cancellationToken = default) + { + return GetCommunityResources().Get(communityName, cancellationToken); + } + + /// Gets a collection of EnclaveConnectionResources in the ResourceGroupResource. + /// An object representing collection of EnclaveConnectionResources and their operations over a EnclaveConnectionResource. + public virtual EnclaveConnectionResourceCollection GetEnclaveConnectionResources() + { + return GetCachedClient(client => new EnclaveConnectionResourceCollection(client, Id)); + } + + /// + /// Get a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetEnclaveConnectionResourceAsync(string enclaveConnectionName, CancellationToken cancellationToken = default) + { + return await GetEnclaveConnectionResources().GetAsync(enclaveConnectionName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetEnclaveConnectionResource(string enclaveConnectionName, CancellationToken cancellationToken = default) + { + return GetEnclaveConnectionResources().Get(enclaveConnectionName, cancellationToken); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesSubscriptionResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesSubscriptionResource.cs new file mode 100644 index 000000000000..e21ecbcd3a69 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/MockableVirtualEnclavesSubscriptionResource.cs @@ -0,0 +1,527 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.VirtualEnclaves.Mocking +{ + /// A class to add extension methods to SubscriptionResource. + public partial class MockableVirtualEnclavesSubscriptionResource : ArmResource + { + private ClientDiagnostics _workloadResourceWorkloadClientDiagnostics; + private WorkloadRestOperations _workloadResourceWorkloadRestClient; + private ClientDiagnostics _enclaveResourceVirtualEnclaveClientDiagnostics; + private VirtualEnclaveRestOperations _enclaveResourceVirtualEnclaveRestClient; + private ClientDiagnostics _communityResourceCommunityClientDiagnostics; + private CommunityRestOperations _communityResourceCommunityRestClient; + private ClientDiagnostics _transitHubResourceTransitHubClientDiagnostics; + private TransitHubRestOperations _transitHubResourceTransitHubRestClient; + private ClientDiagnostics _enclaveConnectionResourceEnclaveConnectionClientDiagnostics; + private EnclaveConnectionRestOperations _enclaveConnectionResourceEnclaveConnectionRestClient; + private ClientDiagnostics _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics; + private EnclaveEndpointsRestOperations _enclaveEndpointResourceEnclaveEndpointsRestClient; + private ClientDiagnostics _communityEndpointResourceCommunityEndpointsClientDiagnostics; + private CommunityEndpointsRestOperations _communityEndpointResourceCommunityEndpointsRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableVirtualEnclavesSubscriptionResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableVirtualEnclavesSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics WorkloadResourceWorkloadClientDiagnostics => _workloadResourceWorkloadClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", WorkloadResource.ResourceType.Namespace, Diagnostics); + private WorkloadRestOperations WorkloadResourceWorkloadRestClient => _workloadResourceWorkloadRestClient ??= new WorkloadRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(WorkloadResource.ResourceType)); + private ClientDiagnostics EnclaveResourceVirtualEnclaveClientDiagnostics => _enclaveResourceVirtualEnclaveClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", EnclaveResource.ResourceType.Namespace, Diagnostics); + private VirtualEnclaveRestOperations EnclaveResourceVirtualEnclaveRestClient => _enclaveResourceVirtualEnclaveRestClient ??= new VirtualEnclaveRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(EnclaveResource.ResourceType)); + private ClientDiagnostics CommunityResourceCommunityClientDiagnostics => _communityResourceCommunityClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", CommunityResource.ResourceType.Namespace, Diagnostics); + private CommunityRestOperations CommunityResourceCommunityRestClient => _communityResourceCommunityRestClient ??= new CommunityRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(CommunityResource.ResourceType)); + private ClientDiagnostics TransitHubResourceTransitHubClientDiagnostics => _transitHubResourceTransitHubClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", TransitHubResource.ResourceType.Namespace, Diagnostics); + private TransitHubRestOperations TransitHubResourceTransitHubRestClient => _transitHubResourceTransitHubRestClient ??= new TransitHubRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(TransitHubResource.ResourceType)); + private ClientDiagnostics EnclaveConnectionResourceEnclaveConnectionClientDiagnostics => _enclaveConnectionResourceEnclaveConnectionClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", EnclaveConnectionResource.ResourceType.Namespace, Diagnostics); + private EnclaveConnectionRestOperations EnclaveConnectionResourceEnclaveConnectionRestClient => _enclaveConnectionResourceEnclaveConnectionRestClient ??= new EnclaveConnectionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(EnclaveConnectionResource.ResourceType)); + private ClientDiagnostics EnclaveEndpointResourceEnclaveEndpointsClientDiagnostics => _enclaveEndpointResourceEnclaveEndpointsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", EnclaveEndpointResource.ResourceType.Namespace, Diagnostics); + private EnclaveEndpointsRestOperations EnclaveEndpointResourceEnclaveEndpointsRestClient => _enclaveEndpointResourceEnclaveEndpointsRestClient ??= new EnclaveEndpointsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(EnclaveEndpointResource.ResourceType)); + private ClientDiagnostics CommunityEndpointResourceCommunityEndpointsClientDiagnostics => _communityEndpointResourceCommunityEndpointsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", CommunityEndpointResource.ResourceType.Namespace, Diagnostics); + private CommunityEndpointsRestOperations CommunityEndpointResourceCommunityEndpointsRestClient => _communityEndpointResourceCommunityEndpointsRestClient ??= new CommunityEndpointsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(CommunityEndpointResource.ResourceType)); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// List WorkloadResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads + /// + /// + /// Operation Id + /// WorkloadResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetWorkloadResourcesAsync(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => WorkloadResourceWorkloadRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, virtualEnclaveName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => WorkloadResourceWorkloadRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, virtualEnclaveName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new WorkloadResource(Client, WorkloadResourceData.DeserializeWorkloadResourceData(e)), WorkloadResourceWorkloadClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetWorkloadResources", "value", "nextLink", cancellationToken); + } + + /// + /// List WorkloadResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads + /// + /// + /// Operation Id + /// WorkloadResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetWorkloadResources(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => WorkloadResourceWorkloadRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, virtualEnclaveName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => WorkloadResourceWorkloadRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, virtualEnclaveName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new WorkloadResource(Client, WorkloadResourceData.DeserializeWorkloadResourceData(e)), WorkloadResourceWorkloadClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetWorkloadResources", "value", "nextLink", cancellationToken); + } + + /// + /// List EnclaveResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves + /// + /// + /// Operation Id + /// EnclaveResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetEnclaveResourcesAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => EnclaveResourceVirtualEnclaveRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => EnclaveResourceVirtualEnclaveRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new EnclaveResource(Client, EnclaveResourceData.DeserializeEnclaveResourceData(e)), EnclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetEnclaveResources", "value", "nextLink", cancellationToken); + } + + /// + /// List EnclaveResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves + /// + /// + /// Operation Id + /// EnclaveResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetEnclaveResources(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => EnclaveResourceVirtualEnclaveRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => EnclaveResourceVirtualEnclaveRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new EnclaveResource(Client, EnclaveResourceData.DeserializeEnclaveResourceData(e)), EnclaveResourceVirtualEnclaveClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetEnclaveResources", "value", "nextLink", cancellationToken); + } + + /// + /// List CommunityResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities + /// + /// + /// Operation Id + /// CommunityResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetCommunityResourcesAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CommunityResourceCommunityRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CommunityResourceCommunityRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new CommunityResource(Client, CommunityResourceData.DeserializeCommunityResourceData(e)), CommunityResourceCommunityClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetCommunityResources", "value", "nextLink", cancellationToken); + } + + /// + /// List CommunityResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities + /// + /// + /// Operation Id + /// CommunityResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetCommunityResources(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CommunityResourceCommunityRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CommunityResourceCommunityRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new CommunityResource(Client, CommunityResourceData.DeserializeCommunityResourceData(e)), CommunityResourceCommunityClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetCommunityResources", "value", "nextLink", cancellationToken); + } + + /// + /// List TransitHubResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities/{communityName}/transitHubs + /// + /// + /// Operation Id + /// TransitHubResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetTransitHubResourcesAsync(string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => TransitHubResourceTransitHubRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, communityName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => TransitHubResourceTransitHubRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, communityName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new TransitHubResource(Client, TransitHubResourceData.DeserializeTransitHubResourceData(e)), TransitHubResourceTransitHubClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetTransitHubResources", "value", "nextLink", cancellationToken); + } + + /// + /// List TransitHubResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities/{communityName}/transitHubs + /// + /// + /// Operation Id + /// TransitHubResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetTransitHubResources(string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => TransitHubResourceTransitHubRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, communityName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => TransitHubResourceTransitHubRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, communityName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TransitHubResource(Client, TransitHubResourceData.DeserializeTransitHubResourceData(e)), TransitHubResourceTransitHubClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetTransitHubResources", "value", "nextLink", cancellationToken); + } + + /// + /// List EnclaveConnectionResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/enclaveConnections + /// + /// + /// Operation Id + /// EnclaveConnectionResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetEnclaveConnectionResourcesAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => EnclaveConnectionResourceEnclaveConnectionRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => EnclaveConnectionResourceEnclaveConnectionRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new EnclaveConnectionResource(Client, EnclaveConnectionResourceData.DeserializeEnclaveConnectionResourceData(e)), EnclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetEnclaveConnectionResources", "value", "nextLink", cancellationToken); + } + + /// + /// List EnclaveConnectionResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/enclaveConnections + /// + /// + /// Operation Id + /// EnclaveConnectionResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetEnclaveConnectionResources(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => EnclaveConnectionResourceEnclaveConnectionRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => EnclaveConnectionResourceEnclaveConnectionRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new EnclaveConnectionResource(Client, EnclaveConnectionResourceData.DeserializeEnclaveConnectionResourceData(e)), EnclaveConnectionResourceEnclaveConnectionClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetEnclaveConnectionResources", "value", "nextLink", cancellationToken); + } + + /// + /// List EnclaveEndpointResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints + /// + /// + /// Operation Id + /// EnclaveEndpointResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetEnclaveEndpointResourcesAsync(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => EnclaveEndpointResourceEnclaveEndpointsRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, virtualEnclaveName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => EnclaveEndpointResourceEnclaveEndpointsRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, virtualEnclaveName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new EnclaveEndpointResource(Client, EnclaveEndpointResourceData.DeserializeEnclaveEndpointResourceData(e)), EnclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetEnclaveEndpointResources", "value", "nextLink", cancellationToken); + } + + /// + /// List EnclaveEndpointResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints + /// + /// + /// Operation Id + /// EnclaveEndpointResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetEnclaveEndpointResources(string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => EnclaveEndpointResourceEnclaveEndpointsRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, virtualEnclaveName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => EnclaveEndpointResourceEnclaveEndpointsRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, virtualEnclaveName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new EnclaveEndpointResource(Client, EnclaveEndpointResourceData.DeserializeEnclaveEndpointResourceData(e)), EnclaveEndpointResourceEnclaveEndpointsClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetEnclaveEndpointResources", "value", "nextLink", cancellationToken); + } + + /// + /// List CommunityEndpointResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints + /// + /// + /// Operation Id + /// CommunityEndpointResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetCommunityEndpointResourcesAsync(string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CommunityEndpointResourceCommunityEndpointsRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, communityName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CommunityEndpointResourceCommunityEndpointsRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, communityName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new CommunityEndpointResource(Client, CommunityEndpointResourceData.DeserializeCommunityEndpointResourceData(e)), CommunityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetCommunityEndpointResources", "value", "nextLink", cancellationToken); + } + + /// + /// List CommunityEndpointResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints + /// + /// + /// Operation Id + /// CommunityEndpointResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetCommunityEndpointResources(string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CommunityEndpointResourceCommunityEndpointsRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, communityName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CommunityEndpointResourceCommunityEndpointsRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, communityName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new CommunityEndpointResource(Client, CommunityEndpointResourceData.DeserializeCommunityEndpointResourceData(e)), CommunityEndpointResourceCommunityEndpointsClientDiagnostics, Pipeline, "MockableVirtualEnclavesSubscriptionResource.GetCommunityEndpointResources", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/VirtualEnclavesExtensions.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/VirtualEnclavesExtensions.cs new file mode 100644 index 000000000000..3161240b86e4 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Extensions/VirtualEnclavesExtensions.cs @@ -0,0 +1,1082 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.VirtualEnclaves.Mocking; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// A class to add extension methods to Azure.ResourceManager.VirtualEnclaves. + public static partial class VirtualEnclavesExtensions + { + private static MockableVirtualEnclavesArmClient GetMockableVirtualEnclavesArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableVirtualEnclavesArmClient(client0)); + } + + private static MockableVirtualEnclavesResourceGroupResource GetMockableVirtualEnclavesResourceGroupResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableVirtualEnclavesResourceGroupResource(client, resource.Id)); + } + + private static MockableVirtualEnclavesSubscriptionResource GetMockableVirtualEnclavesSubscriptionResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableVirtualEnclavesSubscriptionResource(client, resource.Id)); + } + + /// + /// Gets a collection of ApprovalResources in the ArmClient. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// is null. + /// An object representing collection of ApprovalResources and their operations over a ApprovalResource. + public static ApprovalResourceCollection GetApprovalResources(this ArmClient client, ResourceIdentifier scope) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableVirtualEnclavesArmClient(client).GetApprovalResources(scope); + } + + /// + /// Get a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the approvals resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetApprovalResourceAsync(this ArmClient client, ResourceIdentifier scope, string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return await GetMockableVirtualEnclavesArmClient(client).GetApprovalResourceAsync(scope, approvalName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a ApprovalResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName} + /// + /// + /// Operation Id + /// ApprovalResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the approvals resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetApprovalResource(this ArmClient client, ResourceIdentifier scope, string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableVirtualEnclavesArmClient(client).GetApprovalResource(scope, approvalName, cancellationToken); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static WorkloadResource GetWorkloadResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableVirtualEnclavesArmClient(client).GetWorkloadResource(id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static EnclaveResource GetEnclaveResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableVirtualEnclavesArmClient(client).GetEnclaveResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static CommunityResource GetCommunityResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableVirtualEnclavesArmClient(client).GetCommunityResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static TransitHubResource GetTransitHubResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableVirtualEnclavesArmClient(client).GetTransitHubResource(id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static EnclaveConnectionResource GetEnclaveConnectionResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableVirtualEnclavesArmClient(client).GetEnclaveConnectionResource(id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static EnclaveEndpointResource GetEnclaveEndpointResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableVirtualEnclavesArmClient(client).GetEnclaveEndpointResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static CommunityEndpointResource GetCommunityEndpointResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableVirtualEnclavesArmClient(client).GetCommunityEndpointResource(id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static ApprovalResource GetApprovalResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableVirtualEnclavesArmClient(client).GetApprovalResource(id); + } + + /// + /// Gets a collection of EnclaveResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// is null. + /// An object representing collection of EnclaveResources and their operations over a EnclaveResource. + public static EnclaveResourceCollection GetEnclaveResources(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableVirtualEnclavesResourceGroupResource(resourceGroupResource).GetEnclaveResources(); + } + + /// + /// Get a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetEnclaveResourceAsync(this ResourceGroupResource resourceGroupResource, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableVirtualEnclavesResourceGroupResource(resourceGroupResource).GetEnclaveResourceAsync(virtualEnclaveName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName} + /// + /// + /// Operation Id + /// EnclaveResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetEnclaveResource(this ResourceGroupResource resourceGroupResource, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableVirtualEnclavesResourceGroupResource(resourceGroupResource).GetEnclaveResource(virtualEnclaveName, cancellationToken); + } + + /// + /// Gets a collection of CommunityResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// is null. + /// An object representing collection of CommunityResources and their operations over a CommunityResource. + public static CommunityResourceCollection GetCommunityResources(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableVirtualEnclavesResourceGroupResource(resourceGroupResource).GetCommunityResources(); + } + + /// + /// Get a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetCommunityResourceAsync(this ResourceGroupResource resourceGroupResource, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableVirtualEnclavesResourceGroupResource(resourceGroupResource).GetCommunityResourceAsync(communityName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName} + /// + /// + /// Operation Id + /// CommunityResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetCommunityResource(this ResourceGroupResource resourceGroupResource, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableVirtualEnclavesResourceGroupResource(resourceGroupResource).GetCommunityResource(communityName, cancellationToken); + } + + /// + /// Gets a collection of EnclaveConnectionResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// is null. + /// An object representing collection of EnclaveConnectionResources and their operations over a EnclaveConnectionResource. + public static EnclaveConnectionResourceCollection GetEnclaveConnectionResources(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableVirtualEnclavesResourceGroupResource(resourceGroupResource).GetEnclaveConnectionResources(); + } + + /// + /// Get a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetEnclaveConnectionResourceAsync(this ResourceGroupResource resourceGroupResource, string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableVirtualEnclavesResourceGroupResource(resourceGroupResource).GetEnclaveConnectionResourceAsync(enclaveConnectionName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a EnclaveConnectionResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName} + /// + /// + /// Operation Id + /// EnclaveConnectionResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetEnclaveConnectionResource(this ResourceGroupResource resourceGroupResource, string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableVirtualEnclavesResourceGroupResource(resourceGroupResource).GetEnclaveConnectionResource(enclaveConnectionName, cancellationToken); + } + + /// + /// List WorkloadResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads + /// + /// + /// Operation Id + /// WorkloadResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetWorkloadResourcesAsync(this SubscriptionResource subscriptionResource, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetWorkloadResourcesAsync(virtualEnclaveName, cancellationToken); + } + + /// + /// List WorkloadResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads + /// + /// + /// Operation Id + /// WorkloadResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetWorkloadResources(this SubscriptionResource subscriptionResource, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetWorkloadResources(virtualEnclaveName, cancellationToken); + } + + /// + /// List EnclaveResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves + /// + /// + /// Operation Id + /// EnclaveResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetEnclaveResourcesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetEnclaveResourcesAsync(cancellationToken); + } + + /// + /// List EnclaveResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves + /// + /// + /// Operation Id + /// EnclaveResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetEnclaveResources(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetEnclaveResources(cancellationToken); + } + + /// + /// List CommunityResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities + /// + /// + /// Operation Id + /// CommunityResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetCommunityResourcesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetCommunityResourcesAsync(cancellationToken); + } + + /// + /// List CommunityResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities + /// + /// + /// Operation Id + /// CommunityResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetCommunityResources(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetCommunityResources(cancellationToken); + } + + /// + /// List TransitHubResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities/{communityName}/transitHubs + /// + /// + /// Operation Id + /// TransitHubResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetTransitHubResourcesAsync(this SubscriptionResource subscriptionResource, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetTransitHubResourcesAsync(communityName, cancellationToken); + } + + /// + /// List TransitHubResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities/{communityName}/transitHubs + /// + /// + /// Operation Id + /// TransitHubResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetTransitHubResources(this SubscriptionResource subscriptionResource, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetTransitHubResources(communityName, cancellationToken); + } + + /// + /// List EnclaveConnectionResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/enclaveConnections + /// + /// + /// Operation Id + /// EnclaveConnectionResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetEnclaveConnectionResourcesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetEnclaveConnectionResourcesAsync(cancellationToken); + } + + /// + /// List EnclaveConnectionResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/enclaveConnections + /// + /// + /// Operation Id + /// EnclaveConnectionResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetEnclaveConnectionResources(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetEnclaveConnectionResources(cancellationToken); + } + + /// + /// List EnclaveEndpointResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints + /// + /// + /// Operation Id + /// EnclaveEndpointResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetEnclaveEndpointResourcesAsync(this SubscriptionResource subscriptionResource, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetEnclaveEndpointResourcesAsync(virtualEnclaveName, cancellationToken); + } + + /// + /// List EnclaveEndpointResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints + /// + /// + /// Operation Id + /// EnclaveEndpointResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetEnclaveEndpointResources(this SubscriptionResource subscriptionResource, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetEnclaveEndpointResources(virtualEnclaveName, cancellationToken); + } + + /// + /// List CommunityEndpointResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints + /// + /// + /// Operation Id + /// CommunityEndpointResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetCommunityEndpointResourcesAsync(this SubscriptionResource subscriptionResource, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetCommunityEndpointResourcesAsync(communityName, cancellationToken); + } + + /// + /// List CommunityEndpointResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints + /// + /// + /// Operation Id + /// CommunityEndpointResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetCommunityEndpointResources(this SubscriptionResource subscriptionResource, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableVirtualEnclavesSubscriptionResource(subscriptionResource).GetCommunityEndpointResources(communityName, cancellationToken); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Argument.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..65a2c9c97cb3 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", name); + } + } + + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..ec17aef8d22d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ChangeTrackingList.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..8bbd573c4cb4 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..e88bb450dcb0 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,409 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal static class ModelSerializationExtensions + { + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly ModelReaderWriterOptions WireV3Options = new ModelReaderWriterOptions("W|v3"); + internal static readonly ModelReaderWriterOptions JsonV3Options = new ModelReaderWriterOptions("J|v3"); + internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static bool IsSentinelValue(BinaryData value) + { + ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; + ReadOnlySpan valueSpan = value.ToMemory().Span; + return sentinelSpan.SequenceEqual(valueSpan); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Optional.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..4a79aba8f432 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..ca0c19ebc928 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/ApprovalActionResponseOperationSource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/ApprovalActionResponseOperationSource.cs new file mode 100644 index 000000000000..0427dd64984f --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/ApprovalActionResponseOperationSource.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class ApprovalActionResponseOperationSource : IOperationSource + { + ApprovalActionResponse IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + return ApprovalActionResponse.DeserializeApprovalActionResponse(document.RootElement); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + return ApprovalActionResponse.DeserializeApprovalActionResponse(document.RootElement); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/ApprovalResourceOperationSource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/ApprovalResourceOperationSource.cs new file mode 100644 index 000000000000..503e0dc25ab1 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/ApprovalResourceOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class ApprovalResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal ApprovalResourceOperationSource(ArmClient client) + { + _client = client; + } + + ApprovalResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return new ApprovalResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return await Task.FromResult(new ApprovalResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/CommunityEndpointResourceOperationSource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/CommunityEndpointResourceOperationSource.cs new file mode 100644 index 000000000000..dc2818414251 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/CommunityEndpointResourceOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class CommunityEndpointResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal CommunityEndpointResourceOperationSource(ArmClient client) + { + _client = client; + } + + CommunityEndpointResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return new CommunityEndpointResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return await Task.FromResult(new CommunityEndpointResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/CommunityResourceOperationSource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/CommunityResourceOperationSource.cs new file mode 100644 index 000000000000..dabf85a60c2a --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/CommunityResourceOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class CommunityResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal CommunityResourceOperationSource(ArmClient client) + { + _client = client; + } + + CommunityResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return new CommunityResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return await Task.FromResult(new CommunityResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveConnectionResourceOperationSource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveConnectionResourceOperationSource.cs new file mode 100644 index 000000000000..b57f7bf8b084 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveConnectionResourceOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class EnclaveConnectionResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal EnclaveConnectionResourceOperationSource(ArmClient client) + { + _client = client; + } + + EnclaveConnectionResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return new EnclaveConnectionResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return await Task.FromResult(new EnclaveConnectionResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveEndpointResourceOperationSource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveEndpointResourceOperationSource.cs new file mode 100644 index 000000000000..2013630fbc27 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveEndpointResourceOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class EnclaveEndpointResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal EnclaveEndpointResourceOperationSource(ArmClient client) + { + _client = client; + } + + EnclaveEndpointResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return new EnclaveEndpointResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return await Task.FromResult(new EnclaveEndpointResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveResourceOperationSource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveResourceOperationSource.cs new file mode 100644 index 000000000000..c63af98c459f --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/EnclaveResourceOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class EnclaveResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal EnclaveResourceOperationSource(ArmClient client) + { + _client = client; + } + + EnclaveResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return new EnclaveResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return await Task.FromResult(new EnclaveResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/TransitHubResourceOperationSource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/TransitHubResourceOperationSource.cs new file mode 100644 index 000000000000..ac5755a2c175 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/TransitHubResourceOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class TransitHubResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal TransitHubResourceOperationSource(ArmClient client) + { + _client = client; + } + + TransitHubResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return new TransitHubResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return await Task.FromResult(new TransitHubResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/VirtualEnclavesArmOperation.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/VirtualEnclavesArmOperation.cs new file mode 100644 index 000000000000..97786b507114 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/VirtualEnclavesArmOperation.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.VirtualEnclaves +{ +#pragma warning disable SA1649 // File name should match first type name + internal class VirtualEnclavesArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of VirtualEnclavesArmOperation for mocking. + protected VirtualEnclavesArmOperation() + { + } + + internal VirtualEnclavesArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal VirtualEnclavesArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + { + _nextLinkOperation = nextLinkOperationValue; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "VirtualEnclavesArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); + } + /// + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); + + /// + public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/VirtualEnclavesArmOperationOfT.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/VirtualEnclavesArmOperationOfT.cs new file mode 100644 index 000000000000..b4b833573124 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/VirtualEnclavesArmOperationOfT.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.VirtualEnclaves +{ +#pragma warning disable SA1649 // File name should match first type name + internal class VirtualEnclavesArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of VirtualEnclavesArmOperation for mocking. + protected VirtualEnclavesArmOperation() + { + } + + internal VirtualEnclavesArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal VirtualEnclavesArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + { + _nextLinkOperation = nextLinkOperationValue; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "VirtualEnclavesArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); + } + /// + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override T Value => _operation.Value; + + /// + public override bool HasValue => _operation.HasValue; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); + + /// + public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/WorkloadResourceOperationSource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/WorkloadResourceOperationSource.cs new file mode 100644 index 000000000000..7a87f7e0312d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/LongRunningOperation/WorkloadResourceOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal class WorkloadResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal WorkloadResourceOperationSource(ArmClient client) + { + _client = client; + } + + WorkloadResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return new WorkloadResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerVirtualEnclavesContext.Default); + return await Task.FromResult(new WorkloadResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ActionPerformed.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ActionPerformed.cs new file mode 100644 index 000000000000..71d90048f1ff --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ActionPerformed.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Specifies the action performed by the approver. + public readonly partial struct ActionPerformed : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ActionPerformed(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ApprovedValue = "Approved"; + private const string RejectedValue = "Rejected"; + + /// Action was Approved. + public static ActionPerformed Approved { get; } = new ActionPerformed(ApprovedValue); + /// Action was Rejected. + public static ActionPerformed Rejected { get; } = new ActionPerformed(RejectedValue); + /// Determines if two values are the same. + public static bool operator ==(ActionPerformed left, ActionPerformed right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ActionPerformed left, ActionPerformed right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ActionPerformed(string value) => new ActionPerformed(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ActionPerformed other && Equals(other); + /// + public bool Equals(ActionPerformed other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionContent.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionContent.Serialization.cs new file mode 100644 index 000000000000..a2b7c990551c --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionContent.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class ApprovalActionContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalActionContent)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("approvalStatus"u8); + writer.WriteStringValue(ApprovalStatus.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ApprovalActionContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalActionContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApprovalActionContent(document.RootElement, options); + } + + internal static ApprovalActionContent DeserializeApprovalActionContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ApprovalActionRequestApprovalStatus approvalStatus = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("approvalStatus"u8)) + { + approvalStatus = new ApprovalActionRequestApprovalStatus(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApprovalActionContent(approvalStatus, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(ApprovalActionContent)} does not support writing '{options.Format}' format."); + } + } + + ApprovalActionContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApprovalActionContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApprovalActionContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionContent.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionContent.cs new file mode 100644 index 000000000000..fa600022e9db --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionContent.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Request body for calling post-action. + public partial class ApprovalActionContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Approval status indicating 'Approved' or 'Rejected'. + public ApprovalActionContent(ApprovalActionRequestApprovalStatus approvalStatus) + { + ApprovalStatus = approvalStatus; + } + + /// Initializes a new instance of . + /// Approval status indicating 'Approved' or 'Rejected'. + /// Keeps track of any properties unknown to the library. + internal ApprovalActionContent(ApprovalActionRequestApprovalStatus approvalStatus, IDictionary serializedAdditionalRawData) + { + ApprovalStatus = approvalStatus; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ApprovalActionContent() + { + } + + /// Approval status indicating 'Approved' or 'Rejected'. + public ApprovalActionRequestApprovalStatus ApprovalStatus { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionRequestApprovalStatus.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionRequestApprovalStatus.cs new file mode 100644 index 000000000000..701263b296b6 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionRequestApprovalStatus.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The ApprovalActionRequestApprovalStatus. + public readonly partial struct ApprovalActionRequestApprovalStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ApprovalActionRequestApprovalStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ApprovedValue = "Approved"; + private const string RejectedValue = "Rejected"; + + /// Approved. + public static ApprovalActionRequestApprovalStatus Approved { get; } = new ApprovalActionRequestApprovalStatus(ApprovedValue); + /// Rejected. + public static ApprovalActionRequestApprovalStatus Rejected { get; } = new ApprovalActionRequestApprovalStatus(RejectedValue); + /// Determines if two values are the same. + public static bool operator ==(ApprovalActionRequestApprovalStatus left, ApprovalActionRequestApprovalStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ApprovalActionRequestApprovalStatus left, ApprovalActionRequestApprovalStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ApprovalActionRequestApprovalStatus(string value) => new ApprovalActionRequestApprovalStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ApprovalActionRequestApprovalStatus other && Equals(other); + /// + public bool Equals(ApprovalActionRequestApprovalStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionResponse.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionResponse.Serialization.cs new file mode 100644 index 000000000000..100b1ba66527 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionResponse.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class ApprovalActionResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalActionResponse)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ApprovalActionResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalActionResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApprovalActionResponse(document.RootElement, options); + } + + internal static ApprovalActionResponse DeserializeApprovalActionResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApprovalActionResponse(message, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(ApprovalActionResponse)} does not support writing '{options.Format}' format."); + } + } + + ApprovalActionResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApprovalActionResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApprovalActionResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionResponse.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionResponse.cs new file mode 100644 index 000000000000..0d1049b5466d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalActionResponse.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Response body after handling of approvalCallbackRequest. + public partial class ApprovalActionResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Confirmation message indicating the result of the operation. + /// is null. + internal ApprovalActionResponse(string message) + { + Argument.AssertNotNull(message, nameof(message)); + + Message = message; + } + + /// Initializes a new instance of . + /// Confirmation message indicating the result of the operation. + /// Keeps track of any properties unknown to the library. + internal ApprovalActionResponse(string message, IDictionary serializedAdditionalRawData) + { + Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ApprovalActionResponse() + { + } + + /// Confirmation message indicating the result of the operation. + public string Message { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequest.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequest.Serialization.cs new file mode 100644 index 000000000000..3a65e64eca5a --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequest.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class ApprovalCallbackRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalCallbackRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("resourceRequestAction"u8); + writer.WriteStringValue(ResourceRequestAction.ToString()); + writer.WritePropertyName("approvalStatus"u8); + writer.WriteStringValue(ApprovalStatus.ToString()); + if (Optional.IsDefined(ApprovalCallbackPayload)) + { + writer.WritePropertyName("approvalCallbackPayload"u8); + writer.WriteStringValue(ApprovalCallbackPayload); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ApprovalCallbackRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalCallbackRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApprovalCallbackRequest(document.RootElement, options); + } + + internal static ApprovalCallbackRequest DeserializeApprovalCallbackRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ApprovalCallbackRequestResourceRequestAction resourceRequestAction = default; + ApprovalCallbackRequestApprovalStatus approvalStatus = default; + string approvalCallbackPayload = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceRequestAction"u8)) + { + resourceRequestAction = new ApprovalCallbackRequestResourceRequestAction(property.Value.GetString()); + continue; + } + if (property.NameEquals("approvalStatus"u8)) + { + approvalStatus = new ApprovalCallbackRequestApprovalStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("approvalCallbackPayload"u8)) + { + approvalCallbackPayload = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApprovalCallbackRequest(resourceRequestAction, approvalStatus, approvalCallbackPayload, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(ApprovalCallbackRequest)} does not support writing '{options.Format}' format."); + } + } + + ApprovalCallbackRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApprovalCallbackRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApprovalCallbackRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequest.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequest.cs new file mode 100644 index 000000000000..aa719b002419 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequest.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Request body for calling post-action. + public partial class ApprovalCallbackRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Resource request action indicating action which needed to be performed upon calling approval-callback post action. + /// Approval status indicating 'Approved' or 'Rejected'. + public ApprovalCallbackRequest(ApprovalCallbackRequestResourceRequestAction resourceRequestAction, ApprovalCallbackRequestApprovalStatus approvalStatus) + { + ResourceRequestAction = resourceRequestAction; + ApprovalStatus = approvalStatus; + } + + /// Initializes a new instance of . + /// Resource request action indicating action which needed to be performed upon calling approval-callback post action. + /// Approval status indicating 'Approved' or 'Rejected'. + /// Payload requested by client upon approval action. + /// Keeps track of any properties unknown to the library. + internal ApprovalCallbackRequest(ApprovalCallbackRequestResourceRequestAction resourceRequestAction, ApprovalCallbackRequestApprovalStatus approvalStatus, string approvalCallbackPayload, IDictionary serializedAdditionalRawData) + { + ResourceRequestAction = resourceRequestAction; + ApprovalStatus = approvalStatus; + ApprovalCallbackPayload = approvalCallbackPayload; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ApprovalCallbackRequest() + { + } + + /// Resource request action indicating action which needed to be performed upon calling approval-callback post action. + public ApprovalCallbackRequestResourceRequestAction ResourceRequestAction { get; } + /// Approval status indicating 'Approved' or 'Rejected'. + public ApprovalCallbackRequestApprovalStatus ApprovalStatus { get; } + /// Payload requested by client upon approval action. + public string ApprovalCallbackPayload { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequestApprovalStatus.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequestApprovalStatus.cs new file mode 100644 index 000000000000..8afeeadb6022 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequestApprovalStatus.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The ApprovalCallbackRequestApprovalStatus. + public readonly partial struct ApprovalCallbackRequestApprovalStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ApprovalCallbackRequestApprovalStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ApprovedValue = "Approved"; + private const string RejectedValue = "Rejected"; + + /// Approved. + public static ApprovalCallbackRequestApprovalStatus Approved { get; } = new ApprovalCallbackRequestApprovalStatus(ApprovedValue); + /// Rejected. + public static ApprovalCallbackRequestApprovalStatus Rejected { get; } = new ApprovalCallbackRequestApprovalStatus(RejectedValue); + /// Determines if two values are the same. + public static bool operator ==(ApprovalCallbackRequestApprovalStatus left, ApprovalCallbackRequestApprovalStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ApprovalCallbackRequestApprovalStatus left, ApprovalCallbackRequestApprovalStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ApprovalCallbackRequestApprovalStatus(string value) => new ApprovalCallbackRequestApprovalStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ApprovalCallbackRequestApprovalStatus other && Equals(other); + /// + public bool Equals(ApprovalCallbackRequestApprovalStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequestResourceRequestAction.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequestResourceRequestAction.cs new file mode 100644 index 000000000000..f6aeea37860d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalCallbackRequestResourceRequestAction.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The ApprovalCallbackRequestResourceRequestAction. + public readonly partial struct ApprovalCallbackRequestResourceRequestAction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ApprovalCallbackRequestResourceRequestAction(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CreateValue = "Create"; + private const string DeleteValue = "Delete"; + private const string UpdateValue = "Update"; + private const string ResetValue = "Reset"; + + /// Create. + public static ApprovalCallbackRequestResourceRequestAction Create { get; } = new ApprovalCallbackRequestResourceRequestAction(CreateValue); + /// Delete. + public static ApprovalCallbackRequestResourceRequestAction Delete { get; } = new ApprovalCallbackRequestResourceRequestAction(DeleteValue); + /// Update. + public static ApprovalCallbackRequestResourceRequestAction Update { get; } = new ApprovalCallbackRequestResourceRequestAction(UpdateValue); + /// Reset. + public static ApprovalCallbackRequestResourceRequestAction Reset { get; } = new ApprovalCallbackRequestResourceRequestAction(ResetValue); + /// Determines if two values are the same. + public static bool operator ==(ApprovalCallbackRequestResourceRequestAction left, ApprovalCallbackRequestResourceRequestAction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ApprovalCallbackRequestResourceRequestAction left, ApprovalCallbackRequestResourceRequestAction right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ApprovalCallbackRequestResourceRequestAction(string value) => new ApprovalCallbackRequestResourceRequestAction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ApprovalCallbackRequestResourceRequestAction other && Equals(other); + /// + public bool Equals(ApprovalCallbackRequestResourceRequestAction other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequest.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequest.Serialization.cs new file mode 100644 index 000000000000..366b09d9cfa2 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequest.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class VirtualEnclavesApprovalDeletionCallbackRequestContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualEnclavesApprovalDeletionCallbackRequestContent)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("resourceRequestAction"u8); + writer.WriteStringValue(ResourceRequestAction.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VirtualEnclavesApprovalDeletionCallbackRequestContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualEnclavesApprovalDeletionCallbackRequestContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualEnclavesApprovalDeletionCallbackRequestContent(document.RootElement, options); + } + + internal static VirtualEnclavesApprovalDeletionCallbackRequestContent DeserializeVirtualEnclavesApprovalDeletionCallbackRequestContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction resourceRequestAction = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceRequestAction"u8)) + { + resourceRequestAction = new VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualEnclavesApprovalDeletionCallbackRequestContent(resourceRequestAction, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(VirtualEnclavesApprovalDeletionCallbackRequestContent)} does not support writing '{options.Format}' format."); + } + } + + VirtualEnclavesApprovalDeletionCallbackRequestContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVirtualEnclavesApprovalDeletionCallbackRequestContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualEnclavesApprovalDeletionCallbackRequestContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequest.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequest.cs new file mode 100644 index 000000000000..31671e3a4351 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequest.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Request body for calling post-action. + public partial class VirtualEnclavesApprovalDeletionCallbackRequestContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Resource request action indicating action which needed to be performed upon calling approval-deletion-callback post action. + public VirtualEnclavesApprovalDeletionCallbackRequestContent(VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction resourceRequestAction) + { + ResourceRequestAction = resourceRequestAction; + } + + /// Initializes a new instance of . + /// Resource request action indicating action which needed to be performed upon calling approval-deletion-callback post action. + /// Keeps track of any properties unknown to the library. + internal VirtualEnclavesApprovalDeletionCallbackRequestContent(VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction resourceRequestAction, IDictionary serializedAdditionalRawData) + { + ResourceRequestAction = resourceRequestAction; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualEnclavesApprovalDeletionCallbackRequestContent() + { + } + + /// Resource request action indicating action which needed to be performed upon calling approval-deletion-callback post action. + public VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction ResourceRequestAction { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequestResourceRequestAction.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequestResourceRequestAction.cs new file mode 100644 index 000000000000..8266aea8776e --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalDeletionCallbackRequestResourceRequestAction.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction. + public readonly partial struct VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CreateValue = "Create"; + private const string DeleteValue = "Delete"; + private const string UpdateValue = "Update"; + + /// Create. + public static VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction Create { get; } = new VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction(CreateValue); + /// Delete. + public static VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction Delete { get; } = new VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction(DeleteValue); + /// Update. + public static VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction Update { get; } = new VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction(UpdateValue); + /// Determines if two values are the same. + public static bool operator ==(VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction left, VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction left, VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction(string value) => new VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction other && Equals(other); + /// + public bool Equals(VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPatchProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPatchProperties.Serialization.cs new file mode 100644 index 000000000000..19c742c736ef --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPatchProperties.Serialization.cs @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class ApprovalPatchProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalPatchProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ParentResourceId)) + { + writer.WritePropertyName("parentResourceId"u8); + writer.WriteStringValue(ParentResourceId); + } + if (Optional.IsDefined(GrandparentResourceId)) + { + writer.WritePropertyName("grandparentResourceId"u8); + writer.WriteStringValue(GrandparentResourceId); + } + if (Optional.IsCollectionDefined(Approvers)) + { + writer.WritePropertyName("approvers"u8); + writer.WriteStartArray(); + foreach (var item in Approvers) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(TicketId)) + { + writer.WritePropertyName("ticketId"u8); + writer.WriteStringValue(TicketId); + } + if (Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("createdAt"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (Optional.IsDefined(StateChangedOn)) + { + writer.WritePropertyName("stateChangedAt"u8); + writer.WriteStringValue(StateChangedOn.Value, "O"); + } + writer.WritePropertyName("requestMetadata"u8); + writer.WriteObjectValue(RequestMetadata, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ApprovalPatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalPatchProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApprovalPatchProperties(document.RootElement, options); + } + + internal static ApprovalPatchProperties DeserializeApprovalPatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier parentResourceId = default; + ResourceIdentifier grandparentResourceId = default; + IList approvers = default; + string ticketId = default; + DateTimeOffset? createdAt = default; + DateTimeOffset? stateChangedAt = default; + RequestMetadataUpdatableProperties requestMetadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("parentResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parentResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("grandparentResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + grandparentResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("approvers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Approver.DeserializeApprover(item, options)); + } + approvers = array; + continue; + } + if (property.NameEquals("ticketId"u8)) + { + ticketId = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("stateChangedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stateChangedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("requestMetadata"u8)) + { + requestMetadata = RequestMetadataUpdatableProperties.DeserializeRequestMetadataUpdatableProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApprovalPatchProperties( + parentResourceId, + grandparentResourceId, + approvers ?? new ChangeTrackingList(), + ticketId, + createdAt, + stateChangedAt, + requestMetadata, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(ApprovalPatchProperties)} does not support writing '{options.Format}' format."); + } + } + + ApprovalPatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApprovalPatchProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApprovalPatchProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPatchProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPatchProperties.cs new file mode 100644 index 000000000000..c84fb1449916 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPatchProperties.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Approvals patch properties. + public partial class ApprovalPatchProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Request metadata for the approval request. + /// is null. + public ApprovalPatchProperties(RequestMetadataUpdatableProperties requestMetadata) + { + Argument.AssertNotNull(requestMetadata, nameof(requestMetadata)); + + Approvers = new ChangeTrackingList(); + RequestMetadata = requestMetadata; + } + + /// Initializes a new instance of . + /// Parameter for optimizing query results. + /// Parameter for optimizing query results. + /// List of approvers for the approval request. + /// Ticket ID for the approval request. + /// Approval request creation time. + /// Approval request state change time, time at which approval request state changed from pending to approved or rejected. + /// Request metadata for the approval request. + /// Keeps track of any properties unknown to the library. + internal ApprovalPatchProperties(ResourceIdentifier parentResourceId, ResourceIdentifier grandparentResourceId, IList approvers, string ticketId, DateTimeOffset? createdOn, DateTimeOffset? stateChangedOn, RequestMetadataUpdatableProperties requestMetadata, IDictionary serializedAdditionalRawData) + { + ParentResourceId = parentResourceId; + GrandparentResourceId = grandparentResourceId; + Approvers = approvers; + TicketId = ticketId; + CreatedOn = createdOn; + StateChangedOn = stateChangedOn; + RequestMetadata = requestMetadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ApprovalPatchProperties() + { + } + + /// Parameter for optimizing query results. + public ResourceIdentifier ParentResourceId { get; set; } + /// Parameter for optimizing query results. + public ResourceIdentifier GrandparentResourceId { get; set; } + /// List of approvers for the approval request. + public IList Approvers { get; } + /// Ticket ID for the approval request. + public string TicketId { get; set; } + /// Approval request creation time. + public DateTimeOffset? CreatedOn { get; set; } + /// Approval request state change time, time at which approval request state changed from pending to approved or rejected. + public DateTimeOffset? StateChangedOn { get; set; } + /// Request metadata for the approval request. + public RequestMetadataUpdatableProperties RequestMetadata { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPolicy.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPolicy.cs new file mode 100644 index 000000000000..ed6d1761d7b0 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalPolicy.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Approval Policy. + public readonly partial struct ApprovalPolicy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ApprovalPolicy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string RequiredValue = "Required"; + private const string NotRequiredValue = "NotRequired"; + + /// Approval will be required for the specified action. + public static ApprovalPolicy Required { get; } = new ApprovalPolicy(RequiredValue); + /// Approval will not be required for the specified action. + public static ApprovalPolicy NotRequired { get; } = new ApprovalPolicy(NotRequiredValue); + /// Determines if two values are the same. + public static bool operator ==(ApprovalPolicy left, ApprovalPolicy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ApprovalPolicy left, ApprovalPolicy right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ApprovalPolicy(string value) => new ApprovalPolicy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ApprovalPolicy other && Equals(other); + /// + public bool Equals(ApprovalPolicy other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalProperties.Serialization.cs new file mode 100644 index 000000000000..78b88e456ccb --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalProperties.Serialization.cs @@ -0,0 +1,246 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class ApprovalProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalProperties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(ParentResourceId)) + { + writer.WritePropertyName("parentResourceId"u8); + writer.WriteStringValue(ParentResourceId); + } + if (Optional.IsDefined(GrandparentResourceId)) + { + writer.WritePropertyName("grandparentResourceId"u8); + writer.WriteStringValue(GrandparentResourceId); + } + if (Optional.IsCollectionDefined(Approvers)) + { + writer.WritePropertyName("approvers"u8); + writer.WriteStartArray(); + foreach (var item in Approvers) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(TicketId)) + { + writer.WritePropertyName("ticketId"u8); + writer.WriteStringValue(TicketId); + } + if (Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("createdAt"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (Optional.IsDefined(StateChangedOn)) + { + writer.WritePropertyName("stateChangedAt"u8); + writer.WriteStringValue(StateChangedOn.Value, "O"); + } + writer.WritePropertyName("requestMetadata"u8); + writer.WriteObjectValue(RequestMetadata, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ApprovalProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApprovalProperties(document.RootElement, options); + } + + internal static ApprovalProperties DeserializeApprovalProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + ResourceIdentifier parentResourceId = default; + ResourceIdentifier grandparentResourceId = default; + IList approvers = default; + string ticketId = default; + DateTimeOffset? createdAt = default; + DateTimeOffset? stateChangedAt = default; + RequestMetadata requestMetadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("parentResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parentResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("grandparentResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + grandparentResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("approvers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Approver.DeserializeApprover(item, options)); + } + approvers = array; + continue; + } + if (property.NameEquals("ticketId"u8)) + { + ticketId = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("stateChangedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stateChangedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("requestMetadata"u8)) + { + requestMetadata = RequestMetadata.DeserializeRequestMetadata(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApprovalProperties( + provisioningState, + parentResourceId, + grandparentResourceId, + approvers ?? new ChangeTrackingList(), + ticketId, + createdAt, + stateChangedAt, + requestMetadata, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(ApprovalProperties)} does not support writing '{options.Format}' format."); + } + } + + ApprovalProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApprovalProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApprovalProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalProperties.cs new file mode 100644 index 000000000000..68b8f2df9228 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalProperties.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Approval Base model. + public partial class ApprovalProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Request metadata for the approval request. + /// is null. + public ApprovalProperties(RequestMetadata requestMetadata) + { + Argument.AssertNotNull(requestMetadata, nameof(requestMetadata)); + + Approvers = new ChangeTrackingList(); + RequestMetadata = requestMetadata; + } + + /// Initializes a new instance of . + /// Provisioning State. + /// Parameter for optimizing query results. + /// Parameter for optimizing query results. + /// List of approvers for the approval request. + /// Ticket ID for the approval request. + /// Approval request creation time. + /// Approval request state change time, time at which approval request state changed from pending to approved or rejected. + /// Request metadata for the approval request. + /// Keeps track of any properties unknown to the library. + internal ApprovalProperties(ProvisioningState? provisioningState, ResourceIdentifier parentResourceId, ResourceIdentifier grandparentResourceId, IList approvers, string ticketId, DateTimeOffset? createdOn, DateTimeOffset? stateChangedOn, RequestMetadata requestMetadata, IDictionary serializedAdditionalRawData) + { + ProvisioningState = provisioningState; + ParentResourceId = parentResourceId; + GrandparentResourceId = grandparentResourceId; + Approvers = approvers; + TicketId = ticketId; + CreatedOn = createdOn; + StateChangedOn = stateChangedOn; + RequestMetadata = requestMetadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ApprovalProperties() + { + } + + /// Provisioning State. + public ProvisioningState? ProvisioningState { get; } + /// Parameter for optimizing query results. + public ResourceIdentifier ParentResourceId { get; set; } + /// Parameter for optimizing query results. + public ResourceIdentifier GrandparentResourceId { get; set; } + /// List of approvers for the approval request. + public IList Approvers { get; } + /// Ticket ID for the approval request. + public string TicketId { get; set; } + /// Approval request creation time. + public DateTimeOffset? CreatedOn { get; set; } + /// Approval request state change time, time at which approval request state changed from pending to approved or rejected. + public DateTimeOffset? StateChangedOn { get; set; } + /// Request metadata for the approval request. + public RequestMetadata RequestMetadata { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourceListResult.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourceListResult.Serialization.cs new file mode 100644 index 000000000000..7b8436fd5140 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourceListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class ApprovalResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ApprovalResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApprovalResourceListResult(document.RootElement, options); + } + + internal static ApprovalResourceListResult DeserializeApprovalResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ApprovalResourceData.DeserializeApprovalResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApprovalResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(ApprovalResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + ApprovalResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApprovalResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApprovalResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourceListResult.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourceListResult.cs new file mode 100644 index 000000000000..b3d4d7638619 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourceListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The response of a ApprovalResource list operation. + internal partial class ApprovalResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ApprovalResource items on this page. + /// is null. + internal ApprovalResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The ApprovalResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal ApprovalResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ApprovalResourceListResult() + { + } + + /// The ApprovalResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourcePatch.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourcePatch.Serialization.cs new file mode 100644 index 000000000000..9c8402d83f19 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourcePatch.Serialization.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class ApprovalResourcePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalResourcePatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ApprovalResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalResourcePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApprovalResourcePatch(document.RootElement, options); + } + + internal static ApprovalResourcePatch DeserializeApprovalResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ApprovalPatchProperties properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ApprovalPatchProperties.DeserializeApprovalPatchProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApprovalResourcePatch(properties, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(ApprovalResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + ApprovalResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApprovalResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApprovalResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourcePatch.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourcePatch.cs new file mode 100644 index 000000000000..e85044363540 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalResourcePatch.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Approvals patch model. + public partial class ApprovalResourcePatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ApprovalResourcePatch() + { + } + + /// Initializes a new instance of . + /// Approval Patch properties. + /// Keeps track of any properties unknown to the library. + internal ApprovalResourcePatch(ApprovalPatchProperties properties, IDictionary serializedAdditionalRawData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Approval Patch properties. + public ApprovalPatchProperties Properties { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettings.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettings.Serialization.cs new file mode 100644 index 000000000000..9820a23c05fc --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettings.Serialization.cs @@ -0,0 +1,369 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class ApprovalSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalSettings)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(EndpointCreation)) + { + writer.WritePropertyName("endpointCreation"u8); + writer.WriteStringValue(EndpointCreation.Value.ToString()); + } + if (Optional.IsDefined(EndpointUpdate)) + { + writer.WritePropertyName("endpointUpdate"u8); + writer.WriteStringValue(EndpointUpdate.Value.ToString()); + } + if (Optional.IsDefined(EndpointDeletion)) + { + writer.WritePropertyName("endpointDeletion"u8); + writer.WriteStringValue(EndpointDeletion.Value.ToString()); + } + if (Optional.IsDefined(ConnectionCreation)) + { + writer.WritePropertyName("connectionCreation"u8); + writer.WriteStringValue(ConnectionCreation.Value.ToString()); + } + if (Optional.IsDefined(ConnectionUpdate)) + { + writer.WritePropertyName("connectionUpdate"u8); + writer.WriteStringValue(ConnectionUpdate.Value.ToString()); + } + if (Optional.IsDefined(ConnectionDeletion)) + { + writer.WritePropertyName("connectionDeletion"u8); + writer.WriteStringValue(ConnectionDeletion.Value.ToString()); + } + if (Optional.IsDefined(EnclaveCreation)) + { + writer.WritePropertyName("enclaveCreation"u8); + writer.WriteStringValue(EnclaveCreation.Value.ToString()); + } + if (Optional.IsDefined(EnclaveDeletion)) + { + writer.WritePropertyName("enclaveDeletion"u8); + writer.WriteStringValue(EnclaveDeletion.Value.ToString()); + } + if (Optional.IsDefined(MaintenanceMode)) + { + writer.WritePropertyName("maintenanceMode"u8); + writer.WriteStringValue(MaintenanceMode.Value.ToString()); + } + if (Optional.IsDefined(ServiceCatalogDeployment)) + { + writer.WritePropertyName("serviceCatalogDeployment"u8); + writer.WriteStringValue(ServiceCatalogDeployment.Value.ToString()); + } + if (Optional.IsDefined(NotificationOnApprovalCreation)) + { + writer.WritePropertyName("notificationOnApprovalCreation"u8); + writer.WriteStringValue(NotificationOnApprovalCreation.Value.ToString()); + } + if (Optional.IsDefined(NotificationOnApprovalAction)) + { + writer.WritePropertyName("notificationOnApprovalAction"u8); + writer.WriteStringValue(NotificationOnApprovalAction.Value.ToString()); + } + if (Optional.IsDefined(NotificationOnApprovalDeletion)) + { + writer.WritePropertyName("notificationOnApprovalDeletion"u8); + writer.WriteStringValue(NotificationOnApprovalDeletion.Value.ToString()); + } + if (Optional.IsCollectionDefined(MandatoryApprovers)) + { + writer.WritePropertyName("mandatoryApprovers"u8); + writer.WriteStartArray(); + foreach (var item in MandatoryApprovers) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(MinimumApproversRequired)) + { + writer.WritePropertyName("minimumApproversRequired"u8); + writer.WriteNumberValue(MinimumApproversRequired.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ApprovalSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApprovalSettings(document.RootElement, options); + } + + internal static ApprovalSettings DeserializeApprovalSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ApprovalPolicy? endpointCreation = default; + ApprovalPolicy? endpointUpdate = default; + ApprovalPolicy? endpointDeletion = default; + ApprovalPolicy? connectionCreation = default; + ApprovalPolicy? connectionUpdate = default; + ApprovalPolicy? connectionDeletion = default; + ApprovalPolicy? enclaveCreation = default; + ApprovalPolicy? enclaveDeletion = default; + ApprovalPolicy? maintenanceMode = default; + ApprovalPolicy? serviceCatalogDeployment = default; + ApprovalPolicy? notificationOnApprovalCreation = default; + ApprovalPolicy? notificationOnApprovalAction = default; + ApprovalPolicy? notificationOnApprovalDeletion = default; + IList mandatoryApprovers = default; + long? minimumApproversRequired = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("endpointCreation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endpointCreation = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("endpointUpdate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endpointUpdate = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("endpointDeletion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endpointDeletion = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("connectionCreation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + connectionCreation = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("connectionUpdate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + connectionUpdate = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("connectionDeletion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + connectionDeletion = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("enclaveCreation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enclaveCreation = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("enclaveDeletion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enclaveDeletion = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("maintenanceMode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maintenanceMode = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("serviceCatalogDeployment"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + serviceCatalogDeployment = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("notificationOnApprovalCreation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + notificationOnApprovalCreation = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("notificationOnApprovalAction"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + notificationOnApprovalAction = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("notificationOnApprovalDeletion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + notificationOnApprovalDeletion = new ApprovalPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("mandatoryApprovers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MandatoryApprover.DeserializeMandatoryApprover(item, options)); + } + mandatoryApprovers = array; + continue; + } + if (property.NameEquals("minimumApproversRequired"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minimumApproversRequired = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApprovalSettings( + endpointCreation, + endpointUpdate, + endpointDeletion, + connectionCreation, + connectionUpdate, + connectionDeletion, + enclaveCreation, + enclaveDeletion, + maintenanceMode, + serviceCatalogDeployment, + notificationOnApprovalCreation, + notificationOnApprovalAction, + notificationOnApprovalDeletion, + mandatoryApprovers ?? new ChangeTrackingList(), + minimumApproversRequired, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(ApprovalSettings)} does not support writing '{options.Format}' format."); + } + } + + ApprovalSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApprovalSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApprovalSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettings.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettings.cs new file mode 100644 index 000000000000..645bd4d75395 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettings.cs @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// ApprovalSettings Properties. + public partial class ApprovalSettings + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ApprovalSettings() + { + MandatoryApprovers = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Approval required for endpoint creation (Required or NotRequired). + /// Approval required for endpoint update (Required or NotRequired). + /// Approval required for endpoint deletion (Required or NotRequired). + /// Approval required for enclave connection creation (Required or NotRequired). + /// Approval required for enclave connection update (Required or NotRequired). + /// Approval required for enclave connection deletion (Required or NotRequired). + /// Approval required for virtual enclave creation (Required or NotRequired). + /// Approval required for virtual enclave deletion (Required or NotRequired). + /// Approval required for toggling maintenance mode (Required or NotRequired). + /// Approval required for deploying service catalog templates (Required or NotRequired). + /// Notification will be sent on creation of an Approval Request. + /// Notification will be sent on any action taken (Approve/Reject) on an Approval Request. + /// Notification will be sent on deletion of an Approval Request. + /// List of mandatory approvers for the approval request. + /// Minimum number of approvers required for the approval request. + /// Keeps track of any properties unknown to the library. + internal ApprovalSettings(ApprovalPolicy? endpointCreation, ApprovalPolicy? endpointUpdate, ApprovalPolicy? endpointDeletion, ApprovalPolicy? connectionCreation, ApprovalPolicy? connectionUpdate, ApprovalPolicy? connectionDeletion, ApprovalPolicy? enclaveCreation, ApprovalPolicy? enclaveDeletion, ApprovalPolicy? maintenanceMode, ApprovalPolicy? serviceCatalogDeployment, ApprovalPolicy? notificationOnApprovalCreation, ApprovalPolicy? notificationOnApprovalAction, ApprovalPolicy? notificationOnApprovalDeletion, IList mandatoryApprovers, long? minimumApproversRequired, IDictionary serializedAdditionalRawData) + { + EndpointCreation = endpointCreation; + EndpointUpdate = endpointUpdate; + EndpointDeletion = endpointDeletion; + ConnectionCreation = connectionCreation; + ConnectionUpdate = connectionUpdate; + ConnectionDeletion = connectionDeletion; + EnclaveCreation = enclaveCreation; + EnclaveDeletion = enclaveDeletion; + MaintenanceMode = maintenanceMode; + ServiceCatalogDeployment = serviceCatalogDeployment; + NotificationOnApprovalCreation = notificationOnApprovalCreation; + NotificationOnApprovalAction = notificationOnApprovalAction; + NotificationOnApprovalDeletion = notificationOnApprovalDeletion; + MandatoryApprovers = mandatoryApprovers; + MinimumApproversRequired = minimumApproversRequired; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Approval required for endpoint creation (Required or NotRequired). + public ApprovalPolicy? EndpointCreation { get; set; } + /// Approval required for endpoint update (Required or NotRequired). + public ApprovalPolicy? EndpointUpdate { get; set; } + /// Approval required for endpoint deletion (Required or NotRequired). + public ApprovalPolicy? EndpointDeletion { get; set; } + /// Approval required for enclave connection creation (Required or NotRequired). + public ApprovalPolicy? ConnectionCreation { get; set; } + /// Approval required for enclave connection update (Required or NotRequired). + public ApprovalPolicy? ConnectionUpdate { get; set; } + /// Approval required for enclave connection deletion (Required or NotRequired). + public ApprovalPolicy? ConnectionDeletion { get; set; } + /// Approval required for virtual enclave creation (Required or NotRequired). + public ApprovalPolicy? EnclaveCreation { get; set; } + /// Approval required for virtual enclave deletion (Required or NotRequired). + public ApprovalPolicy? EnclaveDeletion { get; set; } + /// Approval required for toggling maintenance mode (Required or NotRequired). + public ApprovalPolicy? MaintenanceMode { get; set; } + /// Approval required for deploying service catalog templates (Required or NotRequired). + public ApprovalPolicy? ServiceCatalogDeployment { get; set; } + /// Notification will be sent on creation of an Approval Request. + public ApprovalPolicy? NotificationOnApprovalCreation { get; set; } + /// Notification will be sent on any action taken (Approve/Reject) on an Approval Request. + public ApprovalPolicy? NotificationOnApprovalAction { get; set; } + /// Notification will be sent on deletion of an Approval Request. + public ApprovalPolicy? NotificationOnApprovalDeletion { get; set; } + /// List of mandatory approvers for the approval request. + public IList MandatoryApprovers { get; } + /// Minimum number of approvers required for the approval request. + public long? MinimumApproversRequired { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettingsPatchProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettingsPatchProperties.Serialization.cs new file mode 100644 index 000000000000..7faf5cb75408 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettingsPatchProperties.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class ApprovalSettingsPatchProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalSettingsPatchProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(MandatoryApprovers)) + { + writer.WritePropertyName("mandatoryApprovers"u8); + writer.WriteStartArray(); + foreach (var item in MandatoryApprovers) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ApprovalSettingsPatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApprovalSettingsPatchProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApprovalSettingsPatchProperties(document.RootElement, options); + } + + internal static ApprovalSettingsPatchProperties DeserializeApprovalSettingsPatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList mandatoryApprovers = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("mandatoryApprovers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MandatoryApprover.DeserializeMandatoryApprover(item, options)); + } + mandatoryApprovers = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApprovalSettingsPatchProperties(mandatoryApprovers ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(ApprovalSettingsPatchProperties)} does not support writing '{options.Format}' format."); + } + } + + ApprovalSettingsPatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApprovalSettingsPatchProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApprovalSettingsPatchProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettingsPatchProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettingsPatchProperties.cs new file mode 100644 index 000000000000..45d4e2e98683 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalSettingsPatchProperties.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// ApprovalSettings Properties. + internal partial class ApprovalSettingsPatchProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ApprovalSettingsPatchProperties() + { + MandatoryApprovers = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of mandatory approvers for the approval request. + /// Keeps track of any properties unknown to the library. + internal ApprovalSettingsPatchProperties(IList mandatoryApprovers, IDictionary serializedAdditionalRawData) + { + MandatoryApprovers = mandatoryApprovers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// List of mandatory approvers for the approval request. + public IList MandatoryApprovers { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalStatus.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalStatus.cs new file mode 100644 index 000000000000..6db38efeccb9 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ApprovalStatus.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Approval Status. It can be Approved, Rejected, Pending, Deleted or Expired. + public readonly partial struct ApprovalStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ApprovalStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ApprovedValue = "Approved"; + private const string RejectedValue = "Rejected"; + private const string PendingValue = "Pending"; + private const string DeletedValue = "Deleted"; + private const string ExpiredValue = "Expired"; + + /// ApprovalStatus Type Approved. + public static ApprovalStatus Approved { get; } = new ApprovalStatus(ApprovedValue); + /// ApprovalStatus Type Rejected. + public static ApprovalStatus Rejected { get; } = new ApprovalStatus(RejectedValue); + /// ApprovalStatus Type Pending. + public static ApprovalStatus Pending { get; } = new ApprovalStatus(PendingValue); + /// ApprovalStatus Type Deleted. + public static ApprovalStatus Deleted { get; } = new ApprovalStatus(DeletedValue); + /// ApprovalStatus Type Expired. + public static ApprovalStatus Expired { get; } = new ApprovalStatus(ExpiredValue); + /// Determines if two values are the same. + public static bool operator ==(ApprovalStatus left, ApprovalStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ApprovalStatus left, ApprovalStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ApprovalStatus(string value) => new ApprovalStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ApprovalStatus other && Equals(other); + /// + public bool Equals(ApprovalStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Approver.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Approver.Serialization.cs new file mode 100644 index 000000000000..2bce2a2f10d8 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Approver.Serialization.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class Approver : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Approver)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("approverEntraId"u8); + writer.WriteStringValue(ApproverEntraId); + if (Optional.IsDefined(ActionPerformed)) + { + writer.WritePropertyName("actionPerformed"u8); + writer.WriteStringValue(ActionPerformed.Value.ToString()); + } + writer.WritePropertyName("lastUpdatedAt"u8); + writer.WriteStringValue(LastUpdatedOn, "O"); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Approver IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Approver)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApprover(document.RootElement, options); + } + + internal static Approver DeserializeApprover(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string approverEntraId = default; + ActionPerformed? actionPerformed = default; + DateTimeOffset lastUpdatedAt = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("approverEntraId"u8)) + { + approverEntraId = property.Value.GetString(); + continue; + } + if (property.NameEquals("actionPerformed"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + actionPerformed = new ActionPerformed(property.Value.GetString()); + continue; + } + if (property.NameEquals("lastUpdatedAt"u8)) + { + lastUpdatedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Approver(approverEntraId, actionPerformed, lastUpdatedAt, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(Approver)} does not support writing '{options.Format}' format."); + } + } + + Approver IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApprover(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Approver)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Approver.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Approver.cs new file mode 100644 index 000000000000..74a996bc05e2 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Approver.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Approver Metadata for approvals request. + public partial class Approver + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Entra ObjectID of the approver. + /// approval request last updated at. + /// is null. + public Approver(string approverEntraId, DateTimeOffset lastUpdatedOn) + { + Argument.AssertNotNull(approverEntraId, nameof(approverEntraId)); + + ApproverEntraId = approverEntraId; + LastUpdatedOn = lastUpdatedOn; + } + + /// Initializes a new instance of . + /// Entra ObjectID of the approver. + /// Action Performed by approver. + /// approval request last updated at. + /// Keeps track of any properties unknown to the library. + internal Approver(string approverEntraId, ActionPerformed? actionPerformed, DateTimeOffset lastUpdatedOn, IDictionary serializedAdditionalRawData) + { + ApproverEntraId = approverEntraId; + ActionPerformed = actionPerformed; + LastUpdatedOn = lastUpdatedOn; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Approver() + { + } + + /// Entra ObjectID of the approver. + public string ApproverEntraId { get; set; } + /// Action Performed by approver. + public ActionPerformed? ActionPerformed { get; set; } + /// approval request last updated at. + public DateTimeOffset LastUpdatedOn { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/AzureResourceManagerVirtualEnclavesContext.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/AzureResourceManagerVirtualEnclavesContext.cs new file mode 100644 index 000000000000..a6e7c3dcd64d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/AzureResourceManagerVirtualEnclavesContext.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md' + /// + [ModelReaderWriterBuildable(typeof(ApprovalActionContent))] + [ModelReaderWriterBuildable(typeof(ApprovalActionResponse))] + [ModelReaderWriterBuildable(typeof(ApprovalCallbackRequest))] + [ModelReaderWriterBuildable(typeof(VirtualEnclavesApprovalDeletionCallbackRequestContent))] + [ModelReaderWriterBuildable(typeof(ApprovalPatchProperties))] + [ModelReaderWriterBuildable(typeof(ApprovalProperties))] + [ModelReaderWriterBuildable(typeof(ApprovalResource))] + [ModelReaderWriterBuildable(typeof(ApprovalResourceData))] + [ModelReaderWriterBuildable(typeof(ApprovalResourceListResult))] + [ModelReaderWriterBuildable(typeof(ApprovalResourcePatch))] + [ModelReaderWriterBuildable(typeof(ApprovalSettings))] + [ModelReaderWriterBuildable(typeof(ApprovalSettingsPatchProperties))] + [ModelReaderWriterBuildable(typeof(Approver))] + [ModelReaderWriterBuildable(typeof(CheckAddressSpaceAvailabilityContent))] + [ModelReaderWriterBuildable(typeof(CheckAddressSpaceAvailabilityResponse))] + [ModelReaderWriterBuildable(typeof(CommunityEndpointDestinationRule))] + [ModelReaderWriterBuildable(typeof(CommunityEndpointPatchProperties))] + [ModelReaderWriterBuildable(typeof(CommunityEndpointProperties))] + [ModelReaderWriterBuildable(typeof(CommunityEndpointResource))] + [ModelReaderWriterBuildable(typeof(CommunityEndpointResourceData))] + [ModelReaderWriterBuildable(typeof(CommunityEndpointResourceListResult))] + [ModelReaderWriterBuildable(typeof(CommunityEndpointResourcePatch))] + [ModelReaderWriterBuildable(typeof(CommunityPatchProperties))] + [ModelReaderWriterBuildable(typeof(CommunityProperties))] + [ModelReaderWriterBuildable(typeof(CommunityResource))] + [ModelReaderWriterBuildable(typeof(CommunityResourceData))] + [ModelReaderWriterBuildable(typeof(CommunityResourceListResult))] + [ModelReaderWriterBuildable(typeof(CommunityResourcePatch))] + [ModelReaderWriterBuildable(typeof(EnclaveAddressSpacesModel))] + [ModelReaderWriterBuildable(typeof(EnclaveConnectionPatchProperties))] + [ModelReaderWriterBuildable(typeof(EnclaveConnectionProperties))] + [ModelReaderWriterBuildable(typeof(EnclaveConnectionResource))] + [ModelReaderWriterBuildable(typeof(EnclaveConnectionResourceData))] + [ModelReaderWriterBuildable(typeof(EnclaveConnectionResourceListResult))] + [ModelReaderWriterBuildable(typeof(EnclaveConnectionResourcePatch))] + [ModelReaderWriterBuildable(typeof(EnclaveDefaultSettingsModel))] + [ModelReaderWriterBuildable(typeof(EnclaveDefaultSettingsPatchModel))] + [ModelReaderWriterBuildable(typeof(EnclaveEndpointDestinationRule))] + [ModelReaderWriterBuildable(typeof(EnclaveEndpointPatchProperties))] + [ModelReaderWriterBuildable(typeof(EnclaveEndpointProperties))] + [ModelReaderWriterBuildable(typeof(EnclaveEndpointResource))] + [ModelReaderWriterBuildable(typeof(EnclaveEndpointResourceData))] + [ModelReaderWriterBuildable(typeof(EnclaveEndpointResourceListResult))] + [ModelReaderWriterBuildable(typeof(EnclaveEndpointResourcePatch))] + [ModelReaderWriterBuildable(typeof(EnclaveResource))] + [ModelReaderWriterBuildable(typeof(EnclaveResourceData))] + [ModelReaderWriterBuildable(typeof(EnclaveResourceListResult))] + [ModelReaderWriterBuildable(typeof(EnclaveResourcePatch))] + [ModelReaderWriterBuildable(typeof(EnclaveVirtualNetworkModel))] + [ModelReaderWriterBuildable(typeof(GovernedServiceItem))] + [ModelReaderWriterBuildable(typeof(MaintenanceModeConfigurationModel))] + [ModelReaderWriterBuildable(typeof(MaintenanceModeConfigurationPatchModel))] + [ModelReaderWriterBuildable(typeof(ManagedOnBehalfOfConfiguration))] + [ModelReaderWriterBuildable(typeof(ManagedServiceIdentity))] + [ModelReaderWriterBuildable(typeof(MandatoryApprover))] + [ModelReaderWriterBuildable(typeof(Principal))] + [ModelReaderWriterBuildable(typeof(RequestMetadata))] + [ModelReaderWriterBuildable(typeof(RequestMetadataUpdatableProperties))] + [ModelReaderWriterBuildable(typeof(ResponseError))] + [ModelReaderWriterBuildable(typeof(RoleAssignmentItem))] + [ModelReaderWriterBuildable(typeof(SubnetConfiguration))] + [ModelReaderWriterBuildable(typeof(SubResource))] + [ModelReaderWriterBuildable(typeof(SystemData))] + [ModelReaderWriterBuildable(typeof(TransitHubPatchProperties))] + [ModelReaderWriterBuildable(typeof(TransitHubProperties))] + [ModelReaderWriterBuildable(typeof(TransitHubResource))] + [ModelReaderWriterBuildable(typeof(TransitHubResourceData))] + [ModelReaderWriterBuildable(typeof(TransitHubResourceListResult))] + [ModelReaderWriterBuildable(typeof(TransitHubResourcePatch))] + [ModelReaderWriterBuildable(typeof(TransitOption))] + [ModelReaderWriterBuildable(typeof(TransitOptionParams))] + [ModelReaderWriterBuildable(typeof(UserAssignedIdentity))] + [ModelReaderWriterBuildable(typeof(VirtualEnclavePatchProperties))] + [ModelReaderWriterBuildable(typeof(VirtualEnclaveProperties))] + [ModelReaderWriterBuildable(typeof(WorkloadPatchProperties))] + [ModelReaderWriterBuildable(typeof(WorkloadProperties))] + [ModelReaderWriterBuildable(typeof(WorkloadResource))] + [ModelReaderWriterBuildable(typeof(WorkloadResourceData))] + [ModelReaderWriterBuildable(typeof(WorkloadResourceListResult))] + [ModelReaderWriterBuildable(typeof(WorkloadResourcePatch))] + public partial class AzureResourceManagerVirtualEnclavesContext : ModelReaderWriterContext + { + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityContent.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityContent.Serialization.cs new file mode 100644 index 000000000000..33e386bea852 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityContent.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class CheckAddressSpaceAvailabilityContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckAddressSpaceAvailabilityContent)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("communityResourceId"u8); + writer.WriteStringValue(CommunityResourceId); + writer.WritePropertyName("enclaveVirtualNetwork"u8); + writer.WriteObjectValue(EnclaveVirtualNetwork, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CheckAddressSpaceAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckAddressSpaceAvailabilityContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCheckAddressSpaceAvailabilityContent(document.RootElement, options); + } + + internal static CheckAddressSpaceAvailabilityContent DeserializeCheckAddressSpaceAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier communityResourceId = default; + EnclaveVirtualNetworkModel enclaveVirtualNetwork = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("communityResourceId"u8)) + { + communityResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("enclaveVirtualNetwork"u8)) + { + enclaveVirtualNetwork = EnclaveVirtualNetworkModel.DeserializeEnclaveVirtualNetworkModel(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CheckAddressSpaceAvailabilityContent(communityResourceId, enclaveVirtualNetwork, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CheckAddressSpaceAvailabilityContent)} does not support writing '{options.Format}' format."); + } + } + + CheckAddressSpaceAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCheckAddressSpaceAvailabilityContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CheckAddressSpaceAvailabilityContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityContent.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityContent.cs new file mode 100644 index 000000000000..4cbb0fdf0631 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityContent.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Request to the action call to check address space availability. + public partial class CheckAddressSpaceAvailabilityContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Resource Id of the Community. + /// Information about the enclave virtual network. + /// or is null. + public CheckAddressSpaceAvailabilityContent(ResourceIdentifier communityResourceId, EnclaveVirtualNetworkModel enclaveVirtualNetwork) + { + Argument.AssertNotNull(communityResourceId, nameof(communityResourceId)); + Argument.AssertNotNull(enclaveVirtualNetwork, nameof(enclaveVirtualNetwork)); + + CommunityResourceId = communityResourceId; + EnclaveVirtualNetwork = enclaveVirtualNetwork; + } + + /// Initializes a new instance of . + /// Resource Id of the Community. + /// Information about the enclave virtual network. + /// Keeps track of any properties unknown to the library. + internal CheckAddressSpaceAvailabilityContent(ResourceIdentifier communityResourceId, EnclaveVirtualNetworkModel enclaveVirtualNetwork, IDictionary serializedAdditionalRawData) + { + CommunityResourceId = communityResourceId; + EnclaveVirtualNetwork = enclaveVirtualNetwork; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CheckAddressSpaceAvailabilityContent() + { + } + + /// Resource Id of the Community. + public ResourceIdentifier CommunityResourceId { get; } + /// Information about the enclave virtual network. + public EnclaveVirtualNetworkModel EnclaveVirtualNetwork { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityResponse.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityResponse.Serialization.cs new file mode 100644 index 000000000000..c79a2e83bd22 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityResponse.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class CheckAddressSpaceAvailabilityResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckAddressSpaceAvailabilityResponse)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteBooleanValue(Value); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CheckAddressSpaceAvailabilityResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckAddressSpaceAvailabilityResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCheckAddressSpaceAvailabilityResponse(document.RootElement, options); + } + + internal static CheckAddressSpaceAvailabilityResponse DeserializeCheckAddressSpaceAvailabilityResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CheckAddressSpaceAvailabilityResponse(value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CheckAddressSpaceAvailabilityResponse)} does not support writing '{options.Format}' format."); + } + } + + CheckAddressSpaceAvailabilityResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCheckAddressSpaceAvailabilityResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CheckAddressSpaceAvailabilityResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityResponse.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityResponse.cs new file mode 100644 index 000000000000..8a230c99f5d3 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CheckAddressSpaceAvailabilityResponse.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Response of availability of the requested address space. + public partial class CheckAddressSpaceAvailabilityResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Boolean representing whether the address space is available. + internal CheckAddressSpaceAvailabilityResponse(bool value) + { + Value = value; + } + + /// Initializes a new instance of . + /// Boolean representing whether the address space is available. + /// Keeps track of any properties unknown to the library. + internal CheckAddressSpaceAvailabilityResponse(bool value, IDictionary serializedAdditionalRawData) + { + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CheckAddressSpaceAvailabilityResponse() + { + } + + /// Boolean representing whether the address space is available. + public bool Value { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointDestinationRule.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointDestinationRule.Serialization.cs new file mode 100644 index 000000000000..a31d345a4a59 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointDestinationRule.Serialization.cs @@ -0,0 +1,213 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class CommunityEndpointDestinationRule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointDestinationRule)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(DestinationType)) + { + writer.WritePropertyName("destinationType"u8); + writer.WriteStringValue(DestinationType.Value.ToString()); + } + if (Optional.IsCollectionDefined(Protocols)) + { + writer.WritePropertyName("protocols"u8); + writer.WriteStartArray(); + foreach (var item in Protocols) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(TransitHubResourceId)) + { + writer.WritePropertyName("transitHubResourceId"u8); + writer.WriteStringValue(TransitHubResourceId); + } + if (Optional.IsDefined(EndpointRuleName)) + { + writer.WritePropertyName("endpointRuleName"u8); + writer.WriteStringValue(EndpointRuleName); + } + if (Optional.IsDefined(Destination)) + { + writer.WritePropertyName("destination"u8); + writer.WriteStringValue(Destination); + } + if (Optional.IsDefined(Ports)) + { + writer.WritePropertyName("ports"u8); + writer.WriteStringValue(Ports); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CommunityEndpointDestinationRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointDestinationRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommunityEndpointDestinationRule(document.RootElement, options); + } + + internal static CommunityEndpointDestinationRule DeserializeCommunityEndpointDestinationRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DestinationType? destinationType = default; + IList protocols = default; + ResourceIdentifier transitHubResourceId = default; + string endpointRuleName = default; + string destination = default; + string ports = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("destinationType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + destinationType = new DestinationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("protocols"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new CommunityEndpointProtocol(item.GetString())); + } + protocols = array; + continue; + } + if (property.NameEquals("transitHubResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + transitHubResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("endpointRuleName"u8)) + { + endpointRuleName = property.Value.GetString(); + continue; + } + if (property.NameEquals("destination"u8)) + { + destination = property.Value.GetString(); + continue; + } + if (property.NameEquals("ports"u8)) + { + ports = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommunityEndpointDestinationRule( + destinationType, + protocols ?? new ChangeTrackingList(), + transitHubResourceId, + endpointRuleName, + destination, + ports, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CommunityEndpointDestinationRule)} does not support writing '{options.Format}' format."); + } + } + + CommunityEndpointDestinationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCommunityEndpointDestinationRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommunityEndpointDestinationRule)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointDestinationRule.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointDestinationRule.cs new file mode 100644 index 000000000000..8130c6941ead --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointDestinationRule.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Base type for destination rules. + public partial class CommunityEndpointDestinationRule + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public CommunityEndpointDestinationRule() + { + Protocols = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Destination Type. + /// Protocols. Options specified by Endpoint Protocol Enum. + /// Transit Hub Resource Id. + /// Endpoint Rule Name. + /// Destination address. Can include multiple CIDR/IP Addresses or fqdn tags or fqdns (for community endpoint) separated by commas. + /// Port. Can include multiple ports separated by commas or a range indicated by a hyphen. + /// Keeps track of any properties unknown to the library. + internal CommunityEndpointDestinationRule(DestinationType? destinationType, IList protocols, ResourceIdentifier transitHubResourceId, string endpointRuleName, string destination, string ports, IDictionary serializedAdditionalRawData) + { + DestinationType = destinationType; + Protocols = protocols; + TransitHubResourceId = transitHubResourceId; + EndpointRuleName = endpointRuleName; + Destination = destination; + Ports = ports; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Destination Type. + public DestinationType? DestinationType { get; set; } + /// Protocols. Options specified by Endpoint Protocol Enum. + public IList Protocols { get; } + /// Transit Hub Resource Id. + public ResourceIdentifier TransitHubResourceId { get; set; } + /// Endpoint Rule Name. + public string EndpointRuleName { get; set; } + /// Destination address. Can include multiple CIDR/IP Addresses or fqdn tags or fqdns (for community endpoint) separated by commas. + public string Destination { get; set; } + /// Port. Can include multiple ports separated by commas or a range indicated by a hyphen. + public string Ports { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointPatchProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointPatchProperties.Serialization.cs new file mode 100644 index 000000000000..fc9561f90688 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointPatchProperties.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class CommunityEndpointPatchProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointPatchProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("ruleCollection"u8); + writer.WriteStartArray(); + foreach (var item in RuleCollection) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CommunityEndpointPatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointPatchProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommunityEndpointPatchProperties(document.RootElement, options); + } + + internal static CommunityEndpointPatchProperties DeserializeCommunityEndpointPatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList ruleCollection = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ruleCollection"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CommunityEndpointDestinationRule.DeserializeCommunityEndpointDestinationRule(item, options)); + } + ruleCollection = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommunityEndpointPatchProperties(ruleCollection, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CommunityEndpointPatchProperties)} does not support writing '{options.Format}' format."); + } + } + + CommunityEndpointPatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCommunityEndpointPatchProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommunityEndpointPatchProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointPatchProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointPatchProperties.cs new file mode 100644 index 000000000000..03c72a0d97b1 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointPatchProperties.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Community Endpoint patchable Properties. + internal partial class CommunityEndpointPatchProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Community Endpoint Rule Collection. + /// is null. + public CommunityEndpointPatchProperties(IEnumerable ruleCollection) + { + Argument.AssertNotNull(ruleCollection, nameof(ruleCollection)); + + RuleCollection = ruleCollection.ToList(); + } + + /// Initializes a new instance of . + /// Community Endpoint Rule Collection. + /// Keeps track of any properties unknown to the library. + internal CommunityEndpointPatchProperties(IList ruleCollection, IDictionary serializedAdditionalRawData) + { + RuleCollection = ruleCollection; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CommunityEndpointPatchProperties() + { + } + + /// Community Endpoint Rule Collection. + public IList RuleCollection { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProperties.Serialization.cs new file mode 100644 index 000000000000..ba538a8816a5 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProperties.Serialization.cs @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class CommunityEndpointProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("ruleCollection"u8); + writer.WriteStartArray(); + foreach (var item in RuleCollection) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && Optional.IsCollectionDefined(ResourceCollection)) + { + writer.WritePropertyName("resourceCollection"u8); + writer.WriteStartArray(); + foreach (var item in ResourceCollection) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CommunityEndpointProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommunityEndpointProperties(document.RootElement, options); + } + + internal static CommunityEndpointProperties DeserializeCommunityEndpointProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList ruleCollection = default; + IReadOnlyList resourceCollection = default; + ProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ruleCollection"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CommunityEndpointDestinationRule.DeserializeCommunityEndpointDestinationRule(item, options)); + } + ruleCollection = array; + continue; + } + if (property.NameEquals("resourceCollection"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new ResourceIdentifier(item.GetString())); + } + } + resourceCollection = array; + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommunityEndpointProperties(ruleCollection, resourceCollection ?? new ChangeTrackingList(), provisioningState, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CommunityEndpointProperties)} does not support writing '{options.Format}' format."); + } + } + + CommunityEndpointProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCommunityEndpointProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommunityEndpointProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProperties.cs new file mode 100644 index 000000000000..20162d23eff3 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProperties.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Community Endpoint Resource properties. + public partial class CommunityEndpointProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Community Endpoint Rule Collection. + /// is null. + public CommunityEndpointProperties(IEnumerable ruleCollection) + { + Argument.AssertNotNull(ruleCollection, nameof(ruleCollection)); + + RuleCollection = ruleCollection.ToList(); + ResourceCollection = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Community Endpoint Rule Collection. + /// List of resource ids created by community endpoint. + /// Provisioning State. + /// Keeps track of any properties unknown to the library. + internal CommunityEndpointProperties(IList ruleCollection, IReadOnlyList resourceCollection, ProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + RuleCollection = ruleCollection; + ResourceCollection = resourceCollection; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CommunityEndpointProperties() + { + } + + /// Community Endpoint Rule Collection. + public IList RuleCollection { get; } + /// List of resource ids created by community endpoint. + public IReadOnlyList ResourceCollection { get; } + /// Provisioning State. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProtocol.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProtocol.cs new file mode 100644 index 000000000000..05a0b4f196a2 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointProtocol.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Community Endpoint Protocol Enum. + public readonly partial struct CommunityEndpointProtocol : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CommunityEndpointProtocol(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ANYValue = "ANY"; + private const string TCPValue = "TCP"; + private const string UDPValue = "UDP"; + private const string ICMPValue = "ICMP"; + private const string ESPValue = "ESP"; + private const string AHValue = "AH"; + private const string HTTPSValue = "HTTPS"; + private const string HTTPValue = "HTTP"; + + /// CommunityEndpointProtocol Type ANY. + public static CommunityEndpointProtocol ANY { get; } = new CommunityEndpointProtocol(ANYValue); + /// CommunityEndpointProtocol Type TCP. + public static CommunityEndpointProtocol TCP { get; } = new CommunityEndpointProtocol(TCPValue); + /// CommunityEndpointProtocol Type UDP. + public static CommunityEndpointProtocol UDP { get; } = new CommunityEndpointProtocol(UDPValue); + /// CommunityEndpointProtocol Type ICMP. + public static CommunityEndpointProtocol ICMP { get; } = new CommunityEndpointProtocol(ICMPValue); + /// CommunityEndpointProtocol Type ESP. + public static CommunityEndpointProtocol ESP { get; } = new CommunityEndpointProtocol(ESPValue); + /// CommunityEndpointProtocol Type AH. + public static CommunityEndpointProtocol AH { get; } = new CommunityEndpointProtocol(AHValue); + /// CommunityEndpointProtocol Type HTTPS. + public static CommunityEndpointProtocol HTTPS { get; } = new CommunityEndpointProtocol(HTTPSValue); + /// CommunityEndpointProtocol Type HTTP. + public static CommunityEndpointProtocol HTTP { get; } = new CommunityEndpointProtocol(HTTPValue); + /// Determines if two values are the same. + public static bool operator ==(CommunityEndpointProtocol left, CommunityEndpointProtocol right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CommunityEndpointProtocol left, CommunityEndpointProtocol right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CommunityEndpointProtocol(string value) => new CommunityEndpointProtocol(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CommunityEndpointProtocol other && Equals(other); + /// + public bool Equals(CommunityEndpointProtocol other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourceListResult.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourceListResult.Serialization.cs new file mode 100644 index 000000000000..79c86ea53d29 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourceListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class CommunityEndpointResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CommunityEndpointResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommunityEndpointResourceListResult(document.RootElement, options); + } + + internal static CommunityEndpointResourceListResult DeserializeCommunityEndpointResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CommunityEndpointResourceData.DeserializeCommunityEndpointResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommunityEndpointResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CommunityEndpointResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + CommunityEndpointResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCommunityEndpointResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommunityEndpointResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourceListResult.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourceListResult.cs new file mode 100644 index 000000000000..396fef7f2760 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourceListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The response of a CommunityEndpointResource list operation. + internal partial class CommunityEndpointResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The CommunityEndpointResource items on this page. + /// is null. + internal CommunityEndpointResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The CommunityEndpointResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal CommunityEndpointResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CommunityEndpointResourceListResult() + { + } + + /// The CommunityEndpointResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourcePatch.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourcePatch.Serialization.cs new file mode 100644 index 000000000000..1088c32aaa87 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourcePatch.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class CommunityEndpointResourcePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointResourcePatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CommunityEndpointResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityEndpointResourcePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommunityEndpointResourcePatch(document.RootElement, options); + } + + internal static CommunityEndpointResourcePatch DeserializeCommunityEndpointResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CommunityEndpointPatchProperties properties = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = CommunityEndpointPatchProperties.DeserializeCommunityEndpointPatchProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommunityEndpointResourcePatch(properties, tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CommunityEndpointResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + CommunityEndpointResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCommunityEndpointResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommunityEndpointResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourcePatch.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourcePatch.cs new file mode 100644 index 000000000000..546d94660d33 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityEndpointResourcePatch.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Community Endpoint Patch Resource. + public partial class CommunityEndpointResourcePatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public CommunityEndpointResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Community Endpoint Patch properties. + /// Resource tags. + /// Keeps track of any properties unknown to the library. + internal CommunityEndpointResourcePatch(CommunityEndpointPatchProperties properties, IDictionary tags, IDictionary serializedAdditionalRawData) + { + Properties = properties; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Community Endpoint Patch properties. + internal CommunityEndpointPatchProperties Properties { get; set; } + /// Community Endpoint Rule Collection. + public IList CommunityEndpointPatchRuleCollection + { + get => Properties is null ? default : Properties.RuleCollection; + set => Properties = new CommunityEndpointPatchProperties(value); + } + + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPatchProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPatchProperties.Serialization.cs new file mode 100644 index 000000000000..a5dada9197e0 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPatchProperties.Serialization.cs @@ -0,0 +1,261 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class CommunityPatchProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityPatchProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(DnsServers)) + { + writer.WritePropertyName("dnsServers"u8); + writer.WriteStartArray(); + foreach (var item in DnsServers) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(GovernedServiceList)) + { + writer.WritePropertyName("governedServiceList"u8); + writer.WriteStartArray(); + foreach (var item in GovernedServiceList) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PolicyOverride)) + { + writer.WritePropertyName("policyOverride"u8); + writer.WriteStringValue(PolicyOverride.Value.ToString()); + } + if (Optional.IsCollectionDefined(CommunityRoleAssignments)) + { + writer.WritePropertyName("communityRoleAssignments"u8); + writer.WriteStartArray(); + foreach (var item in CommunityRoleAssignments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(FirewallSku)) + { + writer.WritePropertyName("firewallSku"u8); + writer.WriteStringValue(FirewallSku.Value.ToString()); + } + if (Optional.IsDefined(ApprovalSettings)) + { + writer.WritePropertyName("approvalSettings"u8); + writer.WriteObjectValue(ApprovalSettings, options); + } + if (Optional.IsDefined(MaintenanceModeConfiguration)) + { + writer.WritePropertyName("maintenanceModeConfiguration"u8); + writer.WriteObjectValue(MaintenanceModeConfiguration, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CommunityPatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityPatchProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommunityPatchProperties(document.RootElement, options); + } + + internal static CommunityPatchProperties DeserializeCommunityPatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList dnsServers = default; + IList governedServiceList = default; + CommunityPropertiesPolicyOverride? policyOverride = default; + IList communityRoleAssignments = default; + FirewallSKU? firewallSku = default; + ApprovalSettingsPatchProperties approvalSettings = default; + MaintenanceModeConfigurationPatchModel maintenanceModeConfiguration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("dnsServers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + dnsServers = array; + continue; + } + if (property.NameEquals("governedServiceList"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(GovernedServiceItem.DeserializeGovernedServiceItem(item, options)); + } + governedServiceList = array; + continue; + } + if (property.NameEquals("policyOverride"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + policyOverride = new CommunityPropertiesPolicyOverride(property.Value.GetString()); + continue; + } + if (property.NameEquals("communityRoleAssignments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RoleAssignmentItem.DeserializeRoleAssignmentItem(item, options)); + } + communityRoleAssignments = array; + continue; + } + if (property.NameEquals("firewallSku"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + firewallSku = new FirewallSKU(property.Value.GetString()); + continue; + } + if (property.NameEquals("approvalSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + approvalSettings = ApprovalSettingsPatchProperties.DeserializeApprovalSettingsPatchProperties(property.Value, options); + continue; + } + if (property.NameEquals("maintenanceModeConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maintenanceModeConfiguration = MaintenanceModeConfigurationPatchModel.DeserializeMaintenanceModeConfigurationPatchModel(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommunityPatchProperties( + dnsServers ?? new ChangeTrackingList(), + governedServiceList ?? new ChangeTrackingList(), + policyOverride, + communityRoleAssignments ?? new ChangeTrackingList(), + firewallSku, + approvalSettings, + maintenanceModeConfiguration, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CommunityPatchProperties)} does not support writing '{options.Format}' format."); + } + } + + CommunityPatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCommunityPatchProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommunityPatchProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPatchProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPatchProperties.cs new file mode 100644 index 000000000000..fde9050421c8 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPatchProperties.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Community Resource Properties without default values. + public partial class CommunityPatchProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public CommunityPatchProperties() + { + DnsServers = new ChangeTrackingList(); + GovernedServiceList = new ChangeTrackingList(); + CommunityRoleAssignments = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// DNS Servers. + /// List of services governed by a community. + /// Policy override setting for the community. Specifies whether to apply enclave-specific policies or disable policy enforcement. + /// Community role assignments. + /// SKU of the community's Azure Firewall (Basic, Standard, Premium). Standard is the default. + /// Approval requirements for various actions on the community's resources. + /// Maintenance Mode configuration. + /// Keeps track of any properties unknown to the library. + internal CommunityPatchProperties(IList dnsServers, IList governedServiceList, CommunityPropertiesPolicyOverride? policyOverride, IList communityRoleAssignments, FirewallSKU? firewallSku, ApprovalSettingsPatchProperties approvalSettings, MaintenanceModeConfigurationPatchModel maintenanceModeConfiguration, IDictionary serializedAdditionalRawData) + { + DnsServers = dnsServers; + GovernedServiceList = governedServiceList; + PolicyOverride = policyOverride; + CommunityRoleAssignments = communityRoleAssignments; + FirewallSku = firewallSku; + ApprovalSettings = approvalSettings; + MaintenanceModeConfiguration = maintenanceModeConfiguration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// DNS Servers. + public IList DnsServers { get; } + /// List of services governed by a community. + public IList GovernedServiceList { get; } + /// Policy override setting for the community. Specifies whether to apply enclave-specific policies or disable policy enforcement. + public CommunityPropertiesPolicyOverride? PolicyOverride { get; set; } + /// Community role assignments. + public IList CommunityRoleAssignments { get; } + /// SKU of the community's Azure Firewall (Basic, Standard, Premium). Standard is the default. + public FirewallSKU? FirewallSku { get; set; } + /// Approval requirements for various actions on the community's resources. + internal ApprovalSettingsPatchProperties ApprovalSettings { get; set; } + /// List of mandatory approvers for the approval request. + public IList ApprovalMandatoryApprovers + { + get + { + if (ApprovalSettings is null) + ApprovalSettings = new ApprovalSettingsPatchProperties(); + return ApprovalSettings.MandatoryApprovers; + } + } + + /// Maintenance Mode configuration. + public MaintenanceModeConfigurationPatchModel MaintenanceModeConfiguration { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityProperties.Serialization.cs new file mode 100644 index 000000000000..7eb762009244 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityProperties.Serialization.cs @@ -0,0 +1,355 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class CommunityProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AddressSpace)) + { + writer.WritePropertyName("addressSpace"u8); + writer.WriteStringValue(AddressSpace); + } + if (Optional.IsCollectionDefined(DnsServers)) + { + writer.WritePropertyName("dnsServers"u8); + writer.WriteStartArray(); + foreach (var item in DnsServers) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ResourceCollection)) + { + writer.WritePropertyName("resourceCollection"u8); + writer.WriteStartArray(); + foreach (var item in ResourceCollection) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ManagedResourceGroupName)) + { + writer.WritePropertyName("managedResourceGroupName"u8); + writer.WriteStringValue(ManagedResourceGroupName); + } + if (options.Format != "W" && Optional.IsDefined(ManagedOnBehalfOfConfiguration)) + { + writer.WritePropertyName("managedOnBehalfOfConfiguration"u8); + writer.WriteObjectValue(ManagedOnBehalfOfConfiguration, options); + } + if (Optional.IsCollectionDefined(GovernedServiceList)) + { + writer.WritePropertyName("governedServiceList"u8); + writer.WriteStartArray(); + foreach (var item in GovernedServiceList) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PolicyOverride)) + { + writer.WritePropertyName("policyOverride"u8); + writer.WriteStringValue(PolicyOverride.Value.ToString()); + } + if (Optional.IsCollectionDefined(CommunityRoleAssignments)) + { + writer.WritePropertyName("communityRoleAssignments"u8); + writer.WriteStartArray(); + foreach (var item in CommunityRoleAssignments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(FirewallSku)) + { + writer.WritePropertyName("firewallSku"u8); + writer.WriteStringValue(FirewallSku.Value.ToString()); + } + if (Optional.IsDefined(ApprovalSettings)) + { + writer.WritePropertyName("approvalSettings"u8); + writer.WriteObjectValue(ApprovalSettings, options); + } + if (Optional.IsDefined(MaintenanceModeConfiguration)) + { + writer.WritePropertyName("maintenanceModeConfiguration"u8); + writer.WriteObjectValue(MaintenanceModeConfiguration, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CommunityProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommunityProperties(document.RootElement, options); + } + + internal static CommunityProperties DeserializeCommunityProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string addressSpace = default; + IList dnsServers = default; + ProvisioningState? provisioningState = default; + IReadOnlyList resourceCollection = default; + string managedResourceGroupName = default; + ManagedOnBehalfOfConfiguration managedOnBehalfOfConfiguration = default; + IList governedServiceList = default; + CommunityPropertiesPolicyOverride? policyOverride = default; + IList communityRoleAssignments = default; + FirewallSKU? firewallSku = default; + ApprovalSettings approvalSettings = default; + MaintenanceModeConfigurationModel maintenanceModeConfiguration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("addressSpace"u8)) + { + addressSpace = property.Value.GetString(); + continue; + } + if (property.NameEquals("dnsServers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + dnsServers = array; + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("resourceCollection"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new ResourceIdentifier(item.GetString())); + } + } + resourceCollection = array; + continue; + } + if (property.NameEquals("managedResourceGroupName"u8)) + { + managedResourceGroupName = property.Value.GetString(); + continue; + } + if (property.NameEquals("managedOnBehalfOfConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + managedOnBehalfOfConfiguration = ManagedOnBehalfOfConfiguration.DeserializeManagedOnBehalfOfConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("governedServiceList"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(GovernedServiceItem.DeserializeGovernedServiceItem(item, options)); + } + governedServiceList = array; + continue; + } + if (property.NameEquals("policyOverride"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + policyOverride = new CommunityPropertiesPolicyOverride(property.Value.GetString()); + continue; + } + if (property.NameEquals("communityRoleAssignments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RoleAssignmentItem.DeserializeRoleAssignmentItem(item, options)); + } + communityRoleAssignments = array; + continue; + } + if (property.NameEquals("firewallSku"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + firewallSku = new FirewallSKU(property.Value.GetString()); + continue; + } + if (property.NameEquals("approvalSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + approvalSettings = ApprovalSettings.DeserializeApprovalSettings(property.Value, options); + continue; + } + if (property.NameEquals("maintenanceModeConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maintenanceModeConfiguration = MaintenanceModeConfigurationModel.DeserializeMaintenanceModeConfigurationModel(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommunityProperties( + addressSpace, + dnsServers ?? new ChangeTrackingList(), + provisioningState, + resourceCollection ?? new ChangeTrackingList(), + managedResourceGroupName, + managedOnBehalfOfConfiguration, + governedServiceList ?? new ChangeTrackingList(), + policyOverride, + communityRoleAssignments ?? new ChangeTrackingList(), + firewallSku, + approvalSettings, + maintenanceModeConfiguration, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CommunityProperties)} does not support writing '{options.Format}' format."); + } + } + + CommunityProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCommunityProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommunityProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityProperties.cs new file mode 100644 index 000000000000..03a4ac90370f --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityProperties.cs @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Community Resource Properties. + public partial class CommunityProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public CommunityProperties() + { + DnsServers = new ChangeTrackingList(); + ResourceCollection = new ChangeTrackingList(); + GovernedServiceList = new ChangeTrackingList(); + CommunityRoleAssignments = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Address Space. + /// DNS Servers. + /// Provisioning State. + /// List of resource ids created by communities. + /// Managed resource group name. + /// Managed On Behalf Of Configuration. + /// List of services governed by a community. + /// Policy override setting for the community. Specifies whether to apply enclave-specific policies or disable policy enforcement. + /// Community role assignments. + /// SKU of the community's Azure Firewall (Basic, Standard, Premium). Standard is the default. + /// Approval requirements for various actions on the community's resources. + /// Maintenance Mode configuration. + /// Keeps track of any properties unknown to the library. + internal CommunityProperties(string addressSpace, IList dnsServers, ProvisioningState? provisioningState, IReadOnlyList resourceCollection, string managedResourceGroupName, ManagedOnBehalfOfConfiguration managedOnBehalfOfConfiguration, IList governedServiceList, CommunityPropertiesPolicyOverride? policyOverride, IList communityRoleAssignments, FirewallSKU? firewallSku, ApprovalSettings approvalSettings, MaintenanceModeConfigurationModel maintenanceModeConfiguration, IDictionary serializedAdditionalRawData) + { + AddressSpace = addressSpace; + DnsServers = dnsServers; + ProvisioningState = provisioningState; + ResourceCollection = resourceCollection; + ManagedResourceGroupName = managedResourceGroupName; + ManagedOnBehalfOfConfiguration = managedOnBehalfOfConfiguration; + GovernedServiceList = governedServiceList; + PolicyOverride = policyOverride; + CommunityRoleAssignments = communityRoleAssignments; + FirewallSku = firewallSku; + ApprovalSettings = approvalSettings; + MaintenanceModeConfiguration = maintenanceModeConfiguration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Address Space. + public string AddressSpace { get; set; } + /// DNS Servers. + public IList DnsServers { get; } + /// Provisioning State. + public ProvisioningState? ProvisioningState { get; } + /// List of resource ids created by communities. + public IReadOnlyList ResourceCollection { get; } + /// Managed resource group name. + public string ManagedResourceGroupName { get; } + /// Managed On Behalf Of Configuration. + internal ManagedOnBehalfOfConfiguration ManagedOnBehalfOfConfiguration { get; } + /// Managed-On-Behalf-Of broker resources. + public IReadOnlyList ManagedOnBehalfOfMoboBrokerResources + { + get => ManagedOnBehalfOfConfiguration?.MoboBrokerResources; + } + + /// List of services governed by a community. + public IList GovernedServiceList { get; } + /// Policy override setting for the community. Specifies whether to apply enclave-specific policies or disable policy enforcement. + public CommunityPropertiesPolicyOverride? PolicyOverride { get; set; } + /// Community role assignments. + public IList CommunityRoleAssignments { get; } + /// SKU of the community's Azure Firewall (Basic, Standard, Premium). Standard is the default. + public FirewallSKU? FirewallSku { get; set; } + /// Approval requirements for various actions on the community's resources. + public ApprovalSettings ApprovalSettings { get; set; } + /// Maintenance Mode configuration. + public MaintenanceModeConfigurationModel MaintenanceModeConfiguration { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPropertiesPolicyOverride.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPropertiesPolicyOverride.cs new file mode 100644 index 000000000000..8c37cb9c23c5 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityPropertiesPolicyOverride.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The CommunityPropertiesPolicyOverride. + public readonly partial struct CommunityPropertiesPolicyOverride : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CommunityPropertiesPolicyOverride(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EnclaveValue = "Enclave"; + private const string NoneValue = "None"; + + /// Enclave. + public static CommunityPropertiesPolicyOverride Enclave { get; } = new CommunityPropertiesPolicyOverride(EnclaveValue); + /// None. + public static CommunityPropertiesPolicyOverride None { get; } = new CommunityPropertiesPolicyOverride(NoneValue); + /// Determines if two values are the same. + public static bool operator ==(CommunityPropertiesPolicyOverride left, CommunityPropertiesPolicyOverride right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CommunityPropertiesPolicyOverride left, CommunityPropertiesPolicyOverride right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CommunityPropertiesPolicyOverride(string value) => new CommunityPropertiesPolicyOverride(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CommunityPropertiesPolicyOverride other && Equals(other); + /// + public bool Equals(CommunityPropertiesPolicyOverride other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourceListResult.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourceListResult.Serialization.cs new file mode 100644 index 000000000000..07956ac04801 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourceListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class CommunityResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CommunityResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommunityResourceListResult(document.RootElement, options); + } + + internal static CommunityResourceListResult DeserializeCommunityResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CommunityResourceData.DeserializeCommunityResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommunityResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CommunityResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + CommunityResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCommunityResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommunityResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourceListResult.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourceListResult.cs new file mode 100644 index 000000000000..678f58db4f18 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourceListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The response of a CommunityResource list operation. + internal partial class CommunityResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The CommunityResource items on this page. + /// is null. + internal CommunityResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The CommunityResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal CommunityResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CommunityResourceListResult() + { + } + + /// The CommunityResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourcePatch.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourcePatch.Serialization.cs new file mode 100644 index 000000000000..00163d62c9ff --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourcePatch.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class CommunityResourcePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityResourcePatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireV3Options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CommunityResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CommunityResourcePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCommunityResourcePatch(document.RootElement, options); + } + + internal static CommunityResourcePatch DeserializeCommunityResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CommunityPatchProperties properties = default; + IDictionary tags = default; + ManagedServiceIdentity identity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = CommunityPatchProperties.DeserializeCommunityPatchProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireV3Options, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CommunityResourcePatch(properties, tags ?? new ChangeTrackingDictionary(), identity, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(CommunityResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + CommunityResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCommunityResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CommunityResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourcePatch.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourcePatch.cs new file mode 100644 index 000000000000..e9cbbfcb0c51 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/CommunityResourcePatch.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Community Patch Resource. + public partial class CommunityResourcePatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public CommunityResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Community Patch properties. + /// Resource tags. + /// The managed service identities assigned to this resource. + /// Keeps track of any properties unknown to the library. + internal CommunityResourcePatch(CommunityPatchProperties properties, IDictionary tags, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) + { + Properties = properties; + Tags = tags; + Identity = identity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Community Patch properties. + public CommunityPatchProperties Properties { get; set; } + /// Resource tags. + public IDictionary Tags { get; } + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/DestinationType.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/DestinationType.cs new file mode 100644 index 000000000000..43cdd0d48dde --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/DestinationType.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Destination Type Enum. + public readonly partial struct DestinationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DestinationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FQDNValue = "FQDN"; + private const string FQDNTagValue = "FQDNTag"; + private const string IPAddressValue = "IPAddress"; + private const string PrivateNetworkValue = "PrivateNetwork"; + + /// DestinationType Type FQDN. + public static DestinationType FQDN { get; } = new DestinationType(FQDNValue); + /// DestinationType Type FQDNTag. + public static DestinationType FQDNTag { get; } = new DestinationType(FQDNTagValue); + /// DestinationType Type IPAddress. + public static DestinationType IPAddress { get; } = new DestinationType(IPAddressValue); + /// DestinationType Type PrivateNetwork. + public static DestinationType PrivateNetwork { get; } = new DestinationType(PrivateNetworkValue); + /// Determines if two values are the same. + public static bool operator ==(DestinationType left, DestinationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DestinationType left, DestinationType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DestinationType(string value) => new DestinationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DestinationType other && Equals(other); + /// + public bool Equals(DestinationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/DiagnosticDestination.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/DiagnosticDestination.cs new file mode 100644 index 000000000000..81575dd4bc72 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/DiagnosticDestination.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Specifies the destination of where to store diagnostic logs. + public readonly partial struct DiagnosticDestination : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DiagnosticDestination(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CommunityOnlyValue = "CommunityOnly"; + private const string EnclaveOnlyValue = "EnclaveOnly"; + private const string BothValue = "Both"; + + /// DiagnosticDestination Type CommunityOnly. + public static DiagnosticDestination CommunityOnly { get; } = new DiagnosticDestination(CommunityOnlyValue); + /// DiagnosticDestination Type EnclaveOnly. + public static DiagnosticDestination EnclaveOnly { get; } = new DiagnosticDestination(EnclaveOnlyValue); + /// DiagnosticDestination Type Both. + public static DiagnosticDestination Both { get; } = new DiagnosticDestination(BothValue); + /// Determines if two values are the same. + public static bool operator ==(DiagnosticDestination left, DiagnosticDestination right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DiagnosticDestination left, DiagnosticDestination right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DiagnosticDestination(string value) => new DiagnosticDestination(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DiagnosticDestination other && Equals(other); + /// + public bool Equals(DiagnosticDestination other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveAddressSpacesModel.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveAddressSpacesModel.Serialization.cs new file mode 100644 index 000000000000..4a6e8fa18e28 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveAddressSpacesModel.Serialization.cs @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class EnclaveAddressSpacesModel : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveAddressSpacesModel)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(EnclaveAddressSpace)) + { + writer.WritePropertyName("enclaveAddressSpace"u8); + writer.WriteStringValue(EnclaveAddressSpace); + } + if (Optional.IsDefined(ManagedAddressSpace)) + { + writer.WritePropertyName("managedAddressSpace"u8); + writer.WriteStringValue(ManagedAddressSpace); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveAddressSpacesModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveAddressSpacesModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveAddressSpacesModel(document.RootElement, options); + } + + internal static EnclaveAddressSpacesModel DeserializeEnclaveAddressSpacesModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string enclaveAddressSpace = default; + string managedAddressSpace = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("enclaveAddressSpace"u8)) + { + enclaveAddressSpace = property.Value.GetString(); + continue; + } + if (property.NameEquals("managedAddressSpace"u8)) + { + managedAddressSpace = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveAddressSpacesModel(enclaveAddressSpace, managedAddressSpace, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveAddressSpacesModel)} does not support writing '{options.Format}' format."); + } + } + + EnclaveAddressSpacesModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveAddressSpacesModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveAddressSpacesModel)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveAddressSpacesModel.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveAddressSpacesModel.cs new file mode 100644 index 000000000000..67507823f21b --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveAddressSpacesModel.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Enclave Address Spaces. + public partial class EnclaveAddressSpacesModel + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal EnclaveAddressSpacesModel() + { + } + + /// Initializes a new instance of . + /// Enclave Address Space. + /// Managed Address Space. + /// Keeps track of any properties unknown to the library. + internal EnclaveAddressSpacesModel(string enclaveAddressSpace, string managedAddressSpace, IDictionary serializedAdditionalRawData) + { + EnclaveAddressSpace = enclaveAddressSpace; + ManagedAddressSpace = managedAddressSpace; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Enclave Address Space. + public string EnclaveAddressSpace { get; } + /// Managed Address Space. + public string ManagedAddressSpace { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionPatchProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionPatchProperties.Serialization.cs new file mode 100644 index 000000000000..8448cae63270 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionPatchProperties.Serialization.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class EnclaveConnectionPatchProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveConnectionPatchProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(SourceCidr)) + { + writer.WritePropertyName("sourceCidr"u8); + writer.WriteStringValue(SourceCidr); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveConnectionPatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveConnectionPatchProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveConnectionPatchProperties(document.RootElement, options); + } + + internal static EnclaveConnectionPatchProperties DeserializeEnclaveConnectionPatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string sourceCidr = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sourceCidr"u8)) + { + sourceCidr = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveConnectionPatchProperties(sourceCidr, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveConnectionPatchProperties)} does not support writing '{options.Format}' format."); + } + } + + EnclaveConnectionPatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveConnectionPatchProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveConnectionPatchProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionPatchProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionPatchProperties.cs new file mode 100644 index 000000000000..822cb3010010 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionPatchProperties.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Enclave Connection patchable Properties. + internal partial class EnclaveConnectionPatchProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public EnclaveConnectionPatchProperties() + { + } + + /// Initializes a new instance of . + /// Source CIDR. + /// Keeps track of any properties unknown to the library. + internal EnclaveConnectionPatchProperties(string sourceCidr, IDictionary serializedAdditionalRawData) + { + SourceCidr = sourceCidr; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Source CIDR. + public string SourceCidr { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionProperties.Serialization.cs new file mode 100644 index 000000000000..c102bc172776 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionProperties.Serialization.cs @@ -0,0 +1,228 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class EnclaveConnectionProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveConnectionProperties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.Value.ToString()); + } + writer.WritePropertyName("communityResourceId"u8); + writer.WriteStringValue(CommunityResourceId); + writer.WritePropertyName("sourceResourceId"u8); + writer.WriteStringValue(SourceResourceId); + if (Optional.IsDefined(SourceCidr)) + { + writer.WritePropertyName("sourceCidr"u8); + writer.WriteStringValue(SourceCidr); + } + writer.WritePropertyName("destinationEndpointId"u8); + writer.WriteStringValue(DestinationEndpointId); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ResourceCollection)) + { + writer.WritePropertyName("resourceCollection"u8); + writer.WriteStartArray(); + foreach (var item in ResourceCollection) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveConnectionProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveConnectionProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveConnectionProperties(document.RootElement, options); + } + + internal static EnclaveConnectionProperties DeserializeEnclaveConnectionProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EnclaveConnectionState? state = default; + ResourceIdentifier communityResourceId = default; + ResourceIdentifier sourceResourceId = default; + string sourceCidr = default; + ResourceIdentifier destinationEndpointId = default; + ProvisioningState? provisioningState = default; + IReadOnlyList resourceCollection = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("state"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + state = new EnclaveConnectionState(property.Value.GetString()); + continue; + } + if (property.NameEquals("communityResourceId"u8)) + { + communityResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("sourceResourceId"u8)) + { + sourceResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("sourceCidr"u8)) + { + sourceCidr = property.Value.GetString(); + continue; + } + if (property.NameEquals("destinationEndpointId"u8)) + { + destinationEndpointId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("resourceCollection"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new ResourceIdentifier(item.GetString())); + } + } + resourceCollection = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveConnectionProperties( + state, + communityResourceId, + sourceResourceId, + sourceCidr, + destinationEndpointId, + provisioningState, + resourceCollection ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveConnectionProperties)} does not support writing '{options.Format}' format."); + } + } + + EnclaveConnectionProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveConnectionProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveConnectionProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionProperties.cs new file mode 100644 index 000000000000..cb6779960862 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionProperties.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Enclave Connection Resource properties. + public partial class EnclaveConnectionProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Community Resource Id. + /// Source Resource Id. + /// Destination Endpoint Resource Id. + /// , or is null. + public EnclaveConnectionProperties(ResourceIdentifier communityResourceId, ResourceIdentifier sourceResourceId, ResourceIdentifier destinationEndpointId) + { + Argument.AssertNotNull(communityResourceId, nameof(communityResourceId)); + Argument.AssertNotNull(sourceResourceId, nameof(sourceResourceId)); + Argument.AssertNotNull(destinationEndpointId, nameof(destinationEndpointId)); + + CommunityResourceId = communityResourceId; + SourceResourceId = sourceResourceId; + DestinationEndpointId = destinationEndpointId; + ResourceCollection = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The state of the enclaveConnection. + /// Community Resource Id. + /// Source Resource Id. + /// Source CIDR. + /// Destination Endpoint Resource Id. + /// Provisioning State. + /// List of resource ids modified by enclave Connections. + /// Keeps track of any properties unknown to the library. + internal EnclaveConnectionProperties(EnclaveConnectionState? state, ResourceIdentifier communityResourceId, ResourceIdentifier sourceResourceId, string sourceCidr, ResourceIdentifier destinationEndpointId, ProvisioningState? provisioningState, IReadOnlyList resourceCollection, IDictionary serializedAdditionalRawData) + { + State = state; + CommunityResourceId = communityResourceId; + SourceResourceId = sourceResourceId; + SourceCidr = sourceCidr; + DestinationEndpointId = destinationEndpointId; + ProvisioningState = provisioningState; + ResourceCollection = resourceCollection; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EnclaveConnectionProperties() + { + } + + /// The state of the enclaveConnection. + public EnclaveConnectionState? State { get; } + /// Community Resource Id. + public ResourceIdentifier CommunityResourceId { get; set; } + /// Source Resource Id. + public ResourceIdentifier SourceResourceId { get; set; } + /// Source CIDR. + public string SourceCidr { get; set; } + /// Destination Endpoint Resource Id. + public ResourceIdentifier DestinationEndpointId { get; set; } + /// Provisioning State. + public ProvisioningState? ProvisioningState { get; } + /// List of resource ids modified by enclave Connections. + public IReadOnlyList ResourceCollection { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourceListResult.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourceListResult.Serialization.cs new file mode 100644 index 000000000000..d293b3c841ee --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourceListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class EnclaveConnectionResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveConnectionResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveConnectionResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveConnectionResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveConnectionResourceListResult(document.RootElement, options); + } + + internal static EnclaveConnectionResourceListResult DeserializeEnclaveConnectionResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(EnclaveConnectionResourceData.DeserializeEnclaveConnectionResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveConnectionResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveConnectionResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + EnclaveConnectionResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveConnectionResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveConnectionResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourceListResult.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourceListResult.cs new file mode 100644 index 000000000000..fc8523208998 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourceListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The response of a EnclaveConnectionResource list operation. + internal partial class EnclaveConnectionResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The EnclaveConnectionResource items on this page. + /// is null. + internal EnclaveConnectionResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The EnclaveConnectionResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal EnclaveConnectionResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EnclaveConnectionResourceListResult() + { + } + + /// The EnclaveConnectionResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourcePatch.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourcePatch.Serialization.cs new file mode 100644 index 000000000000..2b3c921c81d4 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourcePatch.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class EnclaveConnectionResourcePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveConnectionResourcePatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveConnectionResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveConnectionResourcePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveConnectionResourcePatch(document.RootElement, options); + } + + internal static EnclaveConnectionResourcePatch DeserializeEnclaveConnectionResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EnclaveConnectionPatchProperties properties = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = EnclaveConnectionPatchProperties.DeserializeEnclaveConnectionPatchProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveConnectionResourcePatch(properties, tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveConnectionResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + EnclaveConnectionResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveConnectionResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveConnectionResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourcePatch.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourcePatch.cs new file mode 100644 index 000000000000..9203e892422c --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionResourcePatch.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Enclave Connection Patch Resource. + public partial class EnclaveConnectionResourcePatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public EnclaveConnectionResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Enclave Connection Patch properties. + /// Resource tags. + /// Keeps track of any properties unknown to the library. + internal EnclaveConnectionResourcePatch(EnclaveConnectionPatchProperties properties, IDictionary tags, IDictionary serializedAdditionalRawData) + { + Properties = properties; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Enclave Connection Patch properties. + internal EnclaveConnectionPatchProperties Properties { get; set; } + /// Source CIDR. + public string EnclaveConnectionPatchSourceCidr + { + get => Properties is null ? default : Properties.SourceCidr; + set + { + if (Properties is null) + Properties = new EnclaveConnectionPatchProperties(); + Properties.SourceCidr = value; + } + } + + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionState.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionState.cs new file mode 100644 index 000000000000..de3144989747 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveConnectionState.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Specifies the state of the enclave connection. + public readonly partial struct EnclaveConnectionState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public EnclaveConnectionState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PendingApprovalValue = "PendingApproval"; + private const string PendingUpdateValue = "PendingUpdate"; + private const string ApprovedValue = "Approved"; + private const string ActiveValue = "Active"; + private const string FailedValue = "Failed"; + private const string ConnectedValue = "Connected"; + private const string DisconnectedValue = "Disconnected"; + + /// EnclaveConnectionState Type Pending Approval. + public static EnclaveConnectionState PendingApproval { get; } = new EnclaveConnectionState(PendingApprovalValue); + /// EnclaveConnectionState Type Pending Update. + public static EnclaveConnectionState PendingUpdate { get; } = new EnclaveConnectionState(PendingUpdateValue); + /// EnclaveConnectionState Type Approved. + public static EnclaveConnectionState Approved { get; } = new EnclaveConnectionState(ApprovedValue); + /// EnclaveConnectionState Type Active. + public static EnclaveConnectionState Active { get; } = new EnclaveConnectionState(ActiveValue); + /// EnclaveConnectionState Type Failed. + public static EnclaveConnectionState Failed { get; } = new EnclaveConnectionState(FailedValue); + /// EnclaveConnectionState Type Connected. + public static EnclaveConnectionState Connected { get; } = new EnclaveConnectionState(ConnectedValue); + /// EnclaveConnectionState Type Disconnected. + public static EnclaveConnectionState Disconnected { get; } = new EnclaveConnectionState(DisconnectedValue); + /// Determines if two values are the same. + public static bool operator ==(EnclaveConnectionState left, EnclaveConnectionState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(EnclaveConnectionState left, EnclaveConnectionState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator EnclaveConnectionState(string value) => new EnclaveConnectionState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EnclaveConnectionState other && Equals(other); + /// + public bool Equals(EnclaveConnectionState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsModel.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsModel.Serialization.cs new file mode 100644 index 000000000000..5ea3157dae35 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsModel.Serialization.cs @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class EnclaveDefaultSettingsModel : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveDefaultSettingsModel)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(KeyVaultResourceId)) + { + writer.WritePropertyName("keyVaultResourceId"u8); + writer.WriteStringValue(KeyVaultResourceId); + } + if (options.Format != "W" && Optional.IsDefined(StorageAccountResourceId)) + { + writer.WritePropertyName("storageAccountResourceId"u8); + writer.WriteStringValue(StorageAccountResourceId); + } + if (options.Format != "W" && Optional.IsCollectionDefined(LogAnalyticsResourceIdCollection)) + { + writer.WritePropertyName("logAnalyticsResourceIdCollection"u8); + writer.WriteStartArray(); + foreach (var item in LogAnalyticsResourceIdCollection) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(DiagnosticDestination)) + { + writer.WritePropertyName("diagnosticDestination"u8); + writer.WriteStringValue(DiagnosticDestination.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveDefaultSettingsModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveDefaultSettingsModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveDefaultSettingsModel(document.RootElement, options); + } + + internal static EnclaveDefaultSettingsModel DeserializeEnclaveDefaultSettingsModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier keyVaultResourceId = default; + ResourceIdentifier storageAccountResourceId = default; + IReadOnlyList logAnalyticsResourceIdCollection = default; + DiagnosticDestination? diagnosticDestination = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("keyVaultResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keyVaultResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("storageAccountResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + storageAccountResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("logAnalyticsResourceIdCollection"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new ResourceIdentifier(item.GetString())); + } + } + logAnalyticsResourceIdCollection = array; + continue; + } + if (property.NameEquals("diagnosticDestination"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diagnosticDestination = new DiagnosticDestination(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveDefaultSettingsModel(keyVaultResourceId, storageAccountResourceId, logAnalyticsResourceIdCollection ?? new ChangeTrackingList(), diagnosticDestination, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveDefaultSettingsModel)} does not support writing '{options.Format}' format."); + } + } + + EnclaveDefaultSettingsModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveDefaultSettingsModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveDefaultSettingsModel)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsModel.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsModel.cs new file mode 100644 index 000000000000..3a4f02a0e210 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsModel.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Virtual Enclave Default Settings. + public partial class EnclaveDefaultSettingsModel + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public EnclaveDefaultSettingsModel() + { + LogAnalyticsResourceIdCollection = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Key Vault Resource Id. + /// Storage Account Resource Id. + /// Log Analytics Resource Ids. + /// Diagnostic Destination. + /// Keeps track of any properties unknown to the library. + internal EnclaveDefaultSettingsModel(ResourceIdentifier keyVaultResourceId, ResourceIdentifier storageAccountResourceId, IReadOnlyList logAnalyticsResourceIdCollection, DiagnosticDestination? diagnosticDestination, IDictionary serializedAdditionalRawData) + { + KeyVaultResourceId = keyVaultResourceId; + StorageAccountResourceId = storageAccountResourceId; + LogAnalyticsResourceIdCollection = logAnalyticsResourceIdCollection; + DiagnosticDestination = diagnosticDestination; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Key Vault Resource Id. + public ResourceIdentifier KeyVaultResourceId { get; } + /// Storage Account Resource Id. + public ResourceIdentifier StorageAccountResourceId { get; } + /// Log Analytics Resource Ids. + public IReadOnlyList LogAnalyticsResourceIdCollection { get; } + /// Diagnostic Destination. + public DiagnosticDestination? DiagnosticDestination { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsPatchModel.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsPatchModel.Serialization.cs new file mode 100644 index 000000000000..98eabf1f8dc8 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsPatchModel.Serialization.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class EnclaveDefaultSettingsPatchModel : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveDefaultSettingsPatchModel)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(DiagnosticDestination)) + { + writer.WritePropertyName("diagnosticDestination"u8); + writer.WriteStringValue(DiagnosticDestination.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveDefaultSettingsPatchModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveDefaultSettingsPatchModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveDefaultSettingsPatchModel(document.RootElement, options); + } + + internal static EnclaveDefaultSettingsPatchModel DeserializeEnclaveDefaultSettingsPatchModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DiagnosticDestination? diagnosticDestination = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("diagnosticDestination"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diagnosticDestination = new DiagnosticDestination(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveDefaultSettingsPatchModel(diagnosticDestination, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveDefaultSettingsPatchModel)} does not support writing '{options.Format}' format."); + } + } + + EnclaveDefaultSettingsPatchModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveDefaultSettingsPatchModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveDefaultSettingsPatchModel)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsPatchModel.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsPatchModel.cs new file mode 100644 index 000000000000..4770571abad1 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveDefaultSettingsPatchModel.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Virtual Enclave Default Settings. + internal partial class EnclaveDefaultSettingsPatchModel + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public EnclaveDefaultSettingsPatchModel() + { + } + + /// Initializes a new instance of . + /// Diagnostic Destination. + /// Keeps track of any properties unknown to the library. + internal EnclaveDefaultSettingsPatchModel(DiagnosticDestination? diagnosticDestination, IDictionary serializedAdditionalRawData) + { + DiagnosticDestination = diagnosticDestination; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Diagnostic Destination. + public DiagnosticDestination? DiagnosticDestination { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointDestinationRule.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointDestinationRule.Serialization.cs new file mode 100644 index 000000000000..d58253f1c92e --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointDestinationRule.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class EnclaveEndpointDestinationRule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointDestinationRule)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Protocols)) + { + writer.WritePropertyName("protocols"u8); + writer.WriteStartArray(); + foreach (var item in Protocols) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(EndpointRuleName)) + { + writer.WritePropertyName("endpointRuleName"u8); + writer.WriteStringValue(EndpointRuleName); + } + if (Optional.IsDefined(Destination)) + { + writer.WritePropertyName("destination"u8); + writer.WriteStringValue(Destination); + } + if (Optional.IsDefined(Ports)) + { + writer.WritePropertyName("ports"u8); + writer.WriteStringValue(Ports); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveEndpointDestinationRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointDestinationRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveEndpointDestinationRule(document.RootElement, options); + } + + internal static EnclaveEndpointDestinationRule DeserializeEnclaveEndpointDestinationRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList protocols = default; + string endpointRuleName = default; + string destination = default; + string ports = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("protocols"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new EnclaveEndpointProtocol(item.GetString())); + } + protocols = array; + continue; + } + if (property.NameEquals("endpointRuleName"u8)) + { + endpointRuleName = property.Value.GetString(); + continue; + } + if (property.NameEquals("destination"u8)) + { + destination = property.Value.GetString(); + continue; + } + if (property.NameEquals("ports"u8)) + { + ports = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveEndpointDestinationRule(protocols ?? new ChangeTrackingList(), endpointRuleName, destination, ports, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveEndpointDestinationRule)} does not support writing '{options.Format}' format."); + } + } + + EnclaveEndpointDestinationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveEndpointDestinationRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveEndpointDestinationRule)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointDestinationRule.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointDestinationRule.cs new file mode 100644 index 000000000000..8a345feb93be --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointDestinationRule.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Enclave Endpoint Rule Properties. + public partial class EnclaveEndpointDestinationRule + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public EnclaveEndpointDestinationRule() + { + Protocols = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Protocols. Options specified by Endpoint Protocol Enum. + /// Endpoint Rule Name. + /// Destination address. Can include multiple CIDR/IP Addresses or fqdn tags or fqdns (for community endpoint) separated by commas. + /// Port. Can include multiple ports separated by commas or a range indicated by a hyphen. + /// Keeps track of any properties unknown to the library. + internal EnclaveEndpointDestinationRule(IList protocols, string endpointRuleName, string destination, string ports, IDictionary serializedAdditionalRawData) + { + Protocols = protocols; + EndpointRuleName = endpointRuleName; + Destination = destination; + Ports = ports; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Protocols. Options specified by Endpoint Protocol Enum. + public IList Protocols { get; } + /// Endpoint Rule Name. + public string EndpointRuleName { get; set; } + /// Destination address. Can include multiple CIDR/IP Addresses or fqdn tags or fqdns (for community endpoint) separated by commas. + public string Destination { get; set; } + /// Port. Can include multiple ports separated by commas or a range indicated by a hyphen. + public string Ports { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointPatchProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointPatchProperties.Serialization.cs new file mode 100644 index 000000000000..bccda6ead61a --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointPatchProperties.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class EnclaveEndpointPatchProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointPatchProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("ruleCollection"u8); + writer.WriteStartArray(); + foreach (var item in RuleCollection) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveEndpointPatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointPatchProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveEndpointPatchProperties(document.RootElement, options); + } + + internal static EnclaveEndpointPatchProperties DeserializeEnclaveEndpointPatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList ruleCollection = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ruleCollection"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(EnclaveEndpointDestinationRule.DeserializeEnclaveEndpointDestinationRule(item, options)); + } + ruleCollection = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveEndpointPatchProperties(ruleCollection, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveEndpointPatchProperties)} does not support writing '{options.Format}' format."); + } + } + + EnclaveEndpointPatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveEndpointPatchProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveEndpointPatchProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointPatchProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointPatchProperties.cs new file mode 100644 index 000000000000..55150811623f --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointPatchProperties.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Enclave Endpoint patchable Properties. + internal partial class EnclaveEndpointPatchProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Enclave Endpoint Rule Collection. + /// is null. + public EnclaveEndpointPatchProperties(IEnumerable ruleCollection) + { + Argument.AssertNotNull(ruleCollection, nameof(ruleCollection)); + + RuleCollection = ruleCollection.ToList(); + } + + /// Initializes a new instance of . + /// Enclave Endpoint Rule Collection. + /// Keeps track of any properties unknown to the library. + internal EnclaveEndpointPatchProperties(IList ruleCollection, IDictionary serializedAdditionalRawData) + { + RuleCollection = ruleCollection; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EnclaveEndpointPatchProperties() + { + } + + /// Enclave Endpoint Rule Collection. + public IList RuleCollection { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProperties.Serialization.cs new file mode 100644 index 000000000000..bfd36c05d6a0 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProperties.Serialization.cs @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class EnclaveEndpointProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("ruleCollection"u8); + writer.WriteStartArray(); + foreach (var item in RuleCollection) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && Optional.IsCollectionDefined(ResourceCollection)) + { + writer.WritePropertyName("resourceCollection"u8); + writer.WriteStartArray(); + foreach (var item in ResourceCollection) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveEndpointProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveEndpointProperties(document.RootElement, options); + } + + internal static EnclaveEndpointProperties DeserializeEnclaveEndpointProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList ruleCollection = default; + IReadOnlyList resourceCollection = default; + ProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ruleCollection"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(EnclaveEndpointDestinationRule.DeserializeEnclaveEndpointDestinationRule(item, options)); + } + ruleCollection = array; + continue; + } + if (property.NameEquals("resourceCollection"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new ResourceIdentifier(item.GetString())); + } + } + resourceCollection = array; + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveEndpointProperties(ruleCollection, resourceCollection ?? new ChangeTrackingList(), provisioningState, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveEndpointProperties)} does not support writing '{options.Format}' format."); + } + } + + EnclaveEndpointProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveEndpointProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveEndpointProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProperties.cs new file mode 100644 index 000000000000..9d929513b864 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProperties.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Enclave Endpoint Resource properties. + public partial class EnclaveEndpointProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Enclave Endpoint Rule Collection. + /// is null. + public EnclaveEndpointProperties(IEnumerable ruleCollection) + { + Argument.AssertNotNull(ruleCollection, nameof(ruleCollection)); + + RuleCollection = ruleCollection.ToList(); + ResourceCollection = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Enclave Endpoint Rule Collection. + /// List of resource ids created by community endpoint. + /// Provisioning State. + /// Keeps track of any properties unknown to the library. + internal EnclaveEndpointProperties(IList ruleCollection, IReadOnlyList resourceCollection, ProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + RuleCollection = ruleCollection; + ResourceCollection = resourceCollection; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EnclaveEndpointProperties() + { + } + + /// Enclave Endpoint Rule Collection. + public IList RuleCollection { get; } + /// List of resource ids created by community endpoint. + public IReadOnlyList ResourceCollection { get; } + /// Provisioning State. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProtocol.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProtocol.cs new file mode 100644 index 000000000000..18bf60bb1037 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointProtocol.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Enclave Endpoint Protocol Enum. + public readonly partial struct EnclaveEndpointProtocol : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public EnclaveEndpointProtocol(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ANYValue = "ANY"; + private const string TCPValue = "TCP"; + private const string UDPValue = "UDP"; + private const string ICMPValue = "ICMP"; + private const string ESPValue = "ESP"; + private const string AHValue = "AH"; + + /// EndpointProtocol Type ANY. + public static EnclaveEndpointProtocol ANY { get; } = new EnclaveEndpointProtocol(ANYValue); + /// EndpointProtocol Type TCP. + public static EnclaveEndpointProtocol TCP { get; } = new EnclaveEndpointProtocol(TCPValue); + /// EndpointProtocol Type UDP. + public static EnclaveEndpointProtocol UDP { get; } = new EnclaveEndpointProtocol(UDPValue); + /// EndpointProtocol Type ICMP. + public static EnclaveEndpointProtocol ICMP { get; } = new EnclaveEndpointProtocol(ICMPValue); + /// EndpointProtocol Type ESP. + public static EnclaveEndpointProtocol ESP { get; } = new EnclaveEndpointProtocol(ESPValue); + /// EndpointProtocol Type AH. + public static EnclaveEndpointProtocol AH { get; } = new EnclaveEndpointProtocol(AHValue); + /// Determines if two values are the same. + public static bool operator ==(EnclaveEndpointProtocol left, EnclaveEndpointProtocol right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(EnclaveEndpointProtocol left, EnclaveEndpointProtocol right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator EnclaveEndpointProtocol(string value) => new EnclaveEndpointProtocol(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EnclaveEndpointProtocol other && Equals(other); + /// + public bool Equals(EnclaveEndpointProtocol other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourceListResult.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourceListResult.Serialization.cs new file mode 100644 index 000000000000..d3c8fccaf75f --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourceListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class EnclaveEndpointResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveEndpointResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveEndpointResourceListResult(document.RootElement, options); + } + + internal static EnclaveEndpointResourceListResult DeserializeEnclaveEndpointResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(EnclaveEndpointResourceData.DeserializeEnclaveEndpointResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveEndpointResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveEndpointResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + EnclaveEndpointResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveEndpointResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveEndpointResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourceListResult.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourceListResult.cs new file mode 100644 index 000000000000..82863cf564c7 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourceListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The response of a EnclaveEndpointResource list operation. + internal partial class EnclaveEndpointResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The EnclaveEndpointResource items on this page. + /// is null. + internal EnclaveEndpointResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The EnclaveEndpointResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal EnclaveEndpointResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EnclaveEndpointResourceListResult() + { + } + + /// The EnclaveEndpointResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourcePatch.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourcePatch.Serialization.cs new file mode 100644 index 000000000000..08365793d526 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourcePatch.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class EnclaveEndpointResourcePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointResourcePatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveEndpointResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveEndpointResourcePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveEndpointResourcePatch(document.RootElement, options); + } + + internal static EnclaveEndpointResourcePatch DeserializeEnclaveEndpointResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EnclaveEndpointPatchProperties properties = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = EnclaveEndpointPatchProperties.DeserializeEnclaveEndpointPatchProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveEndpointResourcePatch(properties, tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveEndpointResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + EnclaveEndpointResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveEndpointResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveEndpointResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourcePatch.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourcePatch.cs new file mode 100644 index 000000000000..f230f2bc1172 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveEndpointResourcePatch.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Enclave Endpoint Patch Resource. + public partial class EnclaveEndpointResourcePatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public EnclaveEndpointResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Enclave Endpoint Patch properties. + /// Resource tags. + /// Keeps track of any properties unknown to the library. + internal EnclaveEndpointResourcePatch(EnclaveEndpointPatchProperties properties, IDictionary tags, IDictionary serializedAdditionalRawData) + { + Properties = properties; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Enclave Endpoint Patch properties. + internal EnclaveEndpointPatchProperties Properties { get; set; } + /// Enclave Endpoint Rule Collection. + public IList EnclaveEndpointPatchRuleCollection + { + get => Properties is null ? default : Properties.RuleCollection; + set => Properties = new EnclaveEndpointPatchProperties(value); + } + + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourceListResult.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourceListResult.Serialization.cs new file mode 100644 index 000000000000..cf4d188a9224 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourceListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class EnclaveResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveResourceListResult(document.RootElement, options); + } + + internal static EnclaveResourceListResult DeserializeEnclaveResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(EnclaveResourceData.DeserializeEnclaveResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + EnclaveResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourceListResult.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourceListResult.cs new file mode 100644 index 000000000000..5895f7f4fc7f --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourceListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The response of a EnclaveResource list operation. + internal partial class EnclaveResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The EnclaveResource items on this page. + /// is null. + internal EnclaveResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The EnclaveResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal EnclaveResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EnclaveResourceListResult() + { + } + + /// The EnclaveResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourcePatch.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourcePatch.Serialization.cs new file mode 100644 index 000000000000..69069d3b80f4 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourcePatch.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class EnclaveResourcePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveResourcePatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireV3Options); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveResourcePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveResourcePatch(document.RootElement, options); + } + + internal static EnclaveResourcePatch DeserializeEnclaveResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VirtualEnclavePatchProperties properties = default; + ManagedServiceIdentity identity = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = VirtualEnclavePatchProperties.DeserializeVirtualEnclavePatchProperties(property.Value, options); + continue; + } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireV3Options, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveResourcePatch(properties, identity, tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + EnclaveResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourcePatch.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourcePatch.cs new file mode 100644 index 000000000000..faf66356a1ff --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveResourcePatch.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Virtual Enclave Patch Model. + public partial class EnclaveResourcePatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public EnclaveResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Virtual Enclave Patch properties. + /// The managed service identities assigned to this resource. + /// Resource tags. + /// Keeps track of any properties unknown to the library. + internal EnclaveResourcePatch(VirtualEnclavePatchProperties properties, ManagedServiceIdentity identity, IDictionary tags, IDictionary serializedAdditionalRawData) + { + Properties = properties; + Identity = identity; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Virtual Enclave Patch properties. + public VirtualEnclavePatchProperties Properties { get; set; } + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveVirtualNetworkModel.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveVirtualNetworkModel.Serialization.cs new file mode 100644 index 000000000000..70280afb3a84 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveVirtualNetworkModel.Serialization.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class EnclaveVirtualNetworkModel : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveVirtualNetworkModel)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(NetworkName)) + { + writer.WritePropertyName("networkName"u8); + writer.WriteStringValue(NetworkName); + } + if (Optional.IsDefined(NetworkSize)) + { + writer.WritePropertyName("networkSize"u8); + writer.WriteStringValue(NetworkSize); + } + if (Optional.IsDefined(CustomCidrRange)) + { + writer.WritePropertyName("customCidrRange"u8); + writer.WriteStringValue(CustomCidrRange); + } + if (Optional.IsCollectionDefined(SubnetConfigurations)) + { + writer.WritePropertyName("subnetConfigurations"u8); + writer.WriteStartArray(); + foreach (var item in SubnetConfigurations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(AllowSubnetCommunication)) + { + writer.WritePropertyName("allowSubnetCommunication"u8); + writer.WriteBooleanValue(AllowSubnetCommunication.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EnclaveVirtualNetworkModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnclaveVirtualNetworkModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnclaveVirtualNetworkModel(document.RootElement, options); + } + + internal static EnclaveVirtualNetworkModel DeserializeEnclaveVirtualNetworkModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string networkName = default; + string networkSize = default; + string customCidrRange = default; + IList subnetConfigurations = default; + bool? allowSubnetCommunication = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("networkName"u8)) + { + networkName = property.Value.GetString(); + continue; + } + if (property.NameEquals("networkSize"u8)) + { + networkSize = property.Value.GetString(); + continue; + } + if (property.NameEquals("customCidrRange"u8)) + { + customCidrRange = property.Value.GetString(); + continue; + } + if (property.NameEquals("subnetConfigurations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SubnetConfiguration.DeserializeSubnetConfiguration(item, options)); + } + subnetConfigurations = array; + continue; + } + if (property.NameEquals("allowSubnetCommunication"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + allowSubnetCommunication = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EnclaveVirtualNetworkModel( + networkName, + networkSize, + customCidrRange, + subnetConfigurations ?? new ChangeTrackingList(), + allowSubnetCommunication, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(EnclaveVirtualNetworkModel)} does not support writing '{options.Format}' format."); + } + } + + EnclaveVirtualNetworkModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEnclaveVirtualNetworkModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnclaveVirtualNetworkModel)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveVirtualNetworkModel.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveVirtualNetworkModel.cs new file mode 100644 index 000000000000..118dde1cfa8e --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/EnclaveVirtualNetworkModel.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Enclave Virtual Network Properties. + public partial class EnclaveVirtualNetworkModel + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public EnclaveVirtualNetworkModel() + { + SubnetConfigurations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Network Name. + /// Network Size. + /// Custom CIDR Range. + /// Subnet Configurations. + /// Allow Subnet Communication. + /// Keeps track of any properties unknown to the library. + internal EnclaveVirtualNetworkModel(string networkName, string networkSize, string customCidrRange, IList subnetConfigurations, bool? allowSubnetCommunication, IDictionary serializedAdditionalRawData) + { + NetworkName = networkName; + NetworkSize = networkSize; + CustomCidrRange = customCidrRange; + SubnetConfigurations = subnetConfigurations; + AllowSubnetCommunication = allowSubnetCommunication; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Network Name. + public string NetworkName { get; set; } + /// Network Size. + public string NetworkSize { get; set; } + /// Custom CIDR Range. + public string CustomCidrRange { get; set; } + /// Subnet Configurations. + public IList SubnetConfigurations { get; } + /// Allow Subnet Communication. + public bool? AllowSubnetCommunication { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/FirewallSKU.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/FirewallSKU.cs new file mode 100644 index 000000000000..54da43ba2764 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/FirewallSKU.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Azure Firewall SKU. + public readonly partial struct FirewallSKU : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FirewallSKU(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string BasicValue = "Basic"; + private const string StandardValue = "Standard"; + private const string PremiumValue = "Premium"; + + /// FirewallSKU Basic. + public static FirewallSKU Basic { get; } = new FirewallSKU(BasicValue); + /// FirwallSKU Standard. + public static FirewallSKU Standard { get; } = new FirewallSKU(StandardValue); + /// FirewallSKU Premium. + public static FirewallSKU Premium { get; } = new FirewallSKU(PremiumValue); + /// Determines if two values are the same. + public static bool operator ==(FirewallSKU left, FirewallSKU right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FirewallSKU left, FirewallSKU right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator FirewallSKU(string value) => new FirewallSKU(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FirewallSKU other && Equals(other); + /// + public bool Equals(FirewallSKU other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItem.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItem.Serialization.cs new file mode 100644 index 000000000000..e626b3c2d35a --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItem.Serialization.cs @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class GovernedServiceItem : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GovernedServiceItem)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("serviceId"u8); + writer.WriteStringValue(ServiceId.ToString()); + if (options.Format != "W" && Optional.IsDefined(ServiceName)) + { + writer.WritePropertyName("serviceName"u8); + writer.WriteStringValue(ServiceName); + } + if (Optional.IsDefined(Option)) + { + writer.WritePropertyName("option"u8); + writer.WriteStringValue(Option.Value.ToString()); + } + if (Optional.IsDefined(Enforcement)) + { + writer.WritePropertyName("enforcement"u8); + writer.WriteStringValue(Enforcement.Value.ToString()); + } + if (Optional.IsDefined(PolicyAction)) + { + writer.WritePropertyName("policyAction"u8); + writer.WriteStringValue(PolicyAction.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Initiatives)) + { + writer.WritePropertyName("initiatives"u8); + writer.WriteStartArray(); + foreach (var item in Initiatives) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + GovernedServiceItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GovernedServiceItem)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGovernedServiceItem(document.RootElement, options); + } + + internal static GovernedServiceItem DeserializeGovernedServiceItem(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ServiceIdentifier serviceId = default; + string serviceName = default; + GovernedServiceItemOption? option = default; + GovernedServiceItemEnforcement? enforcement = default; + GovernedServiceItemPolicyAction? policyAction = default; + IReadOnlyList initiatives = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("serviceId"u8)) + { + serviceId = new ServiceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("serviceName"u8)) + { + serviceName = property.Value.GetString(); + continue; + } + if (property.NameEquals("option"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + option = new GovernedServiceItemOption(property.Value.GetString()); + continue; + } + if (property.NameEquals("enforcement"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enforcement = new GovernedServiceItemEnforcement(property.Value.GetString()); + continue; + } + if (property.NameEquals("policyAction"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + policyAction = new GovernedServiceItemPolicyAction(property.Value.GetString()); + continue; + } + if (property.NameEquals("initiatives"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + initiatives = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new GovernedServiceItem( + serviceId, + serviceName, + option, + enforcement, + policyAction, + initiatives ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(GovernedServiceItem)} does not support writing '{options.Format}' format."); + } + } + + GovernedServiceItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGovernedServiceItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GovernedServiceItem)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItem.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItem.cs new file mode 100644 index 000000000000..bf19101c806b --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItem.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// GovernedServiceItem Properties. + public partial class GovernedServiceItem + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Service ID. + public GovernedServiceItem(ServiceIdentifier serviceId) + { + ServiceId = serviceId; + Initiatives = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Service ID. + /// Service name. + /// Governance option for this service (Allow, Deny, ExceptionOnly, or NotApplicable). + /// Initiative enforcement (Enabled or Disabled). + /// Enforcement mode for policy. AuditOnly, Enforce, or None. + /// Initiatives associated with this service. + /// Keeps track of any properties unknown to the library. + internal GovernedServiceItem(ServiceIdentifier serviceId, string serviceName, GovernedServiceItemOption? option, GovernedServiceItemEnforcement? enforcement, GovernedServiceItemPolicyAction? policyAction, IReadOnlyList initiatives, IDictionary serializedAdditionalRawData) + { + ServiceId = serviceId; + ServiceName = serviceName; + Option = option; + Enforcement = enforcement; + PolicyAction = policyAction; + Initiatives = initiatives; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal GovernedServiceItem() + { + } + + /// Service ID. + public ServiceIdentifier ServiceId { get; set; } + /// Service name. + public string ServiceName { get; } + /// Governance option for this service (Allow, Deny, ExceptionOnly, or NotApplicable). + public GovernedServiceItemOption? Option { get; set; } + /// Initiative enforcement (Enabled or Disabled). + public GovernedServiceItemEnforcement? Enforcement { get; set; } + /// Enforcement mode for policy. AuditOnly, Enforce, or None. + public GovernedServiceItemPolicyAction? PolicyAction { get; set; } + /// Initiatives associated with this service. + public IReadOnlyList Initiatives { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemEnforcement.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemEnforcement.cs new file mode 100644 index 000000000000..fe90ceba9f8d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemEnforcement.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The GovernedServiceItemEnforcement. + public readonly partial struct GovernedServiceItemEnforcement : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public GovernedServiceItemEnforcement(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EnabledValue = "Enabled"; + private const string DisabledValue = "Disabled"; + + /// Enabled. + public static GovernedServiceItemEnforcement Enabled { get; } = new GovernedServiceItemEnforcement(EnabledValue); + /// Disabled. + public static GovernedServiceItemEnforcement Disabled { get; } = new GovernedServiceItemEnforcement(DisabledValue); + /// Determines if two values are the same. + public static bool operator ==(GovernedServiceItemEnforcement left, GovernedServiceItemEnforcement right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(GovernedServiceItemEnforcement left, GovernedServiceItemEnforcement right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator GovernedServiceItemEnforcement(string value) => new GovernedServiceItemEnforcement(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is GovernedServiceItemEnforcement other && Equals(other); + /// + public bool Equals(GovernedServiceItemEnforcement other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemOption.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemOption.cs new file mode 100644 index 000000000000..9535b0e3e30f --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemOption.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The GovernedServiceItemOption. + public readonly partial struct GovernedServiceItemOption : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public GovernedServiceItemOption(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AllowValue = "Allow"; + private const string DenyValue = "Deny"; + private const string ExceptionOnlyValue = "ExceptionOnly"; + private const string NotApplicableValue = "NotApplicable"; + + /// Allow. + public static GovernedServiceItemOption Allow { get; } = new GovernedServiceItemOption(AllowValue); + /// Deny. + public static GovernedServiceItemOption Deny { get; } = new GovernedServiceItemOption(DenyValue); + /// ExceptionOnly. + public static GovernedServiceItemOption ExceptionOnly { get; } = new GovernedServiceItemOption(ExceptionOnlyValue); + /// NotApplicable. + public static GovernedServiceItemOption NotApplicable { get; } = new GovernedServiceItemOption(NotApplicableValue); + /// Determines if two values are the same. + public static bool operator ==(GovernedServiceItemOption left, GovernedServiceItemOption right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(GovernedServiceItemOption left, GovernedServiceItemOption right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator GovernedServiceItemOption(string value) => new GovernedServiceItemOption(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is GovernedServiceItemOption other && Equals(other); + /// + public bool Equals(GovernedServiceItemOption other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemPolicyAction.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemPolicyAction.cs new file mode 100644 index 000000000000..7690bf014e7e --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/GovernedServiceItemPolicyAction.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The GovernedServiceItemPolicyAction. + public readonly partial struct GovernedServiceItemPolicyAction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public GovernedServiceItemPolicyAction(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AuditOnlyValue = "AuditOnly"; + private const string EnforceValue = "Enforce"; + private const string NoneValue = "None"; + + /// AuditOnly. + public static GovernedServiceItemPolicyAction AuditOnly { get; } = new GovernedServiceItemPolicyAction(AuditOnlyValue); + /// Enforce. + public static GovernedServiceItemPolicyAction Enforce { get; } = new GovernedServiceItemPolicyAction(EnforceValue); + /// None. + public static GovernedServiceItemPolicyAction None { get; } = new GovernedServiceItemPolicyAction(NoneValue); + /// Determines if two values are the same. + public static bool operator ==(GovernedServiceItemPolicyAction left, GovernedServiceItemPolicyAction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(GovernedServiceItemPolicyAction left, GovernedServiceItemPolicyAction right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator GovernedServiceItemPolicyAction(string value) => new GovernedServiceItemPolicyAction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is GovernedServiceItemPolicyAction other && Equals(other); + /// + public bool Equals(GovernedServiceItemPolicyAction other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModel.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModel.Serialization.cs new file mode 100644 index 000000000000..01a1884595c6 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModel.Serialization.cs @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class MaintenanceModeConfigurationModel : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MaintenanceModeConfigurationModel)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.ToString()); + if (Optional.IsCollectionDefined(Principals)) + { + writer.WritePropertyName("principals"u8); + writer.WriteStartArray(); + foreach (var item in Principals) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Justification)) + { + writer.WritePropertyName("justification"u8); + writer.WriteStringValue(Justification.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MaintenanceModeConfigurationModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MaintenanceModeConfigurationModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMaintenanceModeConfigurationModel(document.RootElement, options); + } + + internal static MaintenanceModeConfigurationModel DeserializeMaintenanceModeConfigurationModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MaintenanceModeConfigurationModelMode mode = default; + IList principals = default; + MaintenanceModeConfigurationModelJustification? justification = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("mode"u8)) + { + mode = new MaintenanceModeConfigurationModelMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("principals"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Principal.DeserializePrincipal(item, options)); + } + principals = array; + continue; + } + if (property.NameEquals("justification"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + justification = new MaintenanceModeConfigurationModelJustification(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MaintenanceModeConfigurationModel(mode, principals ?? new ChangeTrackingList(), justification, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(MaintenanceModeConfigurationModel)} does not support writing '{options.Format}' format."); + } + } + + MaintenanceModeConfigurationModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMaintenanceModeConfigurationModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MaintenanceModeConfigurationModel)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModel.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModel.cs new file mode 100644 index 000000000000..1ef066ac84c3 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModel.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Maintenance Mode. + public partial class MaintenanceModeConfigurationModel + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Current mode of Maintenance Mode Configuration. + public MaintenanceModeConfigurationModel(MaintenanceModeConfigurationModelMode mode) + { + Mode = mode; + Principals = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Current mode of Maintenance Mode Configuration. + /// The user, group or service principal object affected by Maintenance Mode. + /// Justification for entering or exiting Maintenance Mode. + /// Keeps track of any properties unknown to the library. + internal MaintenanceModeConfigurationModel(MaintenanceModeConfigurationModelMode mode, IList principals, MaintenanceModeConfigurationModelJustification? justification, IDictionary serializedAdditionalRawData) + { + Mode = mode; + Principals = principals; + Justification = justification; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MaintenanceModeConfigurationModel() + { + } + + /// Current mode of Maintenance Mode Configuration. + public MaintenanceModeConfigurationModelMode Mode { get; set; } + /// The user, group or service principal object affected by Maintenance Mode. + public IList Principals { get; } + /// Justification for entering or exiting Maintenance Mode. + public MaintenanceModeConfigurationModelJustification? Justification { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModelJustification.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModelJustification.cs new file mode 100644 index 000000000000..18a056a0d927 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModelJustification.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The MaintenanceModeConfigurationModelJustification. + public readonly partial struct MaintenanceModeConfigurationModelJustification : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MaintenanceModeConfigurationModelJustification(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NetworkingValue = "Networking"; + private const string GovernanceValue = "Governance"; + private const string OffValue = "Off"; + + /// Networking. + public static MaintenanceModeConfigurationModelJustification Networking { get; } = new MaintenanceModeConfigurationModelJustification(NetworkingValue); + /// Governance. + public static MaintenanceModeConfigurationModelJustification Governance { get; } = new MaintenanceModeConfigurationModelJustification(GovernanceValue); + /// Off. + public static MaintenanceModeConfigurationModelJustification Off { get; } = new MaintenanceModeConfigurationModelJustification(OffValue); + /// Determines if two values are the same. + public static bool operator ==(MaintenanceModeConfigurationModelJustification left, MaintenanceModeConfigurationModelJustification right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MaintenanceModeConfigurationModelJustification left, MaintenanceModeConfigurationModelJustification right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MaintenanceModeConfigurationModelJustification(string value) => new MaintenanceModeConfigurationModelJustification(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MaintenanceModeConfigurationModelJustification other && Equals(other); + /// + public bool Equals(MaintenanceModeConfigurationModelJustification other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModelMode.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModelMode.cs new file mode 100644 index 000000000000..9ae77b125938 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationModelMode.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The MaintenanceModeConfigurationModelMode. + public readonly partial struct MaintenanceModeConfigurationModelMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MaintenanceModeConfigurationModelMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string OnValue = "On"; + private const string CanNotDeleteValue = "CanNotDelete"; + private const string OffValue = "Off"; + private const string GeneralValue = "General"; + private const string AdvancedValue = "Advanced"; + + /// On. + public static MaintenanceModeConfigurationModelMode On { get; } = new MaintenanceModeConfigurationModelMode(OnValue); + /// CanNotDelete. + public static MaintenanceModeConfigurationModelMode CanNotDelete { get; } = new MaintenanceModeConfigurationModelMode(CanNotDeleteValue); + /// Off. + public static MaintenanceModeConfigurationModelMode Off { get; } = new MaintenanceModeConfigurationModelMode(OffValue); + /// General. + public static MaintenanceModeConfigurationModelMode General { get; } = new MaintenanceModeConfigurationModelMode(GeneralValue); + /// Advanced. + public static MaintenanceModeConfigurationModelMode Advanced { get; } = new MaintenanceModeConfigurationModelMode(AdvancedValue); + /// Determines if two values are the same. + public static bool operator ==(MaintenanceModeConfigurationModelMode left, MaintenanceModeConfigurationModelMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MaintenanceModeConfigurationModelMode left, MaintenanceModeConfigurationModelMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MaintenanceModeConfigurationModelMode(string value) => new MaintenanceModeConfigurationModelMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MaintenanceModeConfigurationModelMode other && Equals(other); + /// + public bool Equals(MaintenanceModeConfigurationModelMode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationPatchModel.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationPatchModel.Serialization.cs new file mode 100644 index 000000000000..b5c43c96111b --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationPatchModel.Serialization.cs @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class MaintenanceModeConfigurationPatchModel : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MaintenanceModeConfigurationPatchModel)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.ToString()); + if (Optional.IsCollectionDefined(Principals)) + { + writer.WritePropertyName("principals"u8); + writer.WriteStartArray(); + foreach (var item in Principals) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Justification)) + { + writer.WritePropertyName("justification"u8); + writer.WriteStringValue(Justification.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MaintenanceModeConfigurationPatchModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MaintenanceModeConfigurationPatchModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMaintenanceModeConfigurationPatchModel(document.RootElement, options); + } + + internal static MaintenanceModeConfigurationPatchModel DeserializeMaintenanceModeConfigurationPatchModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MaintenanceModeConfigurationModelMode mode = default; + IList principals = default; + MaintenanceModeConfigurationModelJustification? justification = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("mode"u8)) + { + mode = new MaintenanceModeConfigurationModelMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("principals"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Principal.DeserializePrincipal(item, options)); + } + principals = array; + continue; + } + if (property.NameEquals("justification"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + justification = new MaintenanceModeConfigurationModelJustification(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MaintenanceModeConfigurationPatchModel(mode, principals ?? new ChangeTrackingList(), justification, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(MaintenanceModeConfigurationPatchModel)} does not support writing '{options.Format}' format."); + } + } + + MaintenanceModeConfigurationPatchModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMaintenanceModeConfigurationPatchModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MaintenanceModeConfigurationPatchModel)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationPatchModel.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationPatchModel.cs new file mode 100644 index 000000000000..9c87242fe5f2 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MaintenanceModeConfigurationPatchModel.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Maintenance Mode Patch Model. + public partial class MaintenanceModeConfigurationPatchModel + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Current mode of Maintenance Mode Configuration. + public MaintenanceModeConfigurationPatchModel(MaintenanceModeConfigurationModelMode mode) + { + Mode = mode; + Principals = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Current mode of Maintenance Mode Configuration. + /// The user, group or service principal object affected by Maintenance Mode. + /// Justification for entering or exiting Maintenance Mode. + /// Keeps track of any properties unknown to the library. + internal MaintenanceModeConfigurationPatchModel(MaintenanceModeConfigurationModelMode mode, IList principals, MaintenanceModeConfigurationModelJustification? justification, IDictionary serializedAdditionalRawData) + { + Mode = mode; + Principals = principals; + Justification = justification; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MaintenanceModeConfigurationPatchModel() + { + } + + /// Current mode of Maintenance Mode Configuration. + public MaintenanceModeConfigurationModelMode Mode { get; } + /// The user, group or service principal object affected by Maintenance Mode. + public IList Principals { get; } + /// Justification for entering or exiting Maintenance Mode. + public MaintenanceModeConfigurationModelJustification? Justification { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ManagedOnBehalfOfConfiguration.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ManagedOnBehalfOfConfiguration.Serialization.cs new file mode 100644 index 000000000000..0fd34efb888c --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ManagedOnBehalfOfConfiguration.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class ManagedOnBehalfOfConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedOnBehalfOfConfiguration)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsCollectionDefined(MoboBrokerResources)) + { + writer.WritePropertyName("moboBrokerResources"u8); + writer.WriteStartArray(); + foreach (var item in MoboBrokerResources) + { + ((IJsonModel)item).Write(writer, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ManagedOnBehalfOfConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedOnBehalfOfConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedOnBehalfOfConfiguration(document.RootElement, options); + } + + internal static ManagedOnBehalfOfConfiguration DeserializeManagedOnBehalfOfConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList moboBrokerResources = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("moboBrokerResources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureResourceManagerVirtualEnclavesContext.Default)); + } + moboBrokerResources = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedOnBehalfOfConfiguration(moboBrokerResources ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(ManagedOnBehalfOfConfiguration)} does not support writing '{options.Format}' format."); + } + } + + ManagedOnBehalfOfConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeManagedOnBehalfOfConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedOnBehalfOfConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ManagedOnBehalfOfConfiguration.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ManagedOnBehalfOfConfiguration.cs new file mode 100644 index 000000000000..cc91bce53b38 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ManagedOnBehalfOfConfiguration.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Managed-On-Behalf-Of configuration properties. This configuration exists for the resources where a resource provider manages those resources on behalf of the resource owner. + internal partial class ManagedOnBehalfOfConfiguration + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ManagedOnBehalfOfConfiguration() + { + MoboBrokerResources = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Managed-On-Behalf-Of broker resources. + /// Keeps track of any properties unknown to the library. + internal ManagedOnBehalfOfConfiguration(IReadOnlyList moboBrokerResources, IDictionary serializedAdditionalRawData) + { + MoboBrokerResources = moboBrokerResources; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Managed-On-Behalf-Of broker resources. + public IReadOnlyList MoboBrokerResources { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MandatoryApprover.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MandatoryApprover.Serialization.cs new file mode 100644 index 000000000000..d81dfad2a05a --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MandatoryApprover.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class MandatoryApprover : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MandatoryApprover)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("approverEntraId"u8); + writer.WriteStringValue(ApproverEntraId); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MandatoryApprover IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MandatoryApprover)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMandatoryApprover(document.RootElement, options); + } + + internal static MandatoryApprover DeserializeMandatoryApprover(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string approverEntraId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("approverEntraId"u8)) + { + approverEntraId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MandatoryApprover(approverEntraId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(MandatoryApprover)} does not support writing '{options.Format}' format."); + } + } + + MandatoryApprover IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMandatoryApprover(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MandatoryApprover)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MandatoryApprover.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MandatoryApprover.cs new file mode 100644 index 000000000000..1786282cf3ae --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/MandatoryApprover.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Approver Metadata for approvals request. + public partial class MandatoryApprover + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// EntraId of the approver. + /// is null. + public MandatoryApprover(string approverEntraId) + { + Argument.AssertNotNull(approverEntraId, nameof(approverEntraId)); + + ApproverEntraId = approverEntraId; + } + + /// Initializes a new instance of . + /// EntraId of the approver. + /// Keeps track of any properties unknown to the library. + internal MandatoryApprover(string approverEntraId, IDictionary serializedAdditionalRawData) + { + ApproverEntraId = approverEntraId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MandatoryApprover() + { + } + + /// EntraId of the approver. + public string ApproverEntraId { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Principal.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Principal.Serialization.cs new file mode 100644 index 000000000000..0cfd1dfa92e4 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Principal.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class Principal : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Principal)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Principal IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Principal)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrincipal(document.RootElement, options); + } + + internal static Principal DeserializePrincipal(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + PrincipalType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new PrincipalType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Principal(id, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(Principal)} does not support writing '{options.Format}' format."); + } + } + + Principal IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePrincipal(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Principal)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Principal.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Principal.cs new file mode 100644 index 000000000000..6e31a0b2010d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/Principal.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Principal for maintenance mode or role assignments. + public partial class Principal + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The object id associated with the principal. + /// The type of the object id. We currently allow users, groups, and service principals. + /// is null. + public Principal(string id, PrincipalType type) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + Type = type; + } + + /// Initializes a new instance of . + /// The object id associated with the principal. + /// The type of the object id. We currently allow users, groups, and service principals. + /// Keeps track of any properties unknown to the library. + internal Principal(string id, PrincipalType type, IDictionary serializedAdditionalRawData) + { + Id = id; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Principal() + { + } + + /// The object id associated with the principal. + public string Id { get; set; } + /// The type of the object id. We currently allow users, groups, and service principals. + public PrincipalType Type { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/PrincipalType.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/PrincipalType.cs new file mode 100644 index 000000000000..d54b06e827e9 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/PrincipalType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The PrincipalType. + public readonly partial struct PrincipalType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PrincipalType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UserValue = "User"; + private const string GroupValue = "Group"; + private const string ServicePrincipalValue = "ServicePrincipal"; + + /// User. + public static PrincipalType User { get; } = new PrincipalType(UserValue); + /// Group. + public static PrincipalType Group { get; } = new PrincipalType(GroupValue); + /// ServicePrincipal. + public static PrincipalType ServicePrincipal { get; } = new PrincipalType(ServicePrincipalValue); + /// Determines if two values are the same. + public static bool operator ==(PrincipalType left, PrincipalType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PrincipalType left, PrincipalType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PrincipalType(string value) => new PrincipalType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PrincipalType other && Equals(other); + /// + public bool Equals(PrincipalType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ProvisioningState.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..8532dfd0e377 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The provisioning status of the resource. + public readonly partial struct ProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + private const string AcceptedValue = "Accepted"; + private const string CreatingValue = "Creating"; + private const string DeletingValue = "Deleting"; + private const string NotSpecifiedValue = "NotSpecified"; + private const string RunningValue = "Running"; + private const string UpdatingValue = "Updating"; + + /// Resource has been created. + public static ProvisioningState Succeeded { get; } = new ProvisioningState(SucceededValue); + /// Resource creation failed. + public static ProvisioningState Failed { get; } = new ProvisioningState(FailedValue); + /// Resource creation was canceled. + public static ProvisioningState Canceled { get; } = new ProvisioningState(CanceledValue); + /// Provisioning State Type Accepted. + public static ProvisioningState Accepted { get; } = new ProvisioningState(AcceptedValue); + /// Provisioning State Type Creating. + public static ProvisioningState Creating { get; } = new ProvisioningState(CreatingValue); + /// Provisioning State Type Deleting. + public static ProvisioningState Deleting { get; } = new ProvisioningState(DeletingValue); + /// Provisioning State Type NotSpecified. + public static ProvisioningState NotSpecified { get; } = new ProvisioningState(NotSpecifiedValue); + /// Provisioning State Type Running. + public static ProvisioningState Running { get; } = new ProvisioningState(RunningValue); + /// Provisioning State Type Updating. + public static ProvisioningState Updating { get; } = new ProvisioningState(UpdatingValue); + /// Determines if two values are the same. + public static bool operator ==(ProvisioningState left, ProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ProvisioningState left, ProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ProvisioningState(string value) => new ProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ProvisioningState other && Equals(other); + /// + public bool Equals(ProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadata.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadata.Serialization.cs new file mode 100644 index 000000000000..d76c9e0c36ad --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadata.Serialization.cs @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class RequestMetadata : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequestMetadata)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("resourceAction"u8); + writer.WriteStringValue(ResourceAction); + if (Optional.IsDefined(ApprovalCallbackRoute)) + { + writer.WritePropertyName("approvalCallbackRoute"u8); + writer.WriteStringValue(ApprovalCallbackRoute); + } + if (Optional.IsDefined(ApprovalCallbackPayload)) + { + writer.WritePropertyName("approvalCallbackPayload"u8); + writer.WriteStringValue(ApprovalCallbackPayload); + } + if (Optional.IsDefined(ApprovalStatus)) + { + writer.WritePropertyName("approvalStatus"u8); + writer.WriteStringValue(ApprovalStatus.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RequestMetadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequestMetadata)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequestMetadata(document.RootElement, options); + } + + internal static RequestMetadata DeserializeRequestMetadata(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string resourceAction = default; + string approvalCallbackRoute = default; + string approvalCallbackPayload = default; + ApprovalStatus? approvalStatus = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceAction"u8)) + { + resourceAction = property.Value.GetString(); + continue; + } + if (property.NameEquals("approvalCallbackRoute"u8)) + { + approvalCallbackRoute = property.Value.GetString(); + continue; + } + if (property.NameEquals("approvalCallbackPayload"u8)) + { + approvalCallbackPayload = property.Value.GetString(); + continue; + } + if (property.NameEquals("approvalStatus"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + approvalStatus = new ApprovalStatus(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RequestMetadata(resourceAction, approvalCallbackRoute, approvalCallbackPayload, approvalStatus, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(RequestMetadata)} does not support writing '{options.Format}' format."); + } + } + + RequestMetadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRequestMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequestMetadata)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadata.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadata.cs new file mode 100644 index 000000000000..530a7f252a9d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadata.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Request Metadata for approvals request. + public partial class RequestMetadata + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Resource Action of the item being approved or declined. + /// is null. + public RequestMetadata(string resourceAction) + { + Argument.AssertNotNull(resourceAction, nameof(resourceAction)); + + ResourceAction = resourceAction; + } + + /// Initializes a new instance of . + /// Resource Action of the item being approved or declined. + /// Route name for the approval callback. + /// Payload to be sent upon any action on approval request. + /// Status of the approval. Uses ApprovalStatus enum. + /// Keeps track of any properties unknown to the library. + internal RequestMetadata(string resourceAction, string approvalCallbackRoute, string approvalCallbackPayload, ApprovalStatus? approvalStatus, IDictionary serializedAdditionalRawData) + { + ResourceAction = resourceAction; + ApprovalCallbackRoute = approvalCallbackRoute; + ApprovalCallbackPayload = approvalCallbackPayload; + ApprovalStatus = approvalStatus; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RequestMetadata() + { + } + + /// Resource Action of the item being approved or declined. + public string ResourceAction { get; set; } + /// Route name for the approval callback. + public string ApprovalCallbackRoute { get; set; } + /// Payload to be sent upon any action on approval request. + public string ApprovalCallbackPayload { get; set; } + /// Status of the approval. Uses ApprovalStatus enum. + public ApprovalStatus? ApprovalStatus { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadataUpdatableProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadataUpdatableProperties.Serialization.cs new file mode 100644 index 000000000000..a394ffdc0f65 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadataUpdatableProperties.Serialization.cs @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class RequestMetadataUpdatableProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequestMetadataUpdatableProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("resourceAction"u8); + writer.WriteStringValue(ResourceAction); + if (Optional.IsDefined(ApprovalCallbackRoute)) + { + writer.WritePropertyName("approvalCallbackRoute"u8); + writer.WriteStringValue(ApprovalCallbackRoute); + } + if (Optional.IsDefined(ApprovalCallbackPayload)) + { + writer.WritePropertyName("approvalCallbackPayload"u8); + writer.WriteStringValue(ApprovalCallbackPayload); + } + if (Optional.IsDefined(ApprovalStatus)) + { + writer.WritePropertyName("approvalStatus"u8); + writer.WriteStringValue(ApprovalStatus.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RequestMetadataUpdatableProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequestMetadataUpdatableProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequestMetadataUpdatableProperties(document.RootElement, options); + } + + internal static RequestMetadataUpdatableProperties DeserializeRequestMetadataUpdatableProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string resourceAction = default; + string approvalCallbackRoute = default; + string approvalCallbackPayload = default; + ApprovalStatus? approvalStatus = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceAction"u8)) + { + resourceAction = property.Value.GetString(); + continue; + } + if (property.NameEquals("approvalCallbackRoute"u8)) + { + approvalCallbackRoute = property.Value.GetString(); + continue; + } + if (property.NameEquals("approvalCallbackPayload"u8)) + { + approvalCallbackPayload = property.Value.GetString(); + continue; + } + if (property.NameEquals("approvalStatus"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + approvalStatus = new ApprovalStatus(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RequestMetadataUpdatableProperties(resourceAction, approvalCallbackRoute, approvalCallbackPayload, approvalStatus, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(RequestMetadataUpdatableProperties)} does not support writing '{options.Format}' format."); + } + } + + RequestMetadataUpdatableProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRequestMetadataUpdatableProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequestMetadataUpdatableProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadataUpdatableProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadataUpdatableProperties.cs new file mode 100644 index 000000000000..25bbc3430c78 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RequestMetadataUpdatableProperties.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Request Metadata patch properties. + public partial class RequestMetadataUpdatableProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Resource Action of the item being approved or declined. + /// is null. + public RequestMetadataUpdatableProperties(string resourceAction) + { + Argument.AssertNotNull(resourceAction, nameof(resourceAction)); + + ResourceAction = resourceAction; + } + + /// Initializes a new instance of . + /// Resource Action of the item being approved or declined. + /// Route name for the approval callback. + /// Payload to be sent upon any action on approval request. + /// Status of the approval. Uses ApprovalStatus enum. + /// Keeps track of any properties unknown to the library. + internal RequestMetadataUpdatableProperties(string resourceAction, string approvalCallbackRoute, string approvalCallbackPayload, ApprovalStatus? approvalStatus, IDictionary serializedAdditionalRawData) + { + ResourceAction = resourceAction; + ApprovalCallbackRoute = approvalCallbackRoute; + ApprovalCallbackPayload = approvalCallbackPayload; + ApprovalStatus = approvalStatus; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RequestMetadataUpdatableProperties() + { + } + + /// Resource Action of the item being approved or declined. + public string ResourceAction { get; } + /// Route name for the approval callback. + public string ApprovalCallbackRoute { get; set; } + /// Payload to be sent upon any action on approval request. + public string ApprovalCallbackPayload { get; set; } + /// Status of the approval. Uses ApprovalStatus enum. + public ApprovalStatus? ApprovalStatus { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RoleAssignmentItem.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RoleAssignmentItem.Serialization.cs new file mode 100644 index 000000000000..04e3ceca201e --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RoleAssignmentItem.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class RoleAssignmentItem : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RoleAssignmentItem)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("roleDefinitionId"u8); + writer.WriteStringValue(RoleDefinitionId); + if (Optional.IsCollectionDefined(Principals)) + { + writer.WritePropertyName("principals"u8); + writer.WriteStartArray(); + foreach (var item in Principals) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RoleAssignmentItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RoleAssignmentItem)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRoleAssignmentItem(document.RootElement, options); + } + + internal static RoleAssignmentItem DeserializeRoleAssignmentItem(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string roleDefinitionId = default; + IList principals = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("roleDefinitionId"u8)) + { + roleDefinitionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("principals"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Principal.DeserializePrincipal(item, options)); + } + principals = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RoleAssignmentItem(roleDefinitionId, principals ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(RoleAssignmentItem)} does not support writing '{options.Format}' format."); + } + } + + RoleAssignmentItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRoleAssignmentItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RoleAssignmentItem)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RoleAssignmentItem.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RoleAssignmentItem.cs new file mode 100644 index 000000000000..c27671b3c98e --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/RoleAssignmentItem.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Role assignment item that indicates which principals should be assigned this role definition. + public partial class RoleAssignmentItem + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Role definition identifier. + /// is null. + public RoleAssignmentItem(string roleDefinitionId) + { + Argument.AssertNotNull(roleDefinitionId, nameof(roleDefinitionId)); + + RoleDefinitionId = roleDefinitionId; + Principals = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Role definition identifier. + /// List of principal IDs to which to assign this role definition. + /// Keeps track of any properties unknown to the library. + internal RoleAssignmentItem(string roleDefinitionId, IList principals, IDictionary serializedAdditionalRawData) + { + RoleDefinitionId = roleDefinitionId; + Principals = principals; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RoleAssignmentItem() + { + } + + /// Role definition identifier. + public string RoleDefinitionId { get; set; } + /// List of principal IDs to which to assign this role definition. + public IList Principals { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ServiceIdentifier.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ServiceIdentifier.cs new file mode 100644 index 000000000000..b7bc5c4c9ca4 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/ServiceIdentifier.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Identifier for governed services. + public readonly partial struct ServiceIdentifier : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ServiceIdentifier(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AKSValue = "AKS"; + private const string AppServiceValue = "AppService"; + private const string AzureFirewallsValue = "AzureFirewalls"; + private const string ContainerRegistryValue = "ContainerRegistry"; + private const string CosmosDBValue = "CosmosDB"; + private const string DataConnectorsValue = "DataConnectors"; + private const string InsightsValue = "Insights"; + private const string KeyVaultValue = "KeyVault"; + private const string LogicValue = "Logic"; + private const string MicrosoftSqlValue = "MicrosoftSQL"; + private const string MonitoringValue = "Monitoring"; + private const string PostgreSqlValue = "PostgreSQL"; + private const string PrivateDnsZonesValue = "PrivateDNSZones"; + private const string ServiceBusValue = "ServiceBus"; + private const string StorageValue = "Storage"; + + /// Service identifier for AKS. + public static ServiceIdentifier AKS { get; } = new ServiceIdentifier(AKSValue); + /// Service identifier for App Service. + public static ServiceIdentifier AppService { get; } = new ServiceIdentifier(AppServiceValue); + /// Service identifier for Azure Firewalls. + public static ServiceIdentifier AzureFirewalls { get; } = new ServiceIdentifier(AzureFirewallsValue); + /// Service identifier for Container Registry. + public static ServiceIdentifier ContainerRegistry { get; } = new ServiceIdentifier(ContainerRegistryValue); + /// Service identifier for CosmosDB. + public static ServiceIdentifier CosmosDB { get; } = new ServiceIdentifier(CosmosDBValue); + /// Service identifier for Data Connectors. + public static ServiceIdentifier DataConnectors { get; } = new ServiceIdentifier(DataConnectorsValue); + /// Service identifier for Insights. + public static ServiceIdentifier Insights { get; } = new ServiceIdentifier(InsightsValue); + /// Service identifier for Key Vault. + public static ServiceIdentifier KeyVault { get; } = new ServiceIdentifier(KeyVaultValue); + /// Service identifier for Logic. + public static ServiceIdentifier Logic { get; } = new ServiceIdentifier(LogicValue); + /// Service identifier for Microsoft SQL. + public static ServiceIdentifier MicrosoftSql { get; } = new ServiceIdentifier(MicrosoftSqlValue); + /// Service identifier for Monitoring. + public static ServiceIdentifier Monitoring { get; } = new ServiceIdentifier(MonitoringValue); + /// Service identifier for PostgreSQL. + public static ServiceIdentifier PostgreSql { get; } = new ServiceIdentifier(PostgreSqlValue); + /// Service identifier for Private DNS Zones. + public static ServiceIdentifier PrivateDnsZones { get; } = new ServiceIdentifier(PrivateDnsZonesValue); + /// Service identifier for Service Bus. + public static ServiceIdentifier ServiceBus { get; } = new ServiceIdentifier(ServiceBusValue); + /// Service identifier for Storage. + public static ServiceIdentifier Storage { get; } = new ServiceIdentifier(StorageValue); + /// Determines if two values are the same. + public static bool operator ==(ServiceIdentifier left, ServiceIdentifier right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ServiceIdentifier left, ServiceIdentifier right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ServiceIdentifier(string value) => new ServiceIdentifier(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ServiceIdentifier other && Equals(other); + /// + public bool Equals(ServiceIdentifier other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/SubnetConfiguration.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/SubnetConfiguration.Serialization.cs new file mode 100644 index 000000000000..27c3ddd99fc6 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/SubnetConfiguration.Serialization.cs @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class SubnetConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubnetConfiguration)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("subnetName"u8); + writer.WriteStringValue(SubnetName); + if (options.Format != "W" && Optional.IsDefined(SubnetResourceId)) + { + writer.WritePropertyName("subnetResourceId"u8); + writer.WriteStringValue(SubnetResourceId); + } + writer.WritePropertyName("networkPrefixSize"u8); + writer.WriteNumberValue(NetworkPrefixSize); + if (Optional.IsDefined(SubnetDelegation)) + { + writer.WritePropertyName("subnetDelegation"u8); + writer.WriteStringValue(SubnetDelegation); + } + if (options.Format != "W" && Optional.IsDefined(AddressPrefix)) + { + writer.WritePropertyName("addressPrefix"u8); + writer.WriteStringValue(AddressPrefix); + } + if (options.Format != "W" && Optional.IsDefined(NetworkSecurityGroupResourceId)) + { + writer.WritePropertyName("networkSecurityGroupResourceId"u8); + writer.WriteStringValue(NetworkSecurityGroupResourceId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SubnetConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubnetConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubnetConfiguration(document.RootElement, options); + } + + internal static SubnetConfiguration DeserializeSubnetConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string subnetName = default; + ResourceIdentifier subnetResourceId = default; + int networkPrefixSize = default; + string subnetDelegation = default; + string addressPrefix = default; + ResourceIdentifier networkSecurityGroupResourceId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("subnetName"u8)) + { + subnetName = property.Value.GetString(); + continue; + } + if (property.NameEquals("subnetResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + subnetResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("networkPrefixSize"u8)) + { + networkPrefixSize = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("subnetDelegation"u8)) + { + subnetDelegation = property.Value.GetString(); + continue; + } + if (property.NameEquals("addressPrefix"u8)) + { + addressPrefix = property.Value.GetString(); + continue; + } + if (property.NameEquals("networkSecurityGroupResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + networkSecurityGroupResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SubnetConfiguration( + subnetName, + subnetResourceId, + networkPrefixSize, + subnetDelegation, + addressPrefix, + networkSecurityGroupResourceId, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(SubnetConfiguration)} does not support writing '{options.Format}' format."); + } + } + + SubnetConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSubnetConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubnetConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/SubnetConfiguration.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/SubnetConfiguration.cs new file mode 100644 index 000000000000..46e7950b9bc5 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/SubnetConfiguration.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Subnet Configuration. + public partial class SubnetConfiguration + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Subnet name. + /// Network prefix size. + /// is null. + public SubnetConfiguration(string subnetName, int networkPrefixSize) + { + Argument.AssertNotNull(subnetName, nameof(subnetName)); + + SubnetName = subnetName; + NetworkPrefixSize = networkPrefixSize; + } + + /// Initializes a new instance of . + /// Subnet name. + /// Subnet Resource ID. + /// Network prefix size. + /// Subnet delegation. + /// Address prefix. + /// Network security group ID. + /// Keeps track of any properties unknown to the library. + internal SubnetConfiguration(string subnetName, ResourceIdentifier subnetResourceId, int networkPrefixSize, string subnetDelegation, string addressPrefix, ResourceIdentifier networkSecurityGroupResourceId, IDictionary serializedAdditionalRawData) + { + SubnetName = subnetName; + SubnetResourceId = subnetResourceId; + NetworkPrefixSize = networkPrefixSize; + SubnetDelegation = subnetDelegation; + AddressPrefix = addressPrefix; + NetworkSecurityGroupResourceId = networkSecurityGroupResourceId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SubnetConfiguration() + { + } + + /// Subnet name. + public string SubnetName { get; set; } + /// Subnet Resource ID. + public ResourceIdentifier SubnetResourceId { get; } + /// Network prefix size. + public int NetworkPrefixSize { get; set; } + /// Subnet delegation. + public string SubnetDelegation { get; set; } + /// Address prefix. + public string AddressPrefix { get; } + /// Network security group ID. + public ResourceIdentifier NetworkSecurityGroupResourceId { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubPatchProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubPatchProperties.Serialization.cs new file mode 100644 index 000000000000..bdae76379470 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubPatchProperties.Serialization.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class TransitHubPatchProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitHubPatchProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.Value.ToString()); + } + if (Optional.IsDefined(TransitOption)) + { + writer.WritePropertyName("transitOption"u8); + writer.WriteObjectValue(TransitOption, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TransitHubPatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitHubPatchProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTransitHubPatchProperties(document.RootElement, options); + } + + internal static TransitHubPatchProperties DeserializeTransitHubPatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TransitHubState? state = default; + TransitOption transitOption = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("state"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + state = new TransitHubState(property.Value.GetString()); + continue; + } + if (property.NameEquals("transitOption"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + transitOption = TransitOption.DeserializeTransitOption(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TransitHubPatchProperties(state, transitOption, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(TransitHubPatchProperties)} does not support writing '{options.Format}' format."); + } + } + + TransitHubPatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTransitHubPatchProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TransitHubPatchProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubPatchProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubPatchProperties.cs new file mode 100644 index 000000000000..5faa67d90c5e --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubPatchProperties.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Transit Hub patchable Properties. + public partial class TransitHubPatchProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TransitHubPatchProperties() + { + } + + /// Initializes a new instance of . + /// The state of the transitHub. + /// The TransitOption of the transitHub. + /// Keeps track of any properties unknown to the library. + internal TransitHubPatchProperties(TransitHubState? state, TransitOption transitOption, IDictionary serializedAdditionalRawData) + { + State = state; + TransitOption = transitOption; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The state of the transitHub. + public TransitHubState? State { get; set; } + /// The TransitOption of the transitHub. + public TransitOption TransitOption { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubProperties.Serialization.cs new file mode 100644 index 000000000000..8699a0a866e4 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubProperties.Serialization.cs @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class TransitHubProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitHubProperties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.Value.ToString()); + } + if (Optional.IsDefined(TransitOption)) + { + writer.WritePropertyName("transitOption"u8); + writer.WriteObjectValue(TransitOption, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ResourceCollection)) + { + writer.WritePropertyName("resourceCollection"u8); + writer.WriteStartArray(); + foreach (var item in ResourceCollection) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TransitHubProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitHubProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTransitHubProperties(document.RootElement, options); + } + + internal static TransitHubProperties DeserializeTransitHubProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + TransitHubState? state = default; + TransitOption transitOption = default; + IReadOnlyList resourceCollection = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("state"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + state = new TransitHubState(property.Value.GetString()); + continue; + } + if (property.NameEquals("transitOption"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + transitOption = TransitOption.DeserializeTransitOption(property.Value, options); + continue; + } + if (property.NameEquals("resourceCollection"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new ResourceIdentifier(item.GetString())); + } + } + resourceCollection = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TransitHubProperties(provisioningState, state, transitOption, resourceCollection ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(TransitHubProperties)} does not support writing '{options.Format}' format."); + } + } + + TransitHubProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTransitHubProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TransitHubProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubProperties.cs new file mode 100644 index 000000000000..1d2d794b540d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubProperties.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Describes the properties of an Transit Hub. + public partial class TransitHubProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TransitHubProperties() + { + ResourceCollection = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// The state of the transitHub. + /// The TransitOption of the transitHub. + /// List of resource ids modified by transitHubs. + /// Keeps track of any properties unknown to the library. + internal TransitHubProperties(ProvisioningState? provisioningState, TransitHubState? state, TransitOption transitOption, IReadOnlyList resourceCollection, IDictionary serializedAdditionalRawData) + { + ProvisioningState = provisioningState; + State = state; + TransitOption = transitOption; + ResourceCollection = resourceCollection; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + /// The state of the transitHub. + public TransitHubState? State { get; set; } + /// The TransitOption of the transitHub. + public TransitOption TransitOption { get; set; } + /// List of resource ids modified by transitHubs. + public IReadOnlyList ResourceCollection { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourceListResult.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourceListResult.Serialization.cs new file mode 100644 index 000000000000..82ab31c9e101 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourceListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class TransitHubResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitHubResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TransitHubResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitHubResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTransitHubResourceListResult(document.RootElement, options); + } + + internal static TransitHubResourceListResult DeserializeTransitHubResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TransitHubResourceData.DeserializeTransitHubResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TransitHubResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(TransitHubResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + TransitHubResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTransitHubResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TransitHubResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourceListResult.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourceListResult.cs new file mode 100644 index 000000000000..dd9ad1cfa1c0 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourceListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The response of a TransitHubResource list operation. + internal partial class TransitHubResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The TransitHubResource items on this page. + /// is null. + internal TransitHubResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The TransitHubResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal TransitHubResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TransitHubResourceListResult() + { + } + + /// The TransitHubResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourcePatch.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourcePatch.Serialization.cs new file mode 100644 index 000000000000..339710ddc803 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourcePatch.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class TransitHubResourcePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitHubResourcePatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TransitHubResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitHubResourcePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTransitHubResourcePatch(document.RootElement, options); + } + + internal static TransitHubResourcePatch DeserializeTransitHubResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TransitHubPatchProperties properties = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = TransitHubPatchProperties.DeserializeTransitHubPatchProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TransitHubResourcePatch(properties, tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(TransitHubResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + TransitHubResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTransitHubResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TransitHubResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourcePatch.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourcePatch.cs new file mode 100644 index 000000000000..31034e0f5ea6 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubResourcePatch.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// TH Patch Resource. + public partial class TransitHubResourcePatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TransitHubResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The TransitHub resource. + /// Resource tags. + /// Keeps track of any properties unknown to the library. + internal TransitHubResourcePatch(TransitHubPatchProperties properties, IDictionary tags, IDictionary serializedAdditionalRawData) + { + Properties = properties; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The TransitHub resource. + public TransitHubPatchProperties Properties { get; set; } + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubState.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubState.cs new file mode 100644 index 000000000000..ae3d2d85000c --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitHubState.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Specifies the state of the transitHub. + public readonly partial struct TransitHubState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TransitHubState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PendingApprovalValue = "PendingApproval"; + private const string ApprovedValue = "Approved"; + private const string PendingUpdateValue = "PendingUpdate"; + private const string ActiveValue = "Active"; + private const string FailedValue = "Failed"; + + /// TransitHubState Type PendingApproval. + public static TransitHubState PendingApproval { get; } = new TransitHubState(PendingApprovalValue); + /// TransitHubState Type Approved. + public static TransitHubState Approved { get; } = new TransitHubState(ApprovedValue); + /// TransitHubState Type PendingUpdate. + public static TransitHubState PendingUpdate { get; } = new TransitHubState(PendingUpdateValue); + /// TransitHubState Type Active. + public static TransitHubState Active { get; } = new TransitHubState(ActiveValue); + /// TransitHubState Type Failed. + public static TransitHubState Failed { get; } = new TransitHubState(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(TransitHubState left, TransitHubState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TransitHubState left, TransitHubState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TransitHubState(string value) => new TransitHubState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TransitHubState other && Equals(other); + /// + public bool Equals(TransitHubState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOption.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOption.Serialization.cs new file mode 100644 index 000000000000..3468b6401d96 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOption.Serialization.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class TransitOption : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitOption)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (Optional.IsDefined(Params)) + { + writer.WritePropertyName("params"u8); + writer.WriteObjectValue(Params, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TransitOption IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitOption)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTransitOption(document.RootElement, options); + } + + internal static TransitOption DeserializeTransitOption(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TransitOptionType? type = default; + TransitOptionParams @params = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new TransitOptionType(property.Value.GetString()); + continue; + } + if (property.NameEquals("params"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @params = TransitOptionParams.DeserializeTransitOptionParams(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TransitOption(type, @params, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(TransitOption)} does not support writing '{options.Format}' format."); + } + } + + TransitOption IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTransitOption(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TransitOption)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOption.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOption.cs new file mode 100644 index 000000000000..32f86ce185b9 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOption.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// TransitOption Properties. + public partial class TransitOption + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TransitOption() + { + } + + /// Initializes a new instance of . + /// Transit Option Type. + /// Transit Option Params. + /// Keeps track of any properties unknown to the library. + internal TransitOption(TransitOptionType? type, TransitOptionParams @params, IDictionary serializedAdditionalRawData) + { + Type = type; + Params = @params; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Transit Option Type. + public TransitOptionType? Type { get; set; } + /// Transit Option Params. + public TransitOptionParams Params { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionParams.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionParams.Serialization.cs new file mode 100644 index 000000000000..a8c43dc0a603 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionParams.Serialization.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class TransitOptionParams : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitOptionParams)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ScaleUnits)) + { + writer.WritePropertyName("scaleUnits"u8); + writer.WriteNumberValue(ScaleUnits.Value); + } + if (Optional.IsDefined(RemoteVirtualNetworkId)) + { + writer.WritePropertyName("remoteVirtualNetworkId"u8); + writer.WriteStringValue(RemoteVirtualNetworkId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TransitOptionParams IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitOptionParams)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTransitOptionParams(document.RootElement, options); + } + + internal static TransitOptionParams DeserializeTransitOptionParams(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long? scaleUnits = default; + ResourceIdentifier remoteVirtualNetworkId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("scaleUnits"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + scaleUnits = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("remoteVirtualNetworkId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + remoteVirtualNetworkId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TransitOptionParams(scaleUnits, remoteVirtualNetworkId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(TransitOptionParams)} does not support writing '{options.Format}' format."); + } + } + + TransitOptionParams IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTransitOptionParams(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TransitOptionParams)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionParams.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionParams.cs new file mode 100644 index 000000000000..72380418ee0a --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionParams.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// TransitOptionParams Properties. + public partial class TransitOptionParams + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TransitOptionParams() + { + } + + /// Initializes a new instance of . + /// Transit Option Params scaleUnits. + /// Transit Option Params remoteVirtualNetworkId. + /// Keeps track of any properties unknown to the library. + internal TransitOptionParams(long? scaleUnits, ResourceIdentifier remoteVirtualNetworkId, IDictionary serializedAdditionalRawData) + { + ScaleUnits = scaleUnits; + RemoteVirtualNetworkId = remoteVirtualNetworkId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Transit Option Params scaleUnits. + public long? ScaleUnits { get; set; } + /// Transit Option Params remoteVirtualNetworkId. + public ResourceIdentifier RemoteVirtualNetworkId { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionType.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionType.cs new file mode 100644 index 000000000000..adf6808a8c6e --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/TransitOptionType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Specifies the type of the transitOption. + public readonly partial struct TransitOptionType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TransitOptionType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ExpressRouteValue = "ExpressRoute"; + private const string GatewayValue = "Gateway"; + private const string PeeringValue = "Peering"; + + /// TransitOptionType ExpressRoute. + public static TransitOptionType ExpressRoute { get; } = new TransitOptionType(ExpressRouteValue); + /// TransitOptionType Gateway. + public static TransitOptionType Gateway { get; } = new TransitOptionType(GatewayValue); + /// TransitOptionType Peering. + public static TransitOptionType Peering { get; } = new TransitOptionType(PeeringValue); + /// Determines if two values are the same. + public static bool operator ==(TransitOptionType left, TransitOptionType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TransitOptionType left, TransitOptionType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TransitOptionType(string value) => new TransitOptionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TransitOptionType other && Equals(other); + /// + public bool Equals(TransitOptionType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclavePatchProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclavePatchProperties.Serialization.cs new file mode 100644 index 000000000000..4736aed0968d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclavePatchProperties.Serialization.cs @@ -0,0 +1,254 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class VirtualEnclavePatchProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualEnclavePatchProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("enclaveVirtualNetwork"u8); + writer.WriteObjectValue(EnclaveVirtualNetwork, options); + if (Optional.IsDefined(BastionEnabled)) + { + writer.WritePropertyName("bastionEnabled"u8); + writer.WriteBooleanValue(BastionEnabled.Value); + } + if (Optional.IsCollectionDefined(EnclaveRoleAssignments)) + { + writer.WritePropertyName("enclaveRoleAssignments"u8); + writer.WriteStartArray(); + foreach (var item in EnclaveRoleAssignments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(WorkloadRoleAssignments)) + { + writer.WritePropertyName("workloadRoleAssignments"u8); + writer.WriteStartArray(); + foreach (var item in WorkloadRoleAssignments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(GovernedServiceList)) + { + writer.WritePropertyName("governedServiceList"u8); + writer.WriteStartArray(); + foreach (var item in GovernedServiceList) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(EnclaveDefaultSettings)) + { + writer.WritePropertyName("enclaveDefaultSettings"u8); + writer.WriteObjectValue(EnclaveDefaultSettings, options); + } + if (Optional.IsDefined(MaintenanceModeConfiguration)) + { + writer.WritePropertyName("maintenanceModeConfiguration"u8); + writer.WriteObjectValue(MaintenanceModeConfiguration, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VirtualEnclavePatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualEnclavePatchProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualEnclavePatchProperties(document.RootElement, options); + } + + internal static VirtualEnclavePatchProperties DeserializeVirtualEnclavePatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EnclaveVirtualNetworkModel enclaveVirtualNetwork = default; + bool? bastionEnabled = default; + IList enclaveRoleAssignments = default; + IList workloadRoleAssignments = default; + IList governedServiceList = default; + EnclaveDefaultSettingsPatchModel enclaveDefaultSettings = default; + MaintenanceModeConfigurationPatchModel maintenanceModeConfiguration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("enclaveVirtualNetwork"u8)) + { + enclaveVirtualNetwork = EnclaveVirtualNetworkModel.DeserializeEnclaveVirtualNetworkModel(property.Value, options); + continue; + } + if (property.NameEquals("bastionEnabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + bastionEnabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("enclaveRoleAssignments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RoleAssignmentItem.DeserializeRoleAssignmentItem(item, options)); + } + enclaveRoleAssignments = array; + continue; + } + if (property.NameEquals("workloadRoleAssignments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RoleAssignmentItem.DeserializeRoleAssignmentItem(item, options)); + } + workloadRoleAssignments = array; + continue; + } + if (property.NameEquals("governedServiceList"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(GovernedServiceItem.DeserializeGovernedServiceItem(item, options)); + } + governedServiceList = array; + continue; + } + if (property.NameEquals("enclaveDefaultSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enclaveDefaultSettings = EnclaveDefaultSettingsPatchModel.DeserializeEnclaveDefaultSettingsPatchModel(property.Value, options); + continue; + } + if (property.NameEquals("maintenanceModeConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maintenanceModeConfiguration = MaintenanceModeConfigurationPatchModel.DeserializeMaintenanceModeConfigurationPatchModel(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualEnclavePatchProperties( + enclaveVirtualNetwork, + bastionEnabled, + enclaveRoleAssignments ?? new ChangeTrackingList(), + workloadRoleAssignments ?? new ChangeTrackingList(), + governedServiceList ?? new ChangeTrackingList(), + enclaveDefaultSettings, + maintenanceModeConfiguration, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(VirtualEnclavePatchProperties)} does not support writing '{options.Format}' format."); + } + } + + VirtualEnclavePatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVirtualEnclavePatchProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualEnclavePatchProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclavePatchProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclavePatchProperties.cs new file mode 100644 index 000000000000..196d809f684e --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclavePatchProperties.cs @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Virtual Enclave Patchable Properties. + public partial class VirtualEnclavePatchProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Virtual Network. + /// is null. + public VirtualEnclavePatchProperties(EnclaveVirtualNetworkModel enclaveVirtualNetwork) + { + Argument.AssertNotNull(enclaveVirtualNetwork, nameof(enclaveVirtualNetwork)); + + EnclaveVirtualNetwork = enclaveVirtualNetwork; + EnclaveRoleAssignments = new ChangeTrackingList(); + WorkloadRoleAssignments = new ChangeTrackingList(); + GovernedServiceList = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Virtual Network. + /// Deploy Bastion service (True or False). + /// Enclave role assignments. + /// Workload role assignments. + /// Enclave specific policies. + /// Enclave default settings. + /// Maintenance Mode configuration. + /// Keeps track of any properties unknown to the library. + internal VirtualEnclavePatchProperties(EnclaveVirtualNetworkModel enclaveVirtualNetwork, bool? bastionEnabled, IList enclaveRoleAssignments, IList workloadRoleAssignments, IList governedServiceList, EnclaveDefaultSettingsPatchModel enclaveDefaultSettings, MaintenanceModeConfigurationPatchModel maintenanceModeConfiguration, IDictionary serializedAdditionalRawData) + { + EnclaveVirtualNetwork = enclaveVirtualNetwork; + BastionEnabled = bastionEnabled; + EnclaveRoleAssignments = enclaveRoleAssignments; + WorkloadRoleAssignments = workloadRoleAssignments; + GovernedServiceList = governedServiceList; + EnclaveDefaultSettings = enclaveDefaultSettings; + MaintenanceModeConfiguration = maintenanceModeConfiguration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualEnclavePatchProperties() + { + } + + /// Virtual Network. + public EnclaveVirtualNetworkModel EnclaveVirtualNetwork { get; } + /// Deploy Bastion service (True or False). + public bool? BastionEnabled { get; set; } + /// Enclave role assignments. + public IList EnclaveRoleAssignments { get; } + /// Workload role assignments. + public IList WorkloadRoleAssignments { get; } + /// Enclave specific policies. + public IList GovernedServiceList { get; } + /// Enclave default settings. + internal EnclaveDefaultSettingsPatchModel EnclaveDefaultSettings { get; set; } + /// Diagnostic Destination. + public DiagnosticDestination? EnclaveDefaultDiagnosticDestination + { + get => EnclaveDefaultSettings is null ? default : EnclaveDefaultSettings.DiagnosticDestination; + set + { + if (EnclaveDefaultSettings is null) + EnclaveDefaultSettings = new EnclaveDefaultSettingsPatchModel(); + EnclaveDefaultSettings.DiagnosticDestination = value; + } + } + + /// Maintenance Mode configuration. + public MaintenanceModeConfigurationPatchModel MaintenanceModeConfiguration { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclaveProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclaveProperties.Serialization.cs new file mode 100644 index 000000000000..8a47d43df0cc --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclaveProperties.Serialization.cs @@ -0,0 +1,361 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class VirtualEnclaveProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualEnclaveProperties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + writer.WritePropertyName("enclaveVirtualNetwork"u8); + writer.WriteObjectValue(EnclaveVirtualNetwork, options); + if (options.Format != "W" && Optional.IsDefined(EnclaveAddressSpaces)) + { + writer.WritePropertyName("enclaveAddressSpaces"u8); + writer.WriteObjectValue(EnclaveAddressSpaces, options); + } + writer.WritePropertyName("communityResourceId"u8); + writer.WriteStringValue(CommunityResourceId); + if (options.Format != "W" && Optional.IsCollectionDefined(ResourceCollection)) + { + writer.WritePropertyName("resourceCollection"u8); + writer.WriteStartArray(); + foreach (var item in ResourceCollection) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ManagedResourceGroupName)) + { + writer.WritePropertyName("managedResourceGroupName"u8); + writer.WriteStringValue(ManagedResourceGroupName); + } + if (options.Format != "W" && Optional.IsDefined(ManagedOnBehalfOfConfiguration)) + { + writer.WritePropertyName("managedOnBehalfOfConfiguration"u8); + writer.WriteObjectValue(ManagedOnBehalfOfConfiguration, options); + } + if (Optional.IsDefined(BastionEnabled)) + { + writer.WritePropertyName("bastionEnabled"u8); + writer.WriteBooleanValue(BastionEnabled.Value); + } + if (Optional.IsCollectionDefined(EnclaveRoleAssignments)) + { + writer.WritePropertyName("enclaveRoleAssignments"u8); + writer.WriteStartArray(); + foreach (var item in EnclaveRoleAssignments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(WorkloadRoleAssignments)) + { + writer.WritePropertyName("workloadRoleAssignments"u8); + writer.WriteStartArray(); + foreach (var item in WorkloadRoleAssignments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(GovernedServiceList)) + { + writer.WritePropertyName("governedServiceList"u8); + writer.WriteStartArray(); + foreach (var item in GovernedServiceList) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(EnclaveDefaultSettings)) + { + writer.WritePropertyName("enclaveDefaultSettings"u8); + writer.WriteObjectValue(EnclaveDefaultSettings, options); + } + if (Optional.IsDefined(MaintenanceModeConfiguration)) + { + writer.WritePropertyName("maintenanceModeConfiguration"u8); + writer.WriteObjectValue(MaintenanceModeConfiguration, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VirtualEnclaveProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualEnclaveProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualEnclaveProperties(document.RootElement, options); + } + + internal static VirtualEnclaveProperties DeserializeVirtualEnclaveProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + EnclaveVirtualNetworkModel enclaveVirtualNetwork = default; + EnclaveAddressSpacesModel enclaveAddressSpaces = default; + ResourceIdentifier communityResourceId = default; + IReadOnlyList resourceCollection = default; + string managedResourceGroupName = default; + ManagedOnBehalfOfConfiguration managedOnBehalfOfConfiguration = default; + bool? bastionEnabled = default; + IList enclaveRoleAssignments = default; + IList workloadRoleAssignments = default; + IList governedServiceList = default; + EnclaveDefaultSettingsModel enclaveDefaultSettings = default; + MaintenanceModeConfigurationModel maintenanceModeConfiguration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("enclaveVirtualNetwork"u8)) + { + enclaveVirtualNetwork = EnclaveVirtualNetworkModel.DeserializeEnclaveVirtualNetworkModel(property.Value, options); + continue; + } + if (property.NameEquals("enclaveAddressSpaces"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enclaveAddressSpaces = EnclaveAddressSpacesModel.DeserializeEnclaveAddressSpacesModel(property.Value, options); + continue; + } + if (property.NameEquals("communityResourceId"u8)) + { + communityResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("resourceCollection"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new ResourceIdentifier(item.GetString())); + } + } + resourceCollection = array; + continue; + } + if (property.NameEquals("managedResourceGroupName"u8)) + { + managedResourceGroupName = property.Value.GetString(); + continue; + } + if (property.NameEquals("managedOnBehalfOfConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + managedOnBehalfOfConfiguration = ManagedOnBehalfOfConfiguration.DeserializeManagedOnBehalfOfConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("bastionEnabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + bastionEnabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("enclaveRoleAssignments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RoleAssignmentItem.DeserializeRoleAssignmentItem(item, options)); + } + enclaveRoleAssignments = array; + continue; + } + if (property.NameEquals("workloadRoleAssignments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RoleAssignmentItem.DeserializeRoleAssignmentItem(item, options)); + } + workloadRoleAssignments = array; + continue; + } + if (property.NameEquals("governedServiceList"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(GovernedServiceItem.DeserializeGovernedServiceItem(item, options)); + } + governedServiceList = array; + continue; + } + if (property.NameEquals("enclaveDefaultSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enclaveDefaultSettings = EnclaveDefaultSettingsModel.DeserializeEnclaveDefaultSettingsModel(property.Value, options); + continue; + } + if (property.NameEquals("maintenanceModeConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maintenanceModeConfiguration = MaintenanceModeConfigurationModel.DeserializeMaintenanceModeConfigurationModel(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualEnclaveProperties( + provisioningState, + enclaveVirtualNetwork, + enclaveAddressSpaces, + communityResourceId, + resourceCollection ?? new ChangeTrackingList(), + managedResourceGroupName, + managedOnBehalfOfConfiguration, + bastionEnabled, + enclaveRoleAssignments ?? new ChangeTrackingList(), + workloadRoleAssignments ?? new ChangeTrackingList(), + governedServiceList ?? new ChangeTrackingList(), + enclaveDefaultSettings, + maintenanceModeConfiguration, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(VirtualEnclaveProperties)} does not support writing '{options.Format}' format."); + } + } + + VirtualEnclaveProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVirtualEnclaveProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualEnclaveProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclaveProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclaveProperties.cs new file mode 100644 index 000000000000..f7298aa62cdf --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/VirtualEnclaveProperties.cs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Virtual Enclave Resource properties. + public partial class VirtualEnclaveProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Virtual Network. + /// Community Resource Id. + /// or is null. + public VirtualEnclaveProperties(EnclaveVirtualNetworkModel enclaveVirtualNetwork, ResourceIdentifier communityResourceId) + { + Argument.AssertNotNull(enclaveVirtualNetwork, nameof(enclaveVirtualNetwork)); + Argument.AssertNotNull(communityResourceId, nameof(communityResourceId)); + + EnclaveVirtualNetwork = enclaveVirtualNetwork; + CommunityResourceId = communityResourceId; + ResourceCollection = new ChangeTrackingList(); + EnclaveRoleAssignments = new ChangeTrackingList(); + WorkloadRoleAssignments = new ChangeTrackingList(); + GovernedServiceList = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Provisioning State. + /// Virtual Network. + /// Enclave Address Spaces. + /// Community Resource Id. + /// List of resource ids created by Virtual Enclave. + /// Managed resource group name. + /// Managed On Behalf Of Configuration. + /// Deploy Bastion service (True or False). + /// Enclave role assignments. + /// Workload role assignments. + /// Enclave specific policies. + /// Enclave default settings. + /// Maintenance Mode configuration. + /// Keeps track of any properties unknown to the library. + internal VirtualEnclaveProperties(ProvisioningState? provisioningState, EnclaveVirtualNetworkModel enclaveVirtualNetwork, EnclaveAddressSpacesModel enclaveAddressSpaces, ResourceIdentifier communityResourceId, IReadOnlyList resourceCollection, string managedResourceGroupName, ManagedOnBehalfOfConfiguration managedOnBehalfOfConfiguration, bool? bastionEnabled, IList enclaveRoleAssignments, IList workloadRoleAssignments, IList governedServiceList, EnclaveDefaultSettingsModel enclaveDefaultSettings, MaintenanceModeConfigurationModel maintenanceModeConfiguration, IDictionary serializedAdditionalRawData) + { + ProvisioningState = provisioningState; + EnclaveVirtualNetwork = enclaveVirtualNetwork; + EnclaveAddressSpaces = enclaveAddressSpaces; + CommunityResourceId = communityResourceId; + ResourceCollection = resourceCollection; + ManagedResourceGroupName = managedResourceGroupName; + ManagedOnBehalfOfConfiguration = managedOnBehalfOfConfiguration; + BastionEnabled = bastionEnabled; + EnclaveRoleAssignments = enclaveRoleAssignments; + WorkloadRoleAssignments = workloadRoleAssignments; + GovernedServiceList = governedServiceList; + EnclaveDefaultSettings = enclaveDefaultSettings; + MaintenanceModeConfiguration = maintenanceModeConfiguration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualEnclaveProperties() + { + } + + /// Provisioning State. + public ProvisioningState? ProvisioningState { get; } + /// Virtual Network. + public EnclaveVirtualNetworkModel EnclaveVirtualNetwork { get; set; } + /// Enclave Address Spaces. + public EnclaveAddressSpacesModel EnclaveAddressSpaces { get; } + /// Community Resource Id. + public ResourceIdentifier CommunityResourceId { get; set; } + /// List of resource ids created by Virtual Enclave. + public IReadOnlyList ResourceCollection { get; } + /// Managed resource group name. + public string ManagedResourceGroupName { get; } + /// Managed On Behalf Of Configuration. + internal ManagedOnBehalfOfConfiguration ManagedOnBehalfOfConfiguration { get; } + /// Managed-On-Behalf-Of broker resources. + public IReadOnlyList ManagedOnBehalfOfMoboBrokerResources + { + get => ManagedOnBehalfOfConfiguration?.MoboBrokerResources; + } + + /// Deploy Bastion service (True or False). + public bool? BastionEnabled { get; set; } + /// Enclave role assignments. + public IList EnclaveRoleAssignments { get; } + /// Workload role assignments. + public IList WorkloadRoleAssignments { get; } + /// Enclave specific policies. + public IList GovernedServiceList { get; } + /// Enclave default settings. + public EnclaveDefaultSettingsModel EnclaveDefaultSettings { get; set; } + /// Maintenance Mode configuration. + public MaintenanceModeConfigurationModel MaintenanceModeConfiguration { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadPatchProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadPatchProperties.Serialization.cs new file mode 100644 index 000000000000..096ee011f56b --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadPatchProperties.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class WorkloadPatchProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkloadPatchProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(ResourceGroupCollection)) + { + writer.WritePropertyName("resourceGroupCollection"u8); + writer.WriteStartArray(); + foreach (var item in ResourceGroupCollection) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WorkloadPatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkloadPatchProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkloadPatchProperties(document.RootElement, options); + } + + internal static WorkloadPatchProperties DeserializeWorkloadPatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList resourceGroupCollection = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceGroupCollection"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + resourceGroupCollection = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WorkloadPatchProperties(resourceGroupCollection ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(WorkloadPatchProperties)} does not support writing '{options.Format}' format."); + } + } + + WorkloadPatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWorkloadPatchProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkloadPatchProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadPatchProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadPatchProperties.cs new file mode 100644 index 000000000000..e6e3409cbcd1 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadPatchProperties.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Workload patchable Properties. + internal partial class WorkloadPatchProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public WorkloadPatchProperties() + { + ResourceGroupCollection = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of resource group ids. + /// Keeps track of any properties unknown to the library. + internal WorkloadPatchProperties(IList resourceGroupCollection, IDictionary serializedAdditionalRawData) + { + ResourceGroupCollection = resourceGroupCollection; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// List of resource group ids. + public IList ResourceGroupCollection { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadProperties.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadProperties.Serialization.cs new file mode 100644 index 000000000000..36b2639b1294 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadProperties.Serialization.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class WorkloadProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkloadProperties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsCollectionDefined(ResourceGroupCollection)) + { + writer.WritePropertyName("resourceGroupCollection"u8); + writer.WriteStartArray(); + foreach (var item in ResourceGroupCollection) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ManagedOnBehalfOfConfiguration)) + { + writer.WritePropertyName("managedOnBehalfOfConfiguration"u8); + writer.WriteObjectValue(ManagedOnBehalfOfConfiguration, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WorkloadProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkloadProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkloadProperties(document.RootElement, options); + } + + internal static WorkloadProperties DeserializeWorkloadProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + IList resourceGroupCollection = default; + ManagedOnBehalfOfConfiguration managedOnBehalfOfConfiguration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("resourceGroupCollection"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + resourceGroupCollection = array; + continue; + } + if (property.NameEquals("managedOnBehalfOfConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + managedOnBehalfOfConfiguration = ManagedOnBehalfOfConfiguration.DeserializeManagedOnBehalfOfConfiguration(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WorkloadProperties(provisioningState, resourceGroupCollection ?? new ChangeTrackingList(), managedOnBehalfOfConfiguration, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(WorkloadProperties)} does not support writing '{options.Format}' format."); + } + } + + WorkloadProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWorkloadProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkloadProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadProperties.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadProperties.cs new file mode 100644 index 000000000000..9cfc9c89a4c9 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadProperties.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Workload Resource properties. + public partial class WorkloadProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public WorkloadProperties() + { + ResourceGroupCollection = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Provisioning State. + /// List of resource group ids. + /// Managed On Behalf Of Configuration. + /// Keeps track of any properties unknown to the library. + internal WorkloadProperties(ProvisioningState? provisioningState, IList resourceGroupCollection, ManagedOnBehalfOfConfiguration managedOnBehalfOfConfiguration, IDictionary serializedAdditionalRawData) + { + ProvisioningState = provisioningState; + ResourceGroupCollection = resourceGroupCollection; + ManagedOnBehalfOfConfiguration = managedOnBehalfOfConfiguration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Provisioning State. + public ProvisioningState? ProvisioningState { get; } + /// List of resource group ids. + public IList ResourceGroupCollection { get; } + /// Managed On Behalf Of Configuration. + internal ManagedOnBehalfOfConfiguration ManagedOnBehalfOfConfiguration { get; } + /// Managed-On-Behalf-Of broker resources. + public IReadOnlyList ManagedOnBehalfOfMoboBrokerResources + { + get => ManagedOnBehalfOfConfiguration?.MoboBrokerResources; + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourceListResult.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourceListResult.Serialization.cs new file mode 100644 index 000000000000..5ec9da01013b --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourceListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + internal partial class WorkloadResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkloadResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WorkloadResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkloadResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkloadResourceListResult(document.RootElement, options); + } + + internal static WorkloadResourceListResult DeserializeWorkloadResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(WorkloadResourceData.DeserializeWorkloadResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WorkloadResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(WorkloadResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + WorkloadResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWorkloadResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkloadResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourceListResult.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourceListResult.cs new file mode 100644 index 000000000000..63937f82add0 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourceListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// The response of a WorkloadResource list operation. + internal partial class WorkloadResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The WorkloadResource items on this page. + /// is null. + internal WorkloadResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The WorkloadResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal WorkloadResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal WorkloadResourceListResult() + { + } + + /// The WorkloadResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourcePatch.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourcePatch.Serialization.cs new file mode 100644 index 000000000000..13a36e3f0bd5 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourcePatch.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + public partial class WorkloadResourcePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkloadResourcePatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WorkloadResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkloadResourcePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkloadResourcePatch(document.RootElement, options); + } + + internal static WorkloadResourcePatch DeserializeWorkloadResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WorkloadPatchProperties properties = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = WorkloadPatchProperties.DeserializeWorkloadPatchProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WorkloadResourcePatch(properties, tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(WorkloadResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + WorkloadResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWorkloadResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkloadResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourcePatch.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourcePatch.cs new file mode 100644 index 000000000000..d9231a6ddfe4 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/Models/WorkloadResourcePatch.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.VirtualEnclaves.Models +{ + /// Workload Patch Resource. + public partial class WorkloadResourcePatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public WorkloadResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Workload Patch properties. + /// Resource tags. + /// Keeps track of any properties unknown to the library. + internal WorkloadResourcePatch(WorkloadPatchProperties properties, IDictionary tags, IDictionary serializedAdditionalRawData) + { + Properties = properties; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Workload Patch properties. + internal WorkloadPatchProperties Properties { get; set; } + /// List of resource group ids. + public IList WorkloadPatchResourceGroupCollection + { + get + { + if (Properties is null) + Properties = new WorkloadPatchProperties(); + return Properties.ResourceGroupCollection; + } + } + + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ProviderConstants.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..76cfd172d373 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/ProviderConstants.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/ApprovalRestOperations.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/ApprovalRestOperations.cs new file mode 100644 index 000000000000..d9574f75e175 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/ApprovalRestOperations.cs @@ -0,0 +1,607 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal partial class ApprovalRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ApprovalRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public ApprovalRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2025-05-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string resourceUri, string approvalName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals/", false); + uri.AppendPath(approvalName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string resourceUri, string approvalName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals/", false); + uri.AppendPath(approvalName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a ApprovalResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the approvals resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string resourceUri, string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + + using var message = CreateGetRequest(resourceUri, approvalName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ApprovalResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = ApprovalResourceData.DeserializeApprovalResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ApprovalResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a ApprovalResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the approvals resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response Get(string resourceUri, string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + + using var message = CreateGetRequest(resourceUri, approvalName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ApprovalResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = ApprovalResourceData.DeserializeApprovalResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ApprovalResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string resourceUri, string approvalName, ApprovalResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals/", false); + uri.AppendPath(approvalName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceUri, string approvalName, ApprovalResourceData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals/", false); + uri.AppendPath(approvalName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a ApprovalResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the approvals resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string resourceUri, string approvalName, ApprovalResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(resourceUri, approvalName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a ApprovalResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the approvals resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string resourceUri, string approvalName, ApprovalResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(resourceUri, approvalName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByParentRequestUri(string resourceUri) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByParentRequest(string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List ApprovalResource resources by parent. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// is null. + public async Task> ListByParentAsync(string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListByParentRequest(resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ApprovalResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = ApprovalResourceListResult.DeserializeApprovalResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List ApprovalResource resources by parent. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// is null. + public Response ListByParent(string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListByParentRequest(resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ApprovalResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = ApprovalResourceListResult.DeserializeApprovalResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string resourceUri, string approvalName, ApprovalResourcePatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals/", false); + uri.AppendPath(approvalName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string resourceUri, string approvalName, ApprovalResourcePatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals/", false); + uri.AppendPath(approvalName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a ApprovalResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the approvals resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string resourceUri, string approvalName, ApprovalResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(resourceUri, approvalName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a ApprovalResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the approvals resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public Response Update(string resourceUri, string approvalName, ApprovalResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(resourceUri, approvalName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string resourceUri, string approvalName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals/", false); + uri.AppendPath(approvalName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string resourceUri, string approvalName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals/", false); + uri.AppendPath(approvalName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a ApprovalResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the approvals resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string resourceUri, string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + + using var message = CreateDeleteRequest(resourceUri, approvalName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a ApprovalResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the approvals resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response Delete(string resourceUri, string approvalName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + + using var message = CreateDeleteRequest(resourceUri, approvalName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateNotifyInitiatorRequestUri(string resourceUri, string approvalName, ApprovalActionContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals/", false); + uri.AppendPath(approvalName, true); + uri.AppendPath("/notifyInitiator", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateNotifyInitiatorRequest(string resourceUri, string approvalName, ApprovalActionContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.Mission/approvals/", false); + uri.AppendPath(approvalName, true); + uri.AppendPath("/notifyInitiator", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Upon receiving approval or rejection from approver, this facilitates actions on approval resource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the approvals resource. + /// The content of the action request. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task NotifyInitiatorAsync(string resourceUri, string approvalName, ApprovalActionContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateNotifyInitiatorRequest(resourceUri, approvalName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Upon receiving approval or rejection from approver, this facilitates actions on approval resource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the approvals resource. + /// The content of the action request. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public Response NotifyInitiator(string resourceUri, string approvalName, ApprovalActionContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(approvalName, nameof(approvalName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateNotifyInitiatorRequest(resourceUri, approvalName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByParentNextPageRequestUri(string nextLink, string resourceUri) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByParentNextPageRequest(string nextLink, string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List ApprovalResource resources by parent. + /// The URL to the next page of results. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// or is null. + public async Task> ListByParentNextPageAsync(string nextLink, string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListByParentNextPageRequest(nextLink, resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ApprovalResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = ApprovalResourceListResult.DeserializeApprovalResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List ApprovalResource resources by parent. + /// The URL to the next page of results. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// or is null. + public Response ListByParentNextPage(string nextLink, string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListByParentNextPageRequest(nextLink, resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ApprovalResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = ApprovalResourceListResult.DeserializeApprovalResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/CommunityEndpointsRestOperations.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/CommunityEndpointsRestOperations.cs new file mode 100644 index 000000000000..f84e6ab73dd7 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/CommunityEndpointsRestOperations.cs @@ -0,0 +1,983 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal partial class CommunityEndpointsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of CommunityEndpointsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public CommunityEndpointsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2025-05-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a CommunityEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunityEndpointResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CommunityEndpointResourceData.DeserializeCommunityEndpointResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CommunityEndpointResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a CommunityEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunityEndpointResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CommunityEndpointResourceData.DeserializeCommunityEndpointResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CommunityEndpointResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CommunityEndpointResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CommunityEndpointResourceData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a CommunityEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CommunityEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a CommunityEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CommunityEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CommunityEndpointResourcePatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CommunityEndpointResourcePatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a CommunityEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CommunityEndpointResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a CommunityEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CommunityEndpointResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a CommunityEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a CommunityEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByCommunityResourceRequestUri(string subscriptionId, string resourceGroupName, string communityName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByCommunityResourceRequest(string subscriptionId, string resourceGroupName, string communityName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunityEndpointResource resources by CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCommunityResourceAsync(string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListByCommunityResourceRequest(subscriptionId, resourceGroupName, communityName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunityEndpointResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CommunityEndpointResourceListResult.DeserializeCommunityEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunityEndpointResource resources by CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCommunityResource(string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListByCommunityResourceRequest(subscriptionId, resourceGroupName, communityName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunityEndpointResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CommunityEndpointResourceListResult.DeserializeCommunityEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId, string communityName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId, string communityName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunityEndpointResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, communityName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunityEndpointResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CommunityEndpointResourceListResult.DeserializeCommunityEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunityEndpointResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, communityName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunityEndpointResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CommunityEndpointResourceListResult.DeserializeCommunityEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateHandleApprovalCreationRequestUri(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, ApprovalCallbackRequest body) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendPath("/handleApprovalCreation", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateHandleApprovalCreationRequest(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, ApprovalCallbackRequest body) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendPath("/handleApprovalCreation", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(body, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Callback that triggers on approval state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task HandleApprovalCreationAsync(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalCreationRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName, body); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Callback that triggers on approval state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response HandleApprovalCreation(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalCreationRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName, body); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateHandleApprovalDeletionRequestUri(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, VirtualEnclavesApprovalDeletionCallbackRequestContent body) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendPath("/handleApprovalDeletion", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateHandleApprovalDeletionRequest(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, VirtualEnclavesApprovalDeletionCallbackRequestContent body) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/communityEndpoints/", false); + uri.AppendPath(communityEndpointName, true); + uri.AppendPath("/handleApprovalDeletion", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(body, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Callback that triggers on approval deletion state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task HandleApprovalDeletionAsync(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalDeletionRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName, body); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Callback that triggers on approval deletion state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the Community Endpoint Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response HandleApprovalDeletion(string subscriptionId, string resourceGroupName, string communityName, string communityEndpointName, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(communityEndpointName, nameof(communityEndpointName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalDeletionRequest(subscriptionId, resourceGroupName, communityName, communityEndpointName, body); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByCommunityResourceNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string communityName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByCommunityResourceNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string communityName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunityEndpointResource resources by CommunityResource. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCommunityResourceNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListByCommunityResourceNextPageRequest(nextLink, subscriptionId, resourceGroupName, communityName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunityEndpointResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CommunityEndpointResourceListResult.DeserializeCommunityEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunityEndpointResource resources by CommunityResource. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCommunityResourceNextPage(string nextLink, string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListByCommunityResourceNextPageRequest(nextLink, subscriptionId, resourceGroupName, communityName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunityEndpointResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CommunityEndpointResourceListResult.DeserializeCommunityEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId, string communityName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId, string communityName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunityEndpointResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, communityName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunityEndpointResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CommunityEndpointResourceListResult.DeserializeCommunityEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunityEndpointResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, communityName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunityEndpointResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CommunityEndpointResourceListResult.DeserializeCommunityEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/CommunityRestOperations.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/CommunityRestOperations.cs new file mode 100644 index 000000000000..8734dee57785 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/CommunityRestOperations.cs @@ -0,0 +1,825 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal partial class CommunityRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of CommunityRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public CommunityRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2025-05-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string communityName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string communityName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, communityName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunityResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CommunityResourceData.DeserializeCommunityResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CommunityResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, communityName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunityResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CommunityResourceData.DeserializeCommunityResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CommunityResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string communityName, CommunityResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string communityName, CommunityResourceData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string communityName, CommunityResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, communityName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string communityName, CommunityResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, communityName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string communityName, CommunityResourcePatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string communityName, CommunityResourcePatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string communityName, CommunityResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, communityName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string communityName, CommunityResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, communityName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string communityName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string communityName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, communityName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, communityName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunityResource resources by resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunityResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CommunityResourceListResult.DeserializeCommunityResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunityResource resources by resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunityResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CommunityResourceListResult.DeserializeCommunityResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/communities", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/communities", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunityResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunityResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CommunityResourceListResult.DeserializeCommunityResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunityResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunityResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CommunityResourceListResult.DeserializeCommunityResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCheckAddressSpaceAvailabilityRequestUri(string subscriptionId, string resourceGroupName, string communityName, CheckAddressSpaceAvailabilityContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/checkAddressSpaceAvailability", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCheckAddressSpaceAvailabilityRequest(string subscriptionId, string resourceGroupName, string communityName, CheckAddressSpaceAvailabilityContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/checkAddressSpaceAvailability", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Checks that the IP Address Space to be allocated for this Community is available. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// Check IP Address Space request body. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> CheckAddressSpaceAvailabilityAsync(string subscriptionId, string resourceGroupName, string communityName, CheckAddressSpaceAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCheckAddressSpaceAvailabilityRequest(subscriptionId, resourceGroupName, communityName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CheckAddressSpaceAvailabilityResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CheckAddressSpaceAvailabilityResponse.DeserializeCheckAddressSpaceAvailabilityResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Checks that the IP Address Space to be allocated for this Community is available. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// Check IP Address Space request body. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response CheckAddressSpaceAvailability(string subscriptionId, string resourceGroupName, string communityName, CheckAddressSpaceAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCheckAddressSpaceAvailabilityRequest(subscriptionId, resourceGroupName, communityName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CheckAddressSpaceAvailabilityResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CheckAddressSpaceAvailabilityResponse.DeserializeCheckAddressSpaceAvailabilityResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunityResource resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunityResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CommunityResourceListResult.DeserializeCommunityResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunityResource resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunityResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CommunityResourceListResult.DeserializeCommunityResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunityResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunityResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CommunityResourceListResult.DeserializeCommunityResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunityResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunityResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CommunityResourceListResult.DeserializeCommunityResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/EnclaveConnectionRestOperations.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/EnclaveConnectionRestOperations.cs new file mode 100644 index 000000000000..e3a35da71b77 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/EnclaveConnectionRestOperations.cs @@ -0,0 +1,911 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal partial class EnclaveConnectionRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of EnclaveConnectionRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public EnclaveConnectionRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2025-05-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string enclaveConnectionName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string enclaveConnectionName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a EnclaveConnectionResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, enclaveConnectionName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveConnectionResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveConnectionResourceData.DeserializeEnclaveConnectionResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((EnclaveConnectionResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a EnclaveConnectionResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, enclaveConnectionName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveConnectionResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveConnectionResourceData.DeserializeEnclaveConnectionResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((EnclaveConnectionResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string enclaveConnectionName, EnclaveConnectionResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string enclaveConnectionName, EnclaveConnectionResourceData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a EnclaveConnectionResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string enclaveConnectionName, EnclaveConnectionResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, enclaveConnectionName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a EnclaveConnectionResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string enclaveConnectionName, EnclaveConnectionResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, enclaveConnectionName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string enclaveConnectionName, EnclaveConnectionResourcePatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string enclaveConnectionName, EnclaveConnectionResourcePatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a EnclaveConnectionResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string enclaveConnectionName, EnclaveConnectionResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, enclaveConnectionName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a EnclaveConnectionResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string enclaveConnectionName, EnclaveConnectionResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, enclaveConnectionName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string enclaveConnectionName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string enclaveConnectionName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a EnclaveConnectionResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, enclaveConnectionName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a EnclaveConnectionResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string enclaveConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, enclaveConnectionName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveConnectionResource resources by resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveConnectionResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveConnectionResourceListResult.DeserializeEnclaveConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveConnectionResource resources by resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveConnectionResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveConnectionResourceListResult.DeserializeEnclaveConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveConnectionResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveConnectionResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveConnectionResourceListResult.DeserializeEnclaveConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveConnectionResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveConnectionResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveConnectionResourceListResult.DeserializeEnclaveConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateHandleApprovalCreationRequestUri(string subscriptionId, string resourceGroupName, string enclaveConnectionName, ApprovalCallbackRequest body) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendPath("/handleApprovalCreation", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateHandleApprovalCreationRequest(string subscriptionId, string resourceGroupName, string enclaveConnectionName, ApprovalCallbackRequest body) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendPath("/handleApprovalCreation", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(body, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Callback that triggers on approval state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task HandleApprovalCreationAsync(string subscriptionId, string resourceGroupName, string enclaveConnectionName, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalCreationRequest(subscriptionId, resourceGroupName, enclaveConnectionName, body); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Callback that triggers on approval state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response HandleApprovalCreation(string subscriptionId, string resourceGroupName, string enclaveConnectionName, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalCreationRequest(subscriptionId, resourceGroupName, enclaveConnectionName, body); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateHandleApprovalDeletionRequestUri(string subscriptionId, string resourceGroupName, string enclaveConnectionName, VirtualEnclavesApprovalDeletionCallbackRequestContent body) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendPath("/handleApprovalDeletion", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateHandleApprovalDeletionRequest(string subscriptionId, string resourceGroupName, string enclaveConnectionName, VirtualEnclavesApprovalDeletionCallbackRequestContent body) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/enclaveConnections/", false); + uri.AppendPath(enclaveConnectionName, true); + uri.AppendPath("/handleApprovalDeletion", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(body, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Callback that triggers on approval deletion state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task HandleApprovalDeletionAsync(string subscriptionId, string resourceGroupName, string enclaveConnectionName, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalDeletionRequest(subscriptionId, resourceGroupName, enclaveConnectionName, body); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Callback that triggers on approval deletion state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Enclave Connection Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response HandleApprovalDeletion(string subscriptionId, string resourceGroupName, string enclaveConnectionName, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(enclaveConnectionName, nameof(enclaveConnectionName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalDeletionRequest(subscriptionId, resourceGroupName, enclaveConnectionName, body); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveConnectionResource resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveConnectionResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveConnectionResourceListResult.DeserializeEnclaveConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveConnectionResource resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveConnectionResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveConnectionResourceListResult.DeserializeEnclaveConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveConnectionResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveConnectionResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveConnectionResourceListResult.DeserializeEnclaveConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveConnectionResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveConnectionResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveConnectionResourceListResult.DeserializeEnclaveConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/EnclaveEndpointsRestOperations.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/EnclaveEndpointsRestOperations.cs new file mode 100644 index 000000000000..8ac22e653861 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/EnclaveEndpointsRestOperations.cs @@ -0,0 +1,983 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal partial class EnclaveEndpointsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of EnclaveEndpointsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public EnclaveEndpointsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2025-05-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a EnclaveEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveEndpointResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveEndpointResourceData.DeserializeEnclaveEndpointResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((EnclaveEndpointResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a EnclaveEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveEndpointResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveEndpointResourceData.DeserializeEnclaveEndpointResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((EnclaveEndpointResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, EnclaveEndpointResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, EnclaveEndpointResourceData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a EnclaveEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, EnclaveEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a EnclaveEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, EnclaveEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, EnclaveEndpointResourcePatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, EnclaveEndpointResourcePatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a EnclaveEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, EnclaveEndpointResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a EnclaveEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, EnclaveEndpointResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a EnclaveEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a EnclaveEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByEnclaveResourceRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByEnclaveResourceRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveEndpointResource resources by EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByEnclaveResourceAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListByEnclaveResourceRequest(subscriptionId, resourceGroupName, virtualEnclaveName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveEndpointResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveEndpointResourceListResult.DeserializeEnclaveEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveEndpointResource resources by EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByEnclaveResource(string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListByEnclaveResourceRequest(subscriptionId, resourceGroupName, virtualEnclaveName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveEndpointResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveEndpointResourceListResult.DeserializeEnclaveEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId, string virtualEnclaveName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId, string virtualEnclaveName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveEndpointResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, virtualEnclaveName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveEndpointResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveEndpointResourceListResult.DeserializeEnclaveEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveEndpointResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, virtualEnclaveName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveEndpointResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveEndpointResourceListResult.DeserializeEnclaveEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateHandleApprovalCreationRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, ApprovalCallbackRequest body) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendPath("/handleApprovalCreation", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateHandleApprovalCreationRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, ApprovalCallbackRequest body) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendPath("/handleApprovalCreation", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(body, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Callback that triggers on approval state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task HandleApprovalCreationAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalCreationRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName, body); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Callback that triggers on approval state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response HandleApprovalCreation(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalCreationRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName, body); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateHandleApprovalDeletionRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, VirtualEnclavesApprovalDeletionCallbackRequestContent body) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendPath("/handleApprovalDeletion", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateHandleApprovalDeletionRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, VirtualEnclavesApprovalDeletionCallbackRequestContent body) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/enclaveEndpoints/", false); + uri.AppendPath(enclaveEndpointName, true); + uri.AppendPath("/handleApprovalDeletion", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(body, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Callback that triggers on approval deletion state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task HandleApprovalDeletionAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalDeletionRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName, body); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Callback that triggers on approval deletion state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the Enclave Endpoint Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response HandleApprovalDeletion(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string enclaveEndpointName, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(enclaveEndpointName, nameof(enclaveEndpointName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalDeletionRequest(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName, body); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByEnclaveResourceNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByEnclaveResourceNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveEndpointResource resources by EnclaveResource. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByEnclaveResourceNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListByEnclaveResourceNextPageRequest(nextLink, subscriptionId, resourceGroupName, virtualEnclaveName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveEndpointResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveEndpointResourceListResult.DeserializeEnclaveEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveEndpointResource resources by EnclaveResource. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByEnclaveResourceNextPage(string nextLink, string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListByEnclaveResourceNextPageRequest(nextLink, subscriptionId, resourceGroupName, virtualEnclaveName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveEndpointResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveEndpointResourceListResult.DeserializeEnclaveEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId, string virtualEnclaveName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId, string virtualEnclaveName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveEndpointResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, virtualEnclaveName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveEndpointResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveEndpointResourceListResult.DeserializeEnclaveEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveEndpointResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, virtualEnclaveName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveEndpointResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveEndpointResourceListResult.DeserializeEnclaveEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/TransitHubRestOperations.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/TransitHubRestOperations.cs new file mode 100644 index 000000000000..03b5c5f60a6c --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/TransitHubRestOperations.cs @@ -0,0 +1,779 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal partial class TransitHubRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of TransitHubRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public TransitHubRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2025-05-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string communityName, string transitHubName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs/", false); + uri.AppendPath(transitHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string communityName, string transitHubName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs/", false); + uri.AppendPath(transitHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a TransitHubResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, communityName, transitHubName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TransitHubResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = TransitHubResourceData.DeserializeTransitHubResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((TransitHubResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a TransitHubResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, communityName, transitHubName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TransitHubResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = TransitHubResourceData.DeserializeTransitHubResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((TransitHubResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, TransitHubResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs/", false); + uri.AppendPath(transitHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, TransitHubResourceData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs/", false); + uri.AppendPath(transitHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a TransitHubResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the TransitHub Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, TransitHubResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, communityName, transitHubName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a TransitHubResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the TransitHub Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, TransitHubResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, communityName, transitHubName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, TransitHubResourcePatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs/", false); + uri.AppendPath(transitHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, TransitHubResourcePatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs/", false); + uri.AppendPath(transitHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a TransitHubResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the TransitHub Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, TransitHubResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, communityName, transitHubName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a TransitHubResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the TransitHub Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, TransitHubResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, communityName, transitHubName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string communityName, string transitHubName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs/", false); + uri.AppendPath(transitHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string communityName, string transitHubName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs/", false); + uri.AppendPath(transitHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a TransitHubResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, communityName, transitHubName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a TransitHubResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string communityName, string transitHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, communityName, transitHubName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByCommunityResourceRequestUri(string subscriptionId, string resourceGroupName, string communityName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByCommunityResourceRequest(string subscriptionId, string resourceGroupName, string communityName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List TransitHubResource resources by CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCommunityResourceAsync(string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListByCommunityResourceRequest(subscriptionId, resourceGroupName, communityName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TransitHubResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = TransitHubResourceListResult.DeserializeTransitHubResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List TransitHubResource resources by CommunityResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCommunityResource(string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListByCommunityResourceRequest(subscriptionId, resourceGroupName, communityName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TransitHubResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = TransitHubResourceListResult.DeserializeTransitHubResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId, string communityName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId, string communityName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/communities/", false); + uri.AppendPath(communityName, true); + uri.AppendPath("/transitHubs", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List TransitHubResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, communityName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TransitHubResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = TransitHubResourceListResult.DeserializeTransitHubResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List TransitHubResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, communityName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TransitHubResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = TransitHubResourceListResult.DeserializeTransitHubResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByCommunityResourceNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string communityName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByCommunityResourceNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string communityName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List TransitHubResource resources by CommunityResource. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCommunityResourceNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListByCommunityResourceNextPageRequest(nextLink, subscriptionId, resourceGroupName, communityName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TransitHubResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = TransitHubResourceListResult.DeserializeTransitHubResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List TransitHubResource resources by CommunityResource. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCommunityResourceNextPage(string nextLink, string subscriptionId, string resourceGroupName, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListByCommunityResourceNextPageRequest(nextLink, subscriptionId, resourceGroupName, communityName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TransitHubResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = TransitHubResourceListResult.DeserializeTransitHubResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId, string communityName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId, string communityName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List TransitHubResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, communityName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TransitHubResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = TransitHubResourceListResult.DeserializeTransitHubResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List TransitHubResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the communityResource Resource. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, string communityName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(communityName, nameof(communityName)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, communityName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TransitHubResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = TransitHubResourceListResult.DeserializeTransitHubResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/VirtualEnclaveRestOperations.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/VirtualEnclaveRestOperations.cs new file mode 100644 index 000000000000..9b963a469ba5 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/VirtualEnclaveRestOperations.cs @@ -0,0 +1,911 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal partial class VirtualEnclaveRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of VirtualEnclaveRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public VirtualEnclaveRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2025-05-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, virtualEnclaveName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveResourceData.DeserializeEnclaveResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((EnclaveResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, virtualEnclaveName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveResourceData.DeserializeEnclaveResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((EnclaveResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, EnclaveResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, EnclaveResourceData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, EnclaveResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string virtualEnclaveName, EnclaveResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, EnclaveResourcePatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, EnclaveResourcePatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, EnclaveResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string virtualEnclaveName, EnclaveResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, virtualEnclaveName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, virtualEnclaveName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveResource resources by resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveResourceListResult.DeserializeEnclaveResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveResource resources by resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveResourceListResult.DeserializeEnclaveResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveResourceListResult.DeserializeEnclaveResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveResourceListResult.DeserializeEnclaveResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateHandleApprovalCreationRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, ApprovalCallbackRequest body) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/handleApprovalCreation", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateHandleApprovalCreationRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, ApprovalCallbackRequest body) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/handleApprovalCreation", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(body, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Callback that triggers on approval state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task HandleApprovalCreationAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalCreationRequest(subscriptionId, resourceGroupName, virtualEnclaveName, body); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Callback that triggers on approval state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response HandleApprovalCreation(string subscriptionId, string resourceGroupName, string virtualEnclaveName, ApprovalCallbackRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalCreationRequest(subscriptionId, resourceGroupName, virtualEnclaveName, body); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateHandleApprovalDeletionRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, VirtualEnclavesApprovalDeletionCallbackRequestContent body) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/handleApprovalDeletion", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateHandleApprovalDeletionRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, VirtualEnclavesApprovalDeletionCallbackRequestContent body) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/handleApprovalDeletion", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(body, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Callback that triggers on approval deletion state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task HandleApprovalDeletionAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalDeletionRequest(subscriptionId, resourceGroupName, virtualEnclaveName, body); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Callback that triggers on approval deletion state change. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The content of the action request. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response HandleApprovalDeletion(string subscriptionId, string resourceGroupName, string virtualEnclaveName, VirtualEnclavesApprovalDeletionCallbackRequestContent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNull(body, nameof(body)); + + using var message = CreateHandleApprovalDeletionRequest(subscriptionId, resourceGroupName, virtualEnclaveName, body); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveResource resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveResourceListResult.DeserializeEnclaveResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveResource resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveResourceListResult.DeserializeEnclaveResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List EnclaveResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EnclaveResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = EnclaveResourceListResult.DeserializeEnclaveResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List EnclaveResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EnclaveResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = EnclaveResourceListResult.DeserializeEnclaveResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/WorkloadRestOperations.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/WorkloadRestOperations.cs new file mode 100644 index 000000000000..1e29e08fb2a2 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/RestOperations/WorkloadRestOperations.cs @@ -0,0 +1,779 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + internal partial class WorkloadRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of WorkloadRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public WorkloadRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2025-05-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads/", false); + uri.AppendPath(workloadName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads/", false); + uri.AppendPath(workloadName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a WorkloadResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, virtualEnclaveName, workloadName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + WorkloadResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = WorkloadResourceData.DeserializeWorkloadResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((WorkloadResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a WorkloadResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, virtualEnclaveName, workloadName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + WorkloadResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = WorkloadResourceData.DeserializeWorkloadResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((WorkloadResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, WorkloadResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads/", false); + uri.AppendPath(workloadName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, WorkloadResourceData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads/", false); + uri.AppendPath(workloadName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a WorkloadResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the workloadResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, WorkloadResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, workloadName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a WorkloadResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the workloadResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, WorkloadResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, workloadName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, WorkloadResourcePatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads/", false); + uri.AppendPath(workloadName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, WorkloadResourcePatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads/", false); + uri.AppendPath(workloadName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a WorkloadResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the workloadResource Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, WorkloadResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, workloadName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a WorkloadResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the workloadResource Resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, WorkloadResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, virtualEnclaveName, workloadName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads/", false); + uri.AppendPath(workloadName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads/", false); + uri.AppendPath(workloadName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a WorkloadResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, virtualEnclaveName, workloadName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a WorkloadResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, virtualEnclaveName, workloadName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByEnclaveResourceRequestUri(string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByEnclaveResourceRequest(string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List WorkloadResource resources by EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByEnclaveResourceAsync(string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListByEnclaveResourceRequest(subscriptionId, resourceGroupName, virtualEnclaveName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + WorkloadResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = WorkloadResourceListResult.DeserializeWorkloadResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List WorkloadResource resources by EnclaveResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByEnclaveResource(string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListByEnclaveResourceRequest(subscriptionId, resourceGroupName, virtualEnclaveName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + WorkloadResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = WorkloadResourceListResult.DeserializeWorkloadResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId, string virtualEnclaveName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId, string virtualEnclaveName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Mission/virtualEnclaves/", false); + uri.AppendPath(virtualEnclaveName, true); + uri.AppendPath("/workloads", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List WorkloadResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, virtualEnclaveName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + WorkloadResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = WorkloadResourceListResult.DeserializeWorkloadResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List WorkloadResource resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, virtualEnclaveName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + WorkloadResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = WorkloadResourceListResult.DeserializeWorkloadResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByEnclaveResourceNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByEnclaveResourceNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string virtualEnclaveName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List WorkloadResource resources by EnclaveResource. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByEnclaveResourceNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListByEnclaveResourceNextPageRequest(nextLink, subscriptionId, resourceGroupName, virtualEnclaveName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + WorkloadResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = WorkloadResourceListResult.DeserializeWorkloadResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List WorkloadResource resources by EnclaveResource. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByEnclaveResourceNextPage(string nextLink, string subscriptionId, string resourceGroupName, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListByEnclaveResourceNextPageRequest(nextLink, subscriptionId, resourceGroupName, virtualEnclaveName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + WorkloadResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = WorkloadResourceListResult.DeserializeWorkloadResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId, string virtualEnclaveName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId, string virtualEnclaveName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List WorkloadResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, virtualEnclaveName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + WorkloadResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = WorkloadResourceListResult.DeserializeWorkloadResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List WorkloadResource resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the enclaveResource Resource. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, string virtualEnclaveName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(virtualEnclaveName, nameof(virtualEnclaveName)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, virtualEnclaveName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + WorkloadResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = WorkloadResourceListResult.DeserializeWorkloadResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResource.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResource.Serialization.cs new file mode 100644 index 000000000000..eb301c0ad007 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResource.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class TransitHubResource : IJsonModel + { + private static TransitHubResourceData s_dataDeserializationInstance; + private static TransitHubResourceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + TransitHubResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + TransitHubResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResource.cs new file mode 100644 index 000000000000..4c749df8872e --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResource.cs @@ -0,0 +1,708 @@ + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A Class representing a TransitHubResource along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetTransitHubResource method. + /// Otherwise you can get one from its parent resource using the GetTransitHubResource method. + /// + public partial class TransitHubResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The communityName. + /// The transitHubName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string communityName, string transitHubName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _transitHubResourceTransitHubClientDiagnostics; + private readonly TransitHubRestOperations _transitHubResourceTransitHubRestClient; + private readonly TransitHubResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Mission/communities/transitHubs"; + + /// Initializes a new instance of the class for mocking. + public TransitHubResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal TransitHubResource(ArmClient client, TransitHubResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal TransitHubResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _transitHubResourceTransitHubClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string transitHubResourceTransitHubApiVersion); + _transitHubResourceTransitHubRestClient = new TransitHubRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, transitHubResourceTransitHubApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual TransitHubResourceData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.Get"); + scope.Start(); + try + { + var response = await _transitHubResourceTransitHubRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TransitHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.Get"); + scope.Start(); + try + { + var response = _transitHubResourceTransitHubRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TransitHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.Delete"); + scope.Start(); + try + { + var response = await _transitHubResourceTransitHubRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(_transitHubResourceTransitHubClientDiagnostics, Pipeline, _transitHubResourceTransitHubRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.Delete"); + scope.Start(); + try + { + var response = _transitHubResourceTransitHubRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new VirtualEnclavesArmOperation(_transitHubResourceTransitHubClientDiagnostics, Pipeline, _transitHubResourceTransitHubRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, TransitHubResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.Update"); + scope.Start(); + try + { + var response = await _transitHubResourceTransitHubRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new TransitHubResourceOperationSource(Client), _transitHubResourceTransitHubClientDiagnostics, Pipeline, _transitHubResourceTransitHubRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, TransitHubResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.Update"); + scope.Start(); + try + { + var response = _transitHubResourceTransitHubRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new TransitHubResourceOperationSource(Client), _transitHubResourceTransitHubClientDiagnostics, Pipeline, _transitHubResourceTransitHubRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _transitHubResourceTransitHubRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new TransitHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new TransitHubResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _transitHubResourceTransitHubRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new TransitHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new TransitHubResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _transitHubResourceTransitHubRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new TransitHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new TransitHubResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _transitHubResourceTransitHubRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new TransitHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new TransitHubResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _transitHubResourceTransitHubRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new TransitHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new TransitHubResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _transitHubResourceTransitHubRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new TransitHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new TransitHubResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceCollection.cs new file mode 100644 index 000000000000..2c83bab97109 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceCollection.cs @@ -0,0 +1,493 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetTransitHubResources method from an instance of . + /// + public partial class TransitHubResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _transitHubResourceTransitHubClientDiagnostics; + private readonly TransitHubRestOperations _transitHubResourceTransitHubRestClient; + + /// Initializes a new instance of the class for mocking. + protected TransitHubResourceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal TransitHubResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _transitHubResourceTransitHubClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", TransitHubResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(TransitHubResource.ResourceType, out string transitHubResourceTransitHubApiVersion); + _transitHubResourceTransitHubRestClient = new TransitHubRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, transitHubResourceTransitHubApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CommunityResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CommunityResource.ResourceType), nameof(id)); + } + + /// + /// Create a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the TransitHub Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string transitHubName, TransitHubResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _transitHubResourceTransitHubRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, transitHubName, data, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new TransitHubResourceOperationSource(Client), _transitHubResourceTransitHubClientDiagnostics, Pipeline, _transitHubResourceTransitHubRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, transitHubName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the TransitHub Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string transitHubName, TransitHubResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _transitHubResourceTransitHubRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, transitHubName, data, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new TransitHubResourceOperationSource(Client), _transitHubResourceTransitHubClientDiagnostics, Pipeline, _transitHubResourceTransitHubRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, transitHubName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string transitHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResourceCollection.Get"); + scope.Start(); + try + { + var response = await _transitHubResourceTransitHubRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, transitHubName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TransitHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TransitHubResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string transitHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResourceCollection.Get"); + scope.Start(); + try + { + var response = _transitHubResourceTransitHubRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, transitHubName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TransitHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List TransitHubResource resources by CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs + /// + /// + /// Operation Id + /// TransitHubResource_ListByCommunityResource + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _transitHubResourceTransitHubRestClient.CreateListByCommunityResourceRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _transitHubResourceTransitHubRestClient.CreateListByCommunityResourceNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new TransitHubResource(Client, TransitHubResourceData.DeserializeTransitHubResourceData(e)), _transitHubResourceTransitHubClientDiagnostics, Pipeline, "TransitHubResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List TransitHubResource resources by CommunityResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs + /// + /// + /// Operation Id + /// TransitHubResource_ListByCommunityResource + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _transitHubResourceTransitHubRestClient.CreateListByCommunityResourceRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _transitHubResourceTransitHubRestClient.CreateListByCommunityResourceNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TransitHubResource(Client, TransitHubResourceData.DeserializeTransitHubResourceData(e)), _transitHubResourceTransitHubClientDiagnostics, Pipeline, "TransitHubResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string transitHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _transitHubResourceTransitHubRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, transitHubName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string transitHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResourceCollection.Exists"); + scope.Start(); + try + { + var response = _transitHubResourceTransitHubRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, transitHubName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string transitHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _transitHubResourceTransitHubRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, transitHubName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new TransitHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName} + /// + /// + /// Operation Id + /// TransitHubResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the TransitHub Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string transitHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(transitHubName, nameof(transitHubName)); + + using var scope = _transitHubResourceTransitHubClientDiagnostics.CreateScope("TransitHubResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _transitHubResourceTransitHubRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, transitHubName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new TransitHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceData.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceData.Serialization.cs new file mode 100644 index 000000000000..103b482ba736 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceData.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class TransitHubResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitHubResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + TransitHubResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TransitHubResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTransitHubResourceData(document.RootElement, options); + } + + internal static TransitHubResourceData DeserializeTransitHubResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TransitHubProperties properties = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = TransitHubProperties.DeserializeTransitHubProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TransitHubResourceData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(TransitHubResourceData)} does not support writing '{options.Format}' format."); + } + } + + TransitHubResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTransitHubResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TransitHubResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceData.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceData.cs new file mode 100644 index 000000000000..a6c2f2eb64aa --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/TransitHubResourceData.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing the TransitHubResource data model. + /// TransitHub Model Resource + /// + public partial class TransitHubResourceData : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + public TransitHubResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal TransitHubResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, TransitHubProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TransitHubResourceData() + { + } + + /// The resource-specific properties for this resource. + public TransitHubProperties Properties { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResource.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResource.Serialization.cs new file mode 100644 index 000000000000..8b732b310a1b --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResource.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class WorkloadResource : IJsonModel + { + private static WorkloadResourceData s_dataDeserializationInstance; + private static WorkloadResourceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + WorkloadResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + WorkloadResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerVirtualEnclavesContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResource.cs new file mode 100644 index 000000000000..1722ff3077f1 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResource.cs @@ -0,0 +1,707 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A Class representing a WorkloadResource along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetWorkloadResource method. + /// Otherwise you can get one from its parent resource using the GetWorkloadResource method. + /// + public partial class WorkloadResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The virtualEnclaveName. + /// The workloadName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string virtualEnclaveName, string workloadName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _workloadResourceWorkloadClientDiagnostics; + private readonly WorkloadRestOperations _workloadResourceWorkloadRestClient; + private readonly WorkloadResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Mission/virtualEnclaves/workloads"; + + /// Initializes a new instance of the class for mocking. + public WorkloadResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal WorkloadResource(ArmClient client, WorkloadResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal WorkloadResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _workloadResourceWorkloadClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string workloadResourceWorkloadApiVersion); + _workloadResourceWorkloadRestClient = new WorkloadRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, workloadResourceWorkloadApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual WorkloadResourceData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.Get"); + scope.Start(); + try + { + var response = await _workloadResourceWorkloadRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new WorkloadResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.Get"); + scope.Start(); + try + { + var response = _workloadResourceWorkloadRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new WorkloadResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.Delete"); + scope.Start(); + try + { + var response = await _workloadResourceWorkloadRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(_workloadResourceWorkloadClientDiagnostics, Pipeline, _workloadResourceWorkloadRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Delete + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.Delete"); + scope.Start(); + try + { + var response = _workloadResourceWorkloadRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new VirtualEnclavesArmOperation(_workloadResourceWorkloadClientDiagnostics, Pipeline, _workloadResourceWorkloadRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, WorkloadResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.Update"); + scope.Start(); + try + { + var response = await _workloadResourceWorkloadRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new WorkloadResourceOperationSource(Client), _workloadResourceWorkloadClientDiagnostics, Pipeline, _workloadResourceWorkloadRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Update + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, WorkloadResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.Update"); + scope.Start(); + try + { + var response = _workloadResourceWorkloadRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new WorkloadResourceOperationSource(Client), _workloadResourceWorkloadClientDiagnostics, Pipeline, _workloadResourceWorkloadRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _workloadResourceWorkloadRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new WorkloadResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new WorkloadResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _workloadResourceWorkloadRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new WorkloadResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new WorkloadResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _workloadResourceWorkloadRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new WorkloadResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new WorkloadResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _workloadResourceWorkloadRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new WorkloadResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new WorkloadResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _workloadResourceWorkloadRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new WorkloadResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new WorkloadResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _workloadResourceWorkloadRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new WorkloadResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new WorkloadResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceCollection.cs new file mode 100644 index 000000000000..28a1e515aa12 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceCollection.cs @@ -0,0 +1,493 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetWorkloadResources method from an instance of . + /// + public partial class WorkloadResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _workloadResourceWorkloadClientDiagnostics; + private readonly WorkloadRestOperations _workloadResourceWorkloadRestClient; + + /// Initializes a new instance of the class for mocking. + protected WorkloadResourceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal WorkloadResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _workloadResourceWorkloadClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.VirtualEnclaves", WorkloadResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(WorkloadResource.ResourceType, out string workloadResourceWorkloadApiVersion); + _workloadResourceWorkloadRestClient = new WorkloadRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, workloadResourceWorkloadApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != EnclaveResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, EnclaveResource.ResourceType), nameof(id)); + } + + /// + /// Create a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the workloadResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string workloadName, WorkloadResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _workloadResourceWorkloadRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, workloadName, data, cancellationToken).ConfigureAwait(false); + var operation = new VirtualEnclavesArmOperation(new WorkloadResourceOperationSource(Client), _workloadResourceWorkloadClientDiagnostics, Pipeline, _workloadResourceWorkloadRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, workloadName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the workloadResource Resource. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string workloadName, WorkloadResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _workloadResourceWorkloadRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, workloadName, data, cancellationToken); + var operation = new VirtualEnclavesArmOperation(new WorkloadResourceOperationSource(Client), _workloadResourceWorkloadClientDiagnostics, Pipeline, _workloadResourceWorkloadRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, workloadName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string workloadName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResourceCollection.Get"); + scope.Start(); + try + { + var response = await _workloadResourceWorkloadRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, workloadName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new WorkloadResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a WorkloadResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string workloadName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResourceCollection.Get"); + scope.Start(); + try + { + var response = _workloadResourceWorkloadRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, workloadName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new WorkloadResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List WorkloadResource resources by EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads + /// + /// + /// Operation Id + /// WorkloadResource_ListByEnclaveResource + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _workloadResourceWorkloadRestClient.CreateListByEnclaveResourceRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _workloadResourceWorkloadRestClient.CreateListByEnclaveResourceNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new WorkloadResource(Client, WorkloadResourceData.DeserializeWorkloadResourceData(e)), _workloadResourceWorkloadClientDiagnostics, Pipeline, "WorkloadResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List WorkloadResource resources by EnclaveResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads + /// + /// + /// Operation Id + /// WorkloadResource_ListByEnclaveResource + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _workloadResourceWorkloadRestClient.CreateListByEnclaveResourceRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _workloadResourceWorkloadRestClient.CreateListByEnclaveResourceNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new WorkloadResource(Client, WorkloadResourceData.DeserializeWorkloadResourceData(e)), _workloadResourceWorkloadClientDiagnostics, Pipeline, "WorkloadResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string workloadName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _workloadResourceWorkloadRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, workloadName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string workloadName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResourceCollection.Exists"); + scope.Start(); + try + { + var response = _workloadResourceWorkloadRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, workloadName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string workloadName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _workloadResourceWorkloadRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, workloadName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new WorkloadResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName} + /// + /// + /// Operation Id + /// WorkloadResource_Get + /// + /// + /// Default Api Version + /// 2025-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the workloadResource Resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string workloadName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workloadName, nameof(workloadName)); + + using var scope = _workloadResourceWorkloadClientDiagnostics.CreateScope("WorkloadResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _workloadResourceWorkloadRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, workloadName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new WorkloadResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceData.Serialization.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceData.Serialization.cs new file mode 100644 index 000000000000..ad65b0c32df9 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceData.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + public partial class WorkloadResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkloadResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + WorkloadResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkloadResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkloadResourceData(document.RootElement, options); + } + + internal static WorkloadResourceData DeserializeWorkloadResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WorkloadProperties properties = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = WorkloadProperties.DeserializeWorkloadProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerVirtualEnclavesContext.Default); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WorkloadResourceData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerVirtualEnclavesContext.Default); + default: + throw new FormatException($"The model {nameof(WorkloadResourceData)} does not support writing '{options.Format}' format."); + } + } + + WorkloadResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWorkloadResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkloadResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceData.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceData.cs new file mode 100644 index 000000000000..70a6ca1398b0 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Generated/WorkloadResourceData.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves +{ + /// + /// A class representing the WorkloadResource data model. + /// Workload Model Resource + /// + public partial class WorkloadResourceData : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + public WorkloadResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal WorkloadResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, WorkloadProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal WorkloadResourceData() + { + } + + /// The resource-specific properties for this resource. + public WorkloadProperties Properties { get; set; } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Properties/AssemblyInfo.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..a403013a73a0 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/src/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: Azure.Core.AzureResourceProviderNamespace("VirtualEnclaves")] + +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo("Azure.ResourceManager.VirtualEnclaves.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Azure.ResourceManager.VirtualEnclaves.Tests.csproj b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Azure.ResourceManager.VirtualEnclaves.Tests.csproj new file mode 100644 index 000000000000..f7c564a4bf45 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Azure.ResourceManager.VirtualEnclaves.Tests.csproj @@ -0,0 +1,5 @@ + + + + + diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_ApprovalResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_ApprovalResource.cs new file mode 100644 index 000000000000..7fef170a40d6 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_ApprovalResource.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_ApprovalResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_ApprovalGet() + { + // Generated from example definition: 2025-05-01-preview/Approvals_Get.json + // this example is just showing the usage of "ApprovalResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApprovalResource created on azure + // for more information of creating ApprovalResource, please refer to the document of ApprovalResource + string resourceUri = "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"; + string approvalName = "TestApprovals"; + ResourceIdentifier approvalResourceId = ApprovalResource.CreateResourceIdentifier(resourceUri, approvalName); + ApprovalResource approvalResource = client.GetApprovalResource(approvalResourceId); + + // invoke the operation + ApprovalResource result = await approvalResource.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApprovalResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ApprovalDelete() + { + // Generated from example definition: 2025-05-01-preview/Approvals_Delete.json + // this example is just showing the usage of "ApprovalResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApprovalResource created on azure + // for more information of creating ApprovalResource, please refer to the document of ApprovalResource + string resourceUri = "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"; + string approvalName = "TestApprovals"; + ResourceIdentifier approvalResourceId = ApprovalResource.CreateResourceIdentifier(resourceUri, approvalName); + ApprovalResource approvalResource = client.GetApprovalResource(approvalResourceId); + + // invoke the operation + await approvalResource.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_ApprovalUpdate() + { + // Generated from example definition: 2025-05-01-preview/Approvals_Update.json + // this example is just showing the usage of "ApprovalResource_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApprovalResource created on azure + // for more information of creating ApprovalResource, please refer to the document of ApprovalResource + string resourceUri = "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"; + string approvalName = "TestApprovals"; + ResourceIdentifier approvalResourceId = ApprovalResource.CreateResourceIdentifier(resourceUri, approvalName); + ApprovalResource approvalResource = client.GetApprovalResource(approvalResourceId); + + // invoke the operation + ApprovalResourcePatch patch = new ApprovalResourcePatch + { + Properties = new ApprovalPatchProperties(new RequestMetadataUpdatableProperties("string") + { + ApprovalCallbackRoute = "approvalCallback", + ApprovalCallbackPayload = "{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}", + ApprovalStatus = ApprovalStatus.Approved, + }) + { + ParentResourceId = new ResourceIdentifier("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + GrandparentResourceId = new ResourceIdentifier("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + Approvers = {new Approver("00000000-0000-0000-0000-000000000000", DateTimeOffset.Parse("2023-03-17T20:43:17.760Z")) +{ +ActionPerformed = ActionPerformed.Approved, +}}, + TicketId = "string", + CreatedOn = DateTimeOffset.Parse("2023-03-17T20:43:17.760Z"), + StateChangedOn = DateTimeOffset.Parse("2023-03-17T20:43:17.760Z"), + }, + }; + ArmOperation lro = await approvalResource.UpdateAsync(WaitUntil.Completed, patch); + ApprovalResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApprovalResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task NotifyInitiator_ApprovalNotifyInitiator() + { + // Generated from example definition: 2025-05-01-preview/Approvals_NotifyInitiator.json + // this example is just showing the usage of "Approval_NotifyInitiator" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApprovalResource created on azure + // for more information of creating ApprovalResource, please refer to the document of ApprovalResource + string resourceUri = "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"; + string approvalName = "TestApprovals"; + ResourceIdentifier approvalResourceId = ApprovalResource.CreateResourceIdentifier(resourceUri, approvalName); + ApprovalResource approvalResource = client.GetApprovalResource(approvalResourceId); + + // invoke the operation + ApprovalActionContent content = new ApprovalActionContent(ApprovalActionRequestApprovalStatus.Approved); + ArmOperation lro = await approvalResource.NotifyInitiatorAsync(WaitUntil.Completed, content); + ApprovalActionResponse result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_ApprovalResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_ApprovalResourceCollection.cs new file mode 100644 index 000000000000..9b4dd9667819 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_ApprovalResourceCollection.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_ApprovalResourceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_ApprovalCreateOrUpdate() + { + // Generated from example definition: 2025-05-01-preview/Approvals_CreateOrUpdate.json + // this example is just showing the usage of "ApprovalResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ApprovalResource + string resourceUri = "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"; + ApprovalResourceCollection collection = client.GetApprovalResources(new ResourceIdentifier(resourceUri)); + + // invoke the operation + string approvalName = "TestApprovals"; + ApprovalResourceData data = new ApprovalResourceData + { + Properties = new ApprovalProperties(new RequestMetadata("string") + { + ApprovalCallbackRoute = "approvalCallback", + ApprovalCallbackPayload = "{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}", + ApprovalStatus = ApprovalStatus.Approved, + }) + { + ParentResourceId = new ResourceIdentifier("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + GrandparentResourceId = new ResourceIdentifier("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + Approvers = {new Approver("00000000-0000-0000-0000-000000000000", DateTimeOffset.Parse("2023-03-17T20:43:17.760Z")) +{ +ActionPerformed = ActionPerformed.Approved, +}}, + TicketId = "string", + CreatedOn = DateTimeOffset.Parse("2023-03-17T20:43:17.760Z"), + StateChangedOn = DateTimeOffset.Parse("2023-03-17T20:43:17.760Z"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, approvalName, data); + ApprovalResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApprovalResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_ApprovalGet() + { + // Generated from example definition: 2025-05-01-preview/Approvals_Get.json + // this example is just showing the usage of "ApprovalResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ApprovalResource + string resourceUri = "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"; + ApprovalResourceCollection collection = client.GetApprovalResources(new ResourceIdentifier(resourceUri)); + + // invoke the operation + string approvalName = "TestApprovals"; + ApprovalResource result = await collection.GetAsync(approvalName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApprovalResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ApprovalListByParent() + { + // Generated from example definition: 2025-05-01-preview/Approvals_ListByParent.json + // this example is just showing the usage of "ApprovalResource_ListByParent" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ApprovalResource + string resourceUri = "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"; + ApprovalResourceCollection collection = client.GetApprovalResources(new ResourceIdentifier(resourceUri)); + + // invoke the operation and iterate over the result + await foreach (ApprovalResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApprovalResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_ApprovalGet() + { + // Generated from example definition: 2025-05-01-preview/Approvals_Get.json + // this example is just showing the usage of "ApprovalResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ApprovalResource + string resourceUri = "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"; + ApprovalResourceCollection collection = client.GetApprovalResources(new ResourceIdentifier(resourceUri)); + + // invoke the operation + string approvalName = "TestApprovals"; + bool result = await collection.ExistsAsync(approvalName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_ApprovalGet() + { + // Generated from example definition: 2025-05-01-preview/Approvals_Get.json + // this example is just showing the usage of "ApprovalResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ApprovalResource + string resourceUri = "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"; + ApprovalResourceCollection collection = client.GetApprovalResources(new ResourceIdentifier(resourceUri)); + + // invoke the operation + string approvalName = "TestApprovals"; + NullableResponse response = await collection.GetIfExistsAsync(approvalName); + ApprovalResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApprovalResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityEndpointResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityEndpointResource.cs new file mode 100644 index 000000000000..6b0354666875 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityEndpointResource.cs @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_CommunityEndpointResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CommunityEndpointsGet() + { + // Generated from example definition: 2025-05-01-preview/CommunityEndpoints_Get.json + // this example is just showing the usage of "CommunityEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityEndpointResource created on azure + // for more information of creating CommunityEndpointResource, please refer to the document of CommunityEndpointResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + string communityEndpointName = "TestMyCommunityEndpoint"; + ResourceIdentifier communityEndpointResourceId = CommunityEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName, communityEndpointName); + CommunityEndpointResource communityEndpointResource = client.GetCommunityEndpointResource(communityEndpointResourceId); + + // invoke the operation + CommunityEndpointResource result = await communityEndpointResource.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_CommunityEndpointsDelete() + { + // Generated from example definition: 2025-05-01-preview/CommunityEndpoints_Delete.json + // this example is just showing the usage of "CommunityEndpointResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityEndpointResource created on azure + // for more information of creating CommunityEndpointResource, please refer to the document of CommunityEndpointResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + string communityEndpointName = "TestMyCommunityEndpoint"; + ResourceIdentifier communityEndpointResourceId = CommunityEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName, communityEndpointName); + CommunityEndpointResource communityEndpointResource = client.GetCommunityEndpointResource(communityEndpointResourceId); + + // invoke the operation + await communityEndpointResource.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_CommunityEndpointsUpdate() + { + // Generated from example definition: 2025-05-01-preview/CommunityEndpoints_Update.json + // this example is just showing the usage of "CommunityEndpointResource_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityEndpointResource created on azure + // for more information of creating CommunityEndpointResource, please refer to the document of CommunityEndpointResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + string communityEndpointName = "TestMyCommunityEndpoint"; + ResourceIdentifier communityEndpointResourceId = CommunityEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName, communityEndpointName); + CommunityEndpointResource communityEndpointResource = client.GetCommunityEndpointResource(communityEndpointResourceId); + + // invoke the operation + CommunityEndpointResourcePatch patch = new CommunityEndpointResourcePatch + { + CommunityEndpointPatchRuleCollection = {new CommunityEndpointDestinationRule +{ +DestinationType = DestinationType.FQDN, +Protocols = {CommunityEndpointProtocol.TCP}, +TransitHubResourceId = new ResourceIdentifier("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), +Destination = "foo.example.com", +Ports = "443", +}}, + Tags = +{ +["sampletag"] = "samplevalue" +}, + }; + ArmOperation lro = await communityEndpointResource.UpdateAsync(WaitUntil.Completed, patch); + CommunityEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task HandleApprovalCreation_CommunityEndpointsHandleApprovalCreation() + { + // Generated from example definition: 2025-05-01-preview/CommunityEndpoints_HandleApprovalCreation.json + // this example is just showing the usage of "CommunityEndpoints_HandleApprovalCreation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityEndpointResource created on azure + // for more information of creating CommunityEndpointResource, please refer to the document of CommunityEndpointResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + string communityEndpointName = "TestMyCommunityEndpoint"; + ResourceIdentifier communityEndpointResourceId = CommunityEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName, communityEndpointName); + CommunityEndpointResource communityEndpointResource = client.GetCommunityEndpointResource(communityEndpointResourceId); + + // invoke the operation + ApprovalCallbackRequest body = new ApprovalCallbackRequest(ApprovalCallbackRequestResourceRequestAction.Create, ApprovalCallbackRequestApprovalStatus.Approved); + ArmOperation lro = await communityEndpointResource.HandleApprovalCreationAsync(WaitUntil.Completed, body); + ApprovalActionResponse result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task HandleApprovalDeletion_CommunityEndpointsHandleApprovalDeletion() + { + // Generated from example definition: 2025-05-01-preview/CommunityEndpoints_HandleApprovalDeletion.json + // this example is just showing the usage of "CommunityEndpoints_HandleApprovalDeletion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityEndpointResource created on azure + // for more information of creating CommunityEndpointResource, please refer to the document of CommunityEndpointResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + string communityEndpointName = "TestMyCommunityEndpoint"; + ResourceIdentifier communityEndpointResourceId = CommunityEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName, communityEndpointName); + CommunityEndpointResource communityEndpointResource = client.GetCommunityEndpointResource(communityEndpointResourceId); + + // invoke the operation + VirtualEnclavesApprovalDeletionCallbackRequestContent body = new VirtualEnclavesApprovalDeletionCallbackRequestContent(VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction.Create); + ArmOperation lro = await communityEndpointResource.HandleApprovalDeletionAsync(WaitUntil.Completed, body); + ApprovalActionResponse result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityEndpointResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityEndpointResourceCollection.cs new file mode 100644 index 000000000000..d65dcfbfb13d --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityEndpointResourceCollection.cs @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_CommunityEndpointResourceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CommunityEndpointsCreateOrUpdate() + { + // Generated from example definition: 2025-05-01-preview/CommunityEndpoints_CreateOrUpdate.json + // this example is just showing the usage of "CommunityEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // get the collection of this CommunityEndpointResource + CommunityEndpointResourceCollection collection = communityResource.GetCommunityEndpointResources(); + + // invoke the operation + string communityEndpointName = "TestMyCommunityEndpoint"; + CommunityEndpointResourceData data = new CommunityEndpointResourceData(new AzureLocation("West US")) + { + Properties = new CommunityEndpointProperties(new CommunityEndpointDestinationRule[] + { +new CommunityEndpointDestinationRule +{ +DestinationType = DestinationType.FQDNTag, +Protocols = {CommunityEndpointProtocol.TCP}, +TransitHubResourceId = new ResourceIdentifier("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), +Destination = "foo.example.com", +Ports = "443", +} + }), + Tags = +{ +["sampletag"] = "samplevalue" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communityEndpointName, data); + CommunityEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CommunityEndpointsGet() + { + // Generated from example definition: 2025-05-01-preview/CommunityEndpoints_Get.json + // this example is just showing the usage of "CommunityEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // get the collection of this CommunityEndpointResource + CommunityEndpointResourceCollection collection = communityResource.GetCommunityEndpointResources(); + + // invoke the operation + string communityEndpointName = "TestMyCommunityEndpoint"; + CommunityEndpointResource result = await collection.GetAsync(communityEndpointName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_CommunityEndpointsListByCommunityResource() + { + // Generated from example definition: 2025-05-01-preview/CommunityEndpoints_ListByCommunityResource.json + // this example is just showing the usage of "CommunityEndpointResource_ListByCommunityResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // get the collection of this CommunityEndpointResource + CommunityEndpointResourceCollection collection = communityResource.GetCommunityEndpointResources(); + + // invoke the operation and iterate over the result + await foreach (CommunityEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityEndpointResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_CommunityEndpointsGet() + { + // Generated from example definition: 2025-05-01-preview/CommunityEndpoints_Get.json + // this example is just showing the usage of "CommunityEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // get the collection of this CommunityEndpointResource + CommunityEndpointResourceCollection collection = communityResource.GetCommunityEndpointResources(); + + // invoke the operation + string communityEndpointName = "TestMyCommunityEndpoint"; + bool result = await collection.ExistsAsync(communityEndpointName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_CommunityEndpointsGet() + { + // Generated from example definition: 2025-05-01-preview/CommunityEndpoints_Get.json + // this example is just showing the usage of "CommunityEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // get the collection of this CommunityEndpointResource + CommunityEndpointResourceCollection collection = communityResource.GetCommunityEndpointResources(); + + // invoke the operation + string communityEndpointName = "TestMyCommunityEndpoint"; + NullableResponse response = await collection.GetIfExistsAsync(communityEndpointName); + CommunityEndpointResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityResource.cs new file mode 100644 index 000000000000..11cf91e378aa --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityResource.cs @@ -0,0 +1,233 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_CommunityResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CommunityGet() + { + // Generated from example definition: 2025-05-01-preview/Community_Get.json + // this example is just showing the usage of "CommunityResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // invoke the operation + CommunityResource result = await communityResource.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_CommunityDelete() + { + // Generated from example definition: 2025-05-01-preview/Community_Delete.json + // this example is just showing the usage of "CommunityResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // invoke the operation + await communityResource.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_CommunityUpdate() + { + // Generated from example definition: 2025-05-01-preview/Community_Update.json + // this example is just showing the usage of "CommunityResource_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // invoke the operation + CommunityResourcePatch patch = new CommunityResourcePatch + { + Properties = new CommunityPatchProperties + { + DnsServers = { "azure.net" }, + GovernedServiceList = {new GovernedServiceItem(ServiceIdentifier.AKS) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.AppService) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.ContainerRegistry) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.CosmosDB) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.KeyVault) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.MicrosoftSql) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.Monitoring) +{ +Option = new GovernedServiceItemOption("Not Applicable"), +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.PostgreSql) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.ServiceBus) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.Storage) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.AzureFirewalls) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.Insights) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.Logic) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.PrivateDnsZones) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.DataConnectors) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}}, + CommunityRoleAssignments = {new RoleAssignmentItem("b24988ac-6180-42a0-ab88-20f7382dd24c") +{ +Principals = {new Principal("01234567-89ab-ef01-2345-0123456789ab", PrincipalType.Group), new Principal("355a6bb0-abc0-4cba-000d-12a345b678c0", PrincipalType.User)}, +}, new RoleAssignmentItem("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9") +{ +Principals = {new Principal("355a6bb0-abc0-4cba-000d-12a345b678c9", PrincipalType.User)}, +}}, + }, + Tags = +{ +["sampletag"] = "samplevalue" +}, + }; + ArmOperation lro = await communityResource.UpdateAsync(WaitUntil.Completed, patch); + CommunityResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckAddressSpaceAvailability_CommunityCheckAddressSpaceAvailability() + { + // Generated from example definition: 2025-05-01-preview/Community_PostCheckAddressSpaceAvailability.json + // this example is just showing the usage of "Community_CheckAddressSpaceAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // invoke the operation + CheckAddressSpaceAvailabilityContent content = new CheckAddressSpaceAvailabilityContent(new ResourceIdentifier("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/communities/TestMyCommunity"), new EnclaveVirtualNetworkModel + { + NetworkSize = "small", + CustomCidrRange = "10.0.0.0/24", + SubnetConfigurations = { new SubnetConfiguration("test", 26) }, + AllowSubnetCommunication = true, + }); + CheckAddressSpaceAvailabilityResponse result = await communityResource.CheckAddressSpaceAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityResourceCollection.cs new file mode 100644 index 000000000000..7b15fd4ff32f --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_CommunityResourceCollection.cs @@ -0,0 +1,319 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_CommunityResourceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CommunityCreateOrUpdate() + { + // Generated from example definition: 2025-05-01-preview/Community_CreateOrUpdate.json + // this example is just showing the usage of "CommunityResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CommunityResource + CommunityResourceCollection collection = resourceGroupResource.GetCommunityResources(); + + // invoke the operation + string communityName = "TestMyCommunity"; + CommunityResourceData data = new CommunityResourceData(new AzureLocation("westcentralus")) + { + Properties = new CommunityProperties + { + AddressSpace = "10.0.0.0/24", + DnsServers = { "azure.net" }, + GovernedServiceList = {new GovernedServiceItem(ServiceIdentifier.AKS) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.AppService) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.ContainerRegistry) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.CosmosDB) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.KeyVault) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.MicrosoftSql) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.Monitoring) +{ +Option = new GovernedServiceItemOption("Not Applicable"), +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.PostgreSql) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.ServiceBus) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.Storage) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.AzureFirewalls) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.Insights) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.Logic) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.PrivateDnsZones) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}, new GovernedServiceItem(ServiceIdentifier.DataConnectors) +{ +Option = GovernedServiceItemOption.Allow, +Enforcement = GovernedServiceItemEnforcement.Enabled, +PolicyAction = GovernedServiceItemPolicyAction.None, +}}, + CommunityRoleAssignments = {new RoleAssignmentItem("b24988ac-6180-42a0-ab88-20f7382dd24c") +{ +Principals = {new Principal("01234567-89ab-ef01-2345-0123456789ab", PrincipalType.Group), new Principal("355a6bb0-abc0-4cba-000d-12a345b678c0", PrincipalType.User)}, +}, new RoleAssignmentItem("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9") +{ +Principals = {new Principal("355a6bb0-abc0-4cba-000d-12a345b678c9", PrincipalType.User)}, +}}, + FirewallSku = FirewallSKU.Standard, + ApprovalSettings = new ApprovalSettings + { + EndpointCreation = ApprovalPolicy.NotRequired, + EndpointUpdate = ApprovalPolicy.Required, + EndpointDeletion = ApprovalPolicy.NotRequired, + ConnectionCreation = ApprovalPolicy.Required, + ConnectionUpdate = ApprovalPolicy.Required, + ConnectionDeletion = ApprovalPolicy.NotRequired, + EnclaveCreation = ApprovalPolicy.NotRequired, + EnclaveDeletion = ApprovalPolicy.NotRequired, + MaintenanceMode = ApprovalPolicy.NotRequired, + ServiceCatalogDeployment = ApprovalPolicy.NotRequired, + NotificationOnApprovalCreation = ApprovalPolicy.NotRequired, + NotificationOnApprovalAction = ApprovalPolicy.NotRequired, + NotificationOnApprovalDeletion = ApprovalPolicy.NotRequired, + MandatoryApprovers = { new MandatoryApprover("00000000-0000-0000-0000-000000000000") }, + MinimumApproversRequired = 0L, + }, + MaintenanceModeConfiguration = new MaintenanceModeConfigurationModel(MaintenanceModeConfigurationModelMode.Off) + { + Principals = { new Principal("355a6bb0-abc0-4cba-000d-12a345b678c9", PrincipalType.User) }, + Justification = MaintenanceModeConfigurationModelJustification.Off, + }, + }, + Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() +}, + }, + Tags = +{ +["sampletag"] = "samplevalue" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communityName, data); + CommunityResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CommunityGet() + { + // Generated from example definition: 2025-05-01-preview/Community_Get.json + // this example is just showing the usage of "CommunityResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CommunityResource + CommunityResourceCollection collection = resourceGroupResource.GetCommunityResources(); + + // invoke the operation + string communityName = "TestMyCommunity"; + CommunityResource result = await collection.GetAsync(communityName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_CommunityListByResourceGroup() + { + // Generated from example definition: 2025-05-01-preview/Community_ListByResourceGroup.json + // this example is just showing the usage of "CommunityResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CommunityResource + CommunityResourceCollection collection = resourceGroupResource.GetCommunityResources(); + + // invoke the operation and iterate over the result + await foreach (CommunityResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_CommunityGet() + { + // Generated from example definition: 2025-05-01-preview/Community_Get.json + // this example is just showing the usage of "CommunityResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CommunityResource + CommunityResourceCollection collection = resourceGroupResource.GetCommunityResources(); + + // invoke the operation + string communityName = "TestMyCommunity"; + bool result = await collection.ExistsAsync(communityName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_CommunityGet() + { + // Generated from example definition: 2025-05-01-preview/Community_Get.json + // this example is just showing the usage of "CommunityResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CommunityResource + CommunityResourceCollection collection = resourceGroupResource.GetCommunityResources(); + + // invoke the operation + string communityName = "TestMyCommunity"; + NullableResponse response = await collection.GetIfExistsAsync(communityName); + CommunityResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveConnectionResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveConnectionResource.cs new file mode 100644 index 000000000000..c855bc8413f0 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveConnectionResource.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_EnclaveConnectionResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_EnclaveConnectionGet() + { + // Generated from example definition: 2025-05-01-preview/EnclaveConnection_Get.json + // this example is just showing the usage of "EnclaveConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveConnectionResource created on azure + // for more information of creating EnclaveConnectionResource, please refer to the document of EnclaveConnectionResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string enclaveConnectionName = "TestMyEnclaveConnection"; + ResourceIdentifier enclaveConnectionResourceId = EnclaveConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, enclaveConnectionName); + EnclaveConnectionResource enclaveConnectionResource = client.GetEnclaveConnectionResource(enclaveConnectionResourceId); + + // invoke the operation + EnclaveConnectionResource result = await enclaveConnectionResource.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveConnectionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_EnclaveConnectionDelete() + { + // Generated from example definition: 2025-05-01-preview/EnclaveConnection_Delete.json + // this example is just showing the usage of "EnclaveConnectionResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveConnectionResource created on azure + // for more information of creating EnclaveConnectionResource, please refer to the document of EnclaveConnectionResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string enclaveConnectionName = "TestMyEnclaveConnection"; + ResourceIdentifier enclaveConnectionResourceId = EnclaveConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, enclaveConnectionName); + EnclaveConnectionResource enclaveConnectionResource = client.GetEnclaveConnectionResource(enclaveConnectionResourceId); + + // invoke the operation + await enclaveConnectionResource.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_EnclaveConnectionUpdate() + { + // Generated from example definition: 2025-05-01-preview/EnclaveConnection_Update.json + // this example is just showing the usage of "EnclaveConnectionResource_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveConnectionResource created on azure + // for more information of creating EnclaveConnectionResource, please refer to the document of EnclaveConnectionResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string enclaveConnectionName = "TestMyEnclaveConnection"; + ResourceIdentifier enclaveConnectionResourceId = EnclaveConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, enclaveConnectionName); + EnclaveConnectionResource enclaveConnectionResource = client.GetEnclaveConnectionResource(enclaveConnectionResourceId); + + // invoke the operation + EnclaveConnectionResourcePatch patch = new EnclaveConnectionResourcePatch + { + EnclaveConnectionPatchSourceCidr = "10.0.0.0/24", + Tags = +{ +["sampletag"] = "samplevalue" +}, + }; + ArmOperation lro = await enclaveConnectionResource.UpdateAsync(WaitUntil.Completed, patch); + EnclaveConnectionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveConnectionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task HandleApprovalCreation_EnclaveConnectionHandleApprovalCreation() + { + // Generated from example definition: 2025-05-01-preview/EnclaveConnection_HandleApprovalCreation.json + // this example is just showing the usage of "EnclaveConnection_HandleApprovalCreation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveConnectionResource created on azure + // for more information of creating EnclaveConnectionResource, please refer to the document of EnclaveConnectionResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string enclaveConnectionName = "TestMyEnclaveConnection"; + ResourceIdentifier enclaveConnectionResourceId = EnclaveConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, enclaveConnectionName); + EnclaveConnectionResource enclaveConnectionResource = client.GetEnclaveConnectionResource(enclaveConnectionResourceId); + + // invoke the operation + ApprovalCallbackRequest body = new ApprovalCallbackRequest(ApprovalCallbackRequestResourceRequestAction.Create, ApprovalCallbackRequestApprovalStatus.Approved) + { + ApprovalCallbackPayload = "{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}", + }; + ArmOperation lro = await enclaveConnectionResource.HandleApprovalCreationAsync(WaitUntil.Completed, body); + ApprovalActionResponse result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task HandleApprovalDeletion_EnclaveConnectionHandleApprovalDeletion() + { + // Generated from example definition: 2025-05-01-preview/EnclaveConnection_HandleApprovalDeletion.json + // this example is just showing the usage of "EnclaveConnection_HandleApprovalDeletion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveConnectionResource created on azure + // for more information of creating EnclaveConnectionResource, please refer to the document of EnclaveConnectionResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string enclaveConnectionName = "TestMyEnclaveConnection"; + ResourceIdentifier enclaveConnectionResourceId = EnclaveConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, enclaveConnectionName); + EnclaveConnectionResource enclaveConnectionResource = client.GetEnclaveConnectionResource(enclaveConnectionResourceId); + + // invoke the operation + VirtualEnclavesApprovalDeletionCallbackRequestContent body = new VirtualEnclavesApprovalDeletionCallbackRequestContent(VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction.Create); + ArmOperation lro = await enclaveConnectionResource.HandleApprovalDeletionAsync(WaitUntil.Completed, body); + ApprovalActionResponse result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveConnectionResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveConnectionResourceCollection.cs new file mode 100644 index 000000000000..8584c3db2b29 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveConnectionResourceCollection.cs @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_EnclaveConnectionResourceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_EnclaveConnectionCreateOrUpdate() + { + // Generated from example definition: 2025-05-01-preview/EnclaveConnection_CreateOrUpdate.json + // this example is just showing the usage of "EnclaveConnectionResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this EnclaveConnectionResource + EnclaveConnectionResourceCollection collection = resourceGroupResource.GetEnclaveConnectionResources(); + + // invoke the operation + string enclaveConnectionName = "TestMyEnclaveConnection"; + EnclaveConnectionResourceData data = new EnclaveConnectionResourceData(new AzureLocation("West US")) + { + Properties = new EnclaveConnectionProperties(new ResourceIdentifier("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), new ResourceIdentifier("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), new ResourceIdentifier("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint")) + { + SourceCidr = "10.0.0.0/24", + }, + Tags = +{ +["sampletag"] = "samplevalue" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, enclaveConnectionName, data); + EnclaveConnectionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveConnectionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_EnclaveConnectionGet() + { + // Generated from example definition: 2025-05-01-preview/EnclaveConnection_Get.json + // this example is just showing the usage of "EnclaveConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this EnclaveConnectionResource + EnclaveConnectionResourceCollection collection = resourceGroupResource.GetEnclaveConnectionResources(); + + // invoke the operation + string enclaveConnectionName = "TestMyEnclaveConnection"; + EnclaveConnectionResource result = await collection.GetAsync(enclaveConnectionName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveConnectionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_EnclaveConnectionListByResourceGroup() + { + // Generated from example definition: 2025-05-01-preview/EnclaveConnection_ListByResourceGroup.json + // this example is just showing the usage of "EnclaveConnectionResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this EnclaveConnectionResource + EnclaveConnectionResourceCollection collection = resourceGroupResource.GetEnclaveConnectionResources(); + + // invoke the operation and iterate over the result + await foreach (EnclaveConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveConnectionResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_EnclaveConnectionGet() + { + // Generated from example definition: 2025-05-01-preview/EnclaveConnection_Get.json + // this example is just showing the usage of "EnclaveConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this EnclaveConnectionResource + EnclaveConnectionResourceCollection collection = resourceGroupResource.GetEnclaveConnectionResources(); + + // invoke the operation + string enclaveConnectionName = "TestMyEnclaveConnection"; + bool result = await collection.ExistsAsync(enclaveConnectionName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_EnclaveConnectionGet() + { + // Generated from example definition: 2025-05-01-preview/EnclaveConnection_Get.json + // this example is just showing the usage of "EnclaveConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this EnclaveConnectionResource + EnclaveConnectionResourceCollection collection = resourceGroupResource.GetEnclaveConnectionResources(); + + // invoke the operation + string enclaveConnectionName = "TestMyEnclaveConnection"; + NullableResponse response = await collection.GetIfExistsAsync(enclaveConnectionName); + EnclaveConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveConnectionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveEndpointResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveEndpointResource.cs new file mode 100644 index 000000000000..47ca6e1b8826 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveEndpointResource.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_EnclaveEndpointResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_EnclaveEndpointsGet() + { + // Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_Get.json + // this example is just showing the usage of "EnclaveEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveEndpointResource created on azure + // for more information of creating EnclaveEndpointResource, please refer to the document of EnclaveEndpointResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + string enclaveEndpointName = "TestMyEnclaveEndpoint"; + ResourceIdentifier enclaveEndpointResourceId = EnclaveEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName); + EnclaveEndpointResource enclaveEndpointResource = client.GetEnclaveEndpointResource(enclaveEndpointResourceId); + + // invoke the operation + EnclaveEndpointResource result = await enclaveEndpointResource.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_EnclaveEndpointsDelete() + { + // Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_Delete.json + // this example is just showing the usage of "EnclaveEndpointResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveEndpointResource created on azure + // for more information of creating EnclaveEndpointResource, please refer to the document of EnclaveEndpointResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + string enclaveEndpointName = "TestMyEnclaveEndpoint"; + ResourceIdentifier enclaveEndpointResourceId = EnclaveEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName); + EnclaveEndpointResource enclaveEndpointResource = client.GetEnclaveEndpointResource(enclaveEndpointResourceId); + + // invoke the operation + await enclaveEndpointResource.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_EnclaveEndpointsUpdate() + { + // Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_Update.json + // this example is just showing the usage of "EnclaveEndpointResource_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveEndpointResource created on azure + // for more information of creating EnclaveEndpointResource, please refer to the document of EnclaveEndpointResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + string enclaveEndpointName = "TestMyEnclaveEndpoint"; + ResourceIdentifier enclaveEndpointResourceId = EnclaveEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName); + EnclaveEndpointResource enclaveEndpointResource = client.GetEnclaveEndpointResource(enclaveEndpointResourceId); + + // invoke the operation + EnclaveEndpointResourcePatch patch = new EnclaveEndpointResourcePatch + { + EnclaveEndpointPatchRuleCollection = {new EnclaveEndpointDestinationRule +{ +Protocols = {EnclaveEndpointProtocol.TCP}, +EndpointRuleName = "54CEECEF-2C30-488E-946F-D20F414D99BA", +Destination = "10.0.0.0/24", +Ports = "443", +}}, + Tags = +{ +["sampletag"] = "samplevalue" +}, + }; + ArmOperation lro = await enclaveEndpointResource.UpdateAsync(WaitUntil.Completed, patch); + EnclaveEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task HandleApprovalCreation_EnclaveEndpointsHandleApprovalCreation() + { + // Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_HandleApprovalCreation.json + // this example is just showing the usage of "EnclaveEndpoints_HandleApprovalCreation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveEndpointResource created on azure + // for more information of creating EnclaveEndpointResource, please refer to the document of EnclaveEndpointResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + string enclaveEndpointName = "TestMyEnclaveEndpoint"; + ResourceIdentifier enclaveEndpointResourceId = EnclaveEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName); + EnclaveEndpointResource enclaveEndpointResource = client.GetEnclaveEndpointResource(enclaveEndpointResourceId); + + // invoke the operation + ApprovalCallbackRequest body = new ApprovalCallbackRequest(ApprovalCallbackRequestResourceRequestAction.Create, ApprovalCallbackRequestApprovalStatus.Approved); + ArmOperation lro = await enclaveEndpointResource.HandleApprovalCreationAsync(WaitUntil.Completed, body); + ApprovalActionResponse result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task HandleApprovalDeletion_EnclaveEndpointsHandleApprovalDeletion() + { + // Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_HandleApprovalDeletion.json + // this example is just showing the usage of "EnclaveEndpoints_HandleApprovalDeletion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveEndpointResource created on azure + // for more information of creating EnclaveEndpointResource, please refer to the document of EnclaveEndpointResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + string enclaveEndpointName = "TestMyEnclaveEndpoint"; + ResourceIdentifier enclaveEndpointResourceId = EnclaveEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName, enclaveEndpointName); + EnclaveEndpointResource enclaveEndpointResource = client.GetEnclaveEndpointResource(enclaveEndpointResourceId); + + // invoke the operation + VirtualEnclavesApprovalDeletionCallbackRequestContent body = new VirtualEnclavesApprovalDeletionCallbackRequestContent(VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction.Create); + ArmOperation lro = await enclaveEndpointResource.HandleApprovalDeletionAsync(WaitUntil.Completed, body); + ApprovalActionResponse result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveEndpointResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveEndpointResourceCollection.cs new file mode 100644 index 000000000000..42c896de24b5 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveEndpointResourceCollection.cs @@ -0,0 +1,213 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_EnclaveEndpointResourceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_EnclaveEndpointsCreateOrUpdate() + { + // Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_CreateOrUpdate.json + // this example is just showing the usage of "EnclaveEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // get the collection of this EnclaveEndpointResource + EnclaveEndpointResourceCollection collection = enclaveResource.GetEnclaveEndpointResources(); + + // invoke the operation + string enclaveEndpointName = "TestMyEnclaveEndpoint"; + EnclaveEndpointResourceData data = new EnclaveEndpointResourceData(new AzureLocation("West US")) + { + Properties = new EnclaveEndpointProperties(new EnclaveEndpointDestinationRule[] + { +new EnclaveEndpointDestinationRule +{ +Protocols = {EnclaveEndpointProtocol.TCP}, +EndpointRuleName = "54CEECEF-2C30-488E-946F-D20F414D99BA", +Destination = "10.0.0.0/24", +Ports = "443", +} + }), + Tags = +{ +["sampletag"] = "samplevalue" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, enclaveEndpointName, data); + EnclaveEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_EnclaveEndpointsGet() + { + // Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_Get.json + // this example is just showing the usage of "EnclaveEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // get the collection of this EnclaveEndpointResource + EnclaveEndpointResourceCollection collection = enclaveResource.GetEnclaveEndpointResources(); + + // invoke the operation + string enclaveEndpointName = "TestMyEnclaveEndpoint"; + EnclaveEndpointResource result = await collection.GetAsync(enclaveEndpointName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_EnclaveEndpointsListByEnclaveResource() + { + // Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_ListByEnclaveResource.json + // this example is just showing the usage of "EnclaveEndpointResource_ListByEnclaveResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // get the collection of this EnclaveEndpointResource + EnclaveEndpointResourceCollection collection = enclaveResource.GetEnclaveEndpointResources(); + + // invoke the operation and iterate over the result + await foreach (EnclaveEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveEndpointResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_EnclaveEndpointsGet() + { + // Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_Get.json + // this example is just showing the usage of "EnclaveEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // get the collection of this EnclaveEndpointResource + EnclaveEndpointResourceCollection collection = enclaveResource.GetEnclaveEndpointResources(); + + // invoke the operation + string enclaveEndpointName = "TestMyEnclaveEndpoint"; + bool result = await collection.ExistsAsync(enclaveEndpointName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_EnclaveEndpointsGet() + { + // Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_Get.json + // this example is just showing the usage of "EnclaveEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // get the collection of this EnclaveEndpointResource + EnclaveEndpointResourceCollection collection = enclaveResource.GetEnclaveEndpointResources(); + + // invoke the operation + string enclaveEndpointName = "TestMyEnclaveEndpoint"; + NullableResponse response = await collection.GetIfExistsAsync(enclaveEndpointName); + EnclaveEndpointResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveResource.cs new file mode 100644 index 000000000000..7c60743081cc --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveResource.cs @@ -0,0 +1,202 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_EnclaveResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_VirtualEnclaveGet() + { + // Generated from example definition: 2025-05-01-preview/VirtualEnclave_Get.json + // this example is just showing the usage of "EnclaveResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // invoke the operation + EnclaveResource result = await enclaveResource.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_VirtualEnclaveDelete() + { + // Generated from example definition: 2025-05-01-preview/VirtualEnclave_Delete.json + // this example is just showing the usage of "EnclaveResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // invoke the operation + await enclaveResource.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_VirtualEnclaveUpdate() + { + // Generated from example definition: 2025-05-01-preview/VirtualEnclave_Update.json + // this example is just showing the usage of "EnclaveResource_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // invoke the operation + EnclaveResourcePatch patch = new EnclaveResourcePatch + { + Properties = new VirtualEnclavePatchProperties(new EnclaveVirtualNetworkModel + { + NetworkSize = "small", + CustomCidrRange = "10.0.0.0/24", + SubnetConfigurations = { new SubnetConfiguration("test", 26) }, + AllowSubnetCommunication = true, + }) + { + BastionEnabled = true, + EnclaveRoleAssignments = {new RoleAssignmentItem("b24988ac-6180-42a0-ab88-20f7382dd24c") +{ +Principals = {new Principal("355a6bb0-abc0-4cba-000d-12a345b678c9", PrincipalType.User), new Principal("355a6bb0-abc0-4cba-000d-12a345b678c0", PrincipalType.User)}, +}, new RoleAssignmentItem("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9") +{ +Principals = {new Principal("355a6bb0-abc0-4cba-000d-12a345b678c9", PrincipalType.User)}, +}}, + WorkloadRoleAssignments = {new RoleAssignmentItem("d73bb868-a0df-4d4d-bd69-98a00b01fccb") +{ +Principals = {new Principal("01234567-89ab-ef01-2345-0123456789ab", PrincipalType.Group)}, +}, new RoleAssignmentItem("fb879df8-f326-4884-b1cf-06f3ad86be52") +{ +Principals = {new Principal("01234567-89ab-ef01-2345-0123456789ab", PrincipalType.Group)}, +}}, + EnclaveDefaultDiagnosticDestination = DiagnosticDestination.Both, + MaintenanceModeConfiguration = new MaintenanceModeConfigurationPatchModel(MaintenanceModeConfigurationModelMode.Off) + { + Principals = { new Principal("355a6bb0-abc0-4cba-000d-12a345b678c9", PrincipalType.User) }, + Justification = MaintenanceModeConfigurationModelJustification.Off, + }, + }, + Tags = +{ +["Tag1"] = "Value1" +}, + }; + ArmOperation lro = await enclaveResource.UpdateAsync(WaitUntil.Completed, patch); + EnclaveResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task HandleApprovalCreation_VirtualEnclaveHandleApprovalCreation() + { + // Generated from example definition: 2025-05-01-preview/VirtualEnclave_HandleApprovalCreation.json + // this example is just showing the usage of "VirtualEnclave_HandleApprovalCreation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // invoke the operation + ApprovalCallbackRequest body = new ApprovalCallbackRequest(ApprovalCallbackRequestResourceRequestAction.Create, ApprovalCallbackRequestApprovalStatus.Approved) + { + ApprovalCallbackPayload = "{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}", + }; + ArmOperation lro = await enclaveResource.HandleApprovalCreationAsync(WaitUntil.Completed, body); + ApprovalActionResponse result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task HandleApprovalDeletion_VirtualEnclaveHandleApprovalDeletion() + { + // Generated from example definition: 2025-05-01-preview/VirtualEnclave_HandleApprovalDeletion.json + // this example is just showing the usage of "VirtualEnclave_HandleApprovalDeletion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // invoke the operation + VirtualEnclavesApprovalDeletionCallbackRequestContent body = new VirtualEnclavesApprovalDeletionCallbackRequestContent(VirtualEnclavesApprovalDeletionCallbackRequestContentResourceRequestAction.Create); + ArmOperation lro = await enclaveResource.HandleApprovalDeletionAsync(WaitUntil.Completed, body); + ApprovalActionResponse result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveResourceCollection.cs new file mode 100644 index 000000000000..b60ecff386fc --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_EnclaveResourceCollection.cs @@ -0,0 +1,240 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_EnclaveResourceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_VirtualEnclaveCreateOrUpdate() + { + // Generated from example definition: 2025-05-01-preview/VirtualEnclave_CreateOrUpdate.json + // this example is just showing the usage of "EnclaveResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this EnclaveResource + EnclaveResourceCollection collection = resourceGroupResource.GetEnclaveResources(); + + // invoke the operation + string virtualEnclaveName = "TestMyEnclave"; + EnclaveResourceData data = new EnclaveResourceData(new AzureLocation("westcentralus")) + { + Properties = new VirtualEnclaveProperties(new EnclaveVirtualNetworkModel + { + NetworkSize = "small", + CustomCidrRange = "10.0.0.0/24", + SubnetConfigurations = { new SubnetConfiguration("test", 26) }, + AllowSubnetCommunication = true, + }, new ResourceIdentifier("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/communities/TestMyCommunity")) + { + BastionEnabled = true, + EnclaveRoleAssignments = {new RoleAssignmentItem("b24988ac-6180-42a0-ab88-20f7382dd24c") +{ +Principals = {new Principal("355a6bb0-abc0-4cba-000d-12a345b678c9", PrincipalType.User), new Principal("355a6bb0-abc0-4cba-000d-12a345b678c0", PrincipalType.User)}, +}, new RoleAssignmentItem("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9") +{ +Principals = {new Principal("355a6bb0-abc0-4cba-000d-12a345b678c9", PrincipalType.User)}, +}}, + WorkloadRoleAssignments = {new RoleAssignmentItem("d73bb868-a0df-4d4d-bd69-98a00b01fccb") +{ +Principals = {new Principal("01234567-89ab-ef01-2345-0123456789ab", PrincipalType.Group)}, +}, new RoleAssignmentItem("fb879df8-f326-4884-b1cf-06f3ad86be52") +{ +Principals = {new Principal("01234567-89ab-ef01-2345-0123456789ab", PrincipalType.Group)}, +}}, + EnclaveDefaultSettings = new EnclaveDefaultSettingsModel + { + DiagnosticDestination = DiagnosticDestination.Both, + }, + MaintenanceModeConfiguration = new MaintenanceModeConfigurationModel(MaintenanceModeConfigurationModelMode.Off) + { + Principals = { new Principal("355a6bb0-abc0-4cba-000d-12a345b678c9", PrincipalType.User) }, + Justification = MaintenanceModeConfigurationModelJustification.Off, + }, + }, + Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() +}, + }, + Tags = +{ +["Tag1"] = "Value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualEnclaveName, data); + EnclaveResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_VirtualEnclaveGet() + { + // Generated from example definition: 2025-05-01-preview/VirtualEnclave_Get.json + // this example is just showing the usage of "EnclaveResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this EnclaveResource + EnclaveResourceCollection collection = resourceGroupResource.GetEnclaveResources(); + + // invoke the operation + string virtualEnclaveName = "TestMyEnclave"; + EnclaveResource result = await collection.GetAsync(virtualEnclaveName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_VirtualEnclaveListByResourceGroup() + { + // Generated from example definition: 2025-05-01-preview/VirtualEnclave_ListByResourceGroup.json + // this example is just showing the usage of "EnclaveResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this EnclaveResource + EnclaveResourceCollection collection = resourceGroupResource.GetEnclaveResources(); + + // invoke the operation and iterate over the result + await foreach (EnclaveResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_VirtualEnclaveGet() + { + // Generated from example definition: 2025-05-01-preview/VirtualEnclave_Get.json + // this example is just showing the usage of "EnclaveResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this EnclaveResource + EnclaveResourceCollection collection = resourceGroupResource.GetEnclaveResources(); + + // invoke the operation + string virtualEnclaveName = "TestMyEnclave"; + bool result = await collection.ExistsAsync(virtualEnclaveName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_VirtualEnclaveGet() + { + // Generated from example definition: 2025-05-01-preview/VirtualEnclave_Get.json + // this example is just showing the usage of "EnclaveResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this EnclaveResource + EnclaveResourceCollection collection = resourceGroupResource.GetEnclaveResources(); + + // invoke the operation + string virtualEnclaveName = "TestMyEnclave"; + NullableResponse response = await collection.GetIfExistsAsync(virtualEnclaveName); + EnclaveResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 000000000000..3d0798cd90b1 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,240 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetWorkloadResources_WorkloadListBySubscription() + { + // Generated from example definition: 2025-05-01-preview/Workload_ListBySubscription.json + // this example is just showing the usage of "WorkloadResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string virtualEnclaveName = "TestMyEnclave"; + await foreach (WorkloadResource item in subscriptionResource.GetWorkloadResourcesAsync(virtualEnclaveName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEnclaveResources_VirtualEnclaveListBySubscription() + { + // Generated from example definition: 2025-05-01-preview/VirtualEnclave_ListBySubscription.json + // this example is just showing the usage of "EnclaveResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (EnclaveResource item in subscriptionResource.GetEnclaveResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCommunityResources_CommunityListBySubscription() + { + // Generated from example definition: 2025-05-01-preview/Community_ListBySubscription.json + // this example is just showing the usage of "CommunityResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CommunityResource item in subscriptionResource.GetCommunityResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetTransitHubResources_TransitHubListBySubscription() + { + // Generated from example definition: 2025-05-01-preview/TransitHub_ListBySubscription.json + // this example is just showing the usage of "TransitHubResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string communityName = "TestMyCommunity"; + await foreach (TransitHubResource item in subscriptionResource.GetTransitHubResourcesAsync(communityName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TransitHubResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEnclaveConnectionResources_EnclaveConnectionListBySubscription() + { + // Generated from example definition: 2025-05-01-preview/EnclaveConnection_ListBySubscription.json + // this example is just showing the usage of "EnclaveConnectionResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (EnclaveConnectionResource item in subscriptionResource.GetEnclaveConnectionResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveConnectionResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEnclaveEndpointResources_EnclaveEndpointsListBySubscription() + { + // Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_ListBySubscription.json + // this example is just showing the usage of "EnclaveEndpointResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string virtualEnclaveName = "TestMyEnclave"; + await foreach (EnclaveEndpointResource item in subscriptionResource.GetEnclaveEndpointResourcesAsync(virtualEnclaveName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EnclaveEndpointResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCommunityEndpointResources_CommunityEndpointsListBySubscription() + { + // Generated from example definition: 2025-05-01-preview/CommunityEndpoints_ListBySubscription.json + // this example is just showing the usage of "CommunityEndpointResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "73CEECEF-2C30-488E-946F-D20F414D99BA"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string communityName = "TestMyCommunity"; + await foreach (CommunityEndpointResource item in subscriptionResource.GetCommunityEndpointResourcesAsync(communityName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityEndpointResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_TransitHubResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_TransitHubResource.cs new file mode 100644 index 000000000000..b252412284ac --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_TransitHubResource.cs @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_TransitHubResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_TransitHubGet() + { + // Generated from example definition: 2025-05-01-preview/TransitHub_Get.json + // this example is just showing the usage of "TransitHubResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TransitHubResource created on azure + // for more information of creating TransitHubResource, please refer to the document of TransitHubResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + string transitHubName = "TestThName"; + ResourceIdentifier transitHubResourceId = TransitHubResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName, transitHubName); + TransitHubResource transitHubResource = client.GetTransitHubResource(transitHubResourceId); + + // invoke the operation + TransitHubResource result = await transitHubResource.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TransitHubResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_TransitHubDelete() + { + // Generated from example definition: 2025-05-01-preview/TransitHub_Delete.json + // this example is just showing the usage of "TransitHubResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TransitHubResource created on azure + // for more information of creating TransitHubResource, please refer to the document of TransitHubResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + string transitHubName = "TestThName"; + ResourceIdentifier transitHubResourceId = TransitHubResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName, transitHubName); + TransitHubResource transitHubResource = client.GetTransitHubResource(transitHubResourceId); + + // invoke the operation + await transitHubResource.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_TransitHubUpdate() + { + // Generated from example definition: 2025-05-01-preview/TransitHub_Update.json + // this example is just showing the usage of "TransitHubResource_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TransitHubResource created on azure + // for more information of creating TransitHubResource, please refer to the document of TransitHubResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + string transitHubName = "TestThName"; + ResourceIdentifier transitHubResourceId = TransitHubResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName, transitHubName); + TransitHubResource transitHubResource = client.GetTransitHubResource(transitHubResourceId); + + // invoke the operation + TransitHubResourcePatch patch = new TransitHubResourcePatch + { + Properties = new TransitHubPatchProperties + { + State = TransitHubState.PendingApproval, + TransitOption = new TransitOption + { + Type = TransitOptionType.ExpressRoute, + Params = new TransitOptionParams + { + ScaleUnits = 1L, + }, + }, + }, + Tags = +{ +["key4278"] = "hjoxhwofxcshowbnafdrrzq" +}, + }; + ArmOperation lro = await transitHubResource.UpdateAsync(WaitUntil.Completed, patch); + TransitHubResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TransitHubResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_TransitHubResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_TransitHubResourceCollection.cs new file mode 100644 index 000000000000..c13145f93d94 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_TransitHubResourceCollection.cs @@ -0,0 +1,215 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_TransitHubResourceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_TransitHubCreateOrUpdate() + { + // Generated from example definition: 2025-05-01-preview/TransitHub_CreateOrUpdate.json + // this example is just showing the usage of "TransitHubResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // get the collection of this TransitHubResource + TransitHubResourceCollection collection = communityResource.GetTransitHubResources(); + + // invoke the operation + string transitHubName = "TestThName"; + TransitHubResourceData data = new TransitHubResourceData(new AzureLocation("westcentralus")) + { + Properties = new TransitHubProperties + { + State = TransitHubState.PendingApproval, + TransitOption = new TransitOption + { + Type = TransitOptionType.ExpressRoute, + Params = new TransitOptionParams + { + ScaleUnits = 1L, + }, + }, + }, + Tags = +{ +["Tag1"] = "Value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, transitHubName, data); + TransitHubResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TransitHubResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_TransitHubGet() + { + // Generated from example definition: 2025-05-01-preview/TransitHub_Get.json + // this example is just showing the usage of "TransitHubResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // get the collection of this TransitHubResource + TransitHubResourceCollection collection = communityResource.GetTransitHubResources(); + + // invoke the operation + string transitHubName = "TestThName"; + TransitHubResource result = await collection.GetAsync(transitHubName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TransitHubResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_TransitHubListByCommunityResource() + { + // Generated from example definition: 2025-05-01-preview/TransitHub_ListByCommunityResource.json + // this example is just showing the usage of "TransitHubResource_ListByCommunityResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // get the collection of this TransitHubResource + TransitHubResourceCollection collection = communityResource.GetTransitHubResources(); + + // invoke the operation and iterate over the result + await foreach (TransitHubResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TransitHubResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_TransitHubGet() + { + // Generated from example definition: 2025-05-01-preview/TransitHub_Get.json + // this example is just showing the usage of "TransitHubResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // get the collection of this TransitHubResource + TransitHubResourceCollection collection = communityResource.GetTransitHubResources(); + + // invoke the operation + string transitHubName = "TestThName"; + bool result = await collection.ExistsAsync(transitHubName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_TransitHubGet() + { + // Generated from example definition: 2025-05-01-preview/TransitHub_Get.json + // this example is just showing the usage of "TransitHubResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CommunityResource created on azure + // for more information of creating CommunityResource, please refer to the document of CommunityResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string communityName = "TestMyCommunity"; + ResourceIdentifier communityResourceId = CommunityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communityName); + CommunityResource communityResource = client.GetCommunityResource(communityResourceId); + + // get the collection of this TransitHubResource + TransitHubResourceCollection collection = communityResource.GetTransitHubResources(); + + // invoke the operation + string transitHubName = "TestThName"; + NullableResponse response = await collection.GetIfExistsAsync(transitHubName); + TransitHubResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TransitHubResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_WorkloadResource.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_WorkloadResource.cs new file mode 100644 index 000000000000..58de295a1eea --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_WorkloadResource.cs @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_WorkloadResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_WorkloadGet() + { + // Generated from example definition: 2025-05-01-preview/Workload_Get.json + // this example is just showing the usage of "WorkloadResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WorkloadResource created on azure + // for more information of creating WorkloadResource, please refer to the document of WorkloadResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + string workloadName = "TestMyWorkload"; + ResourceIdentifier workloadResourceId = WorkloadResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName, workloadName); + WorkloadResource workloadResource = client.GetWorkloadResource(workloadResourceId); + + // invoke the operation + WorkloadResource result = await workloadResource.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_WorkloadDelete() + { + // Generated from example definition: 2025-05-01-preview/Workload_Delete.json + // this example is just showing the usage of "WorkloadResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WorkloadResource created on azure + // for more information of creating WorkloadResource, please refer to the document of WorkloadResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + string workloadName = "TestMyWorkload"; + ResourceIdentifier workloadResourceId = WorkloadResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName, workloadName); + WorkloadResource workloadResource = client.GetWorkloadResource(workloadResourceId); + + // invoke the operation + await workloadResource.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_WorkloadUpdate() + { + // Generated from example definition: 2025-05-01-preview/Workload_Update.json + // this example is just showing the usage of "WorkloadResource_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WorkloadResource created on azure + // for more information of creating WorkloadResource, please refer to the document of WorkloadResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + string workloadName = "TestMyWorkload"; + ResourceIdentifier workloadResourceId = WorkloadResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName, workloadName); + WorkloadResource workloadResource = client.GetWorkloadResource(workloadResourceId); + + // invoke the operation + WorkloadResourcePatch patch = new WorkloadResourcePatch + { + WorkloadPatchResourceGroupCollection = { "g" }, + Tags = +{ +["key9465"] = "cylmdprdhhwpcdxpynwostvzytkryj" +}, + }; + ArmOperation lro = await workloadResource.UpdateAsync(WaitUntil.Completed, patch); + WorkloadResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_WorkloadResourceCollection.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_WorkloadResourceCollection.cs new file mode 100644 index 000000000000..5b3792007cfe --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Generated/Samples/Sample_WorkloadResourceCollection.cs @@ -0,0 +1,207 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.VirtualEnclaves.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public partial class Sample_WorkloadResourceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_WorkloadCreateOrUpdate() + { + // Generated from example definition: 2025-05-01-preview/Workload_CreateOrUpdate.json + // this example is just showing the usage of "WorkloadResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // get the collection of this WorkloadResource + WorkloadResourceCollection collection = enclaveResource.GetWorkloadResources(); + + // invoke the operation + string workloadName = "TestMyWorkload"; + WorkloadResourceData data = new WorkloadResourceData(new AzureLocation("westcentralus")) + { + Properties = new WorkloadProperties + { + ResourceGroupCollection = { }, + }, + Tags = +{ +["TestKey"] = "TestValue" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadName, data); + WorkloadResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_WorkloadGet() + { + // Generated from example definition: 2025-05-01-preview/Workload_Get.json + // this example is just showing the usage of "WorkloadResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // get the collection of this WorkloadResource + WorkloadResourceCollection collection = enclaveResource.GetWorkloadResources(); + + // invoke the operation + string workloadName = "TestMyWorkload"; + WorkloadResource result = await collection.GetAsync(workloadName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_WorkloadListByEnclaveResource() + { + // Generated from example definition: 2025-05-01-preview/Workload_ListByEnclaveResource.json + // this example is just showing the usage of "WorkloadResource_ListByEnclaveResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // get the collection of this WorkloadResource + WorkloadResourceCollection collection = enclaveResource.GetWorkloadResources(); + + // invoke the operation and iterate over the result + await foreach (WorkloadResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_WorkloadGet() + { + // Generated from example definition: 2025-05-01-preview/Workload_Get.json + // this example is just showing the usage of "WorkloadResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // get the collection of this WorkloadResource + WorkloadResourceCollection collection = enclaveResource.GetWorkloadResources(); + + // invoke the operation + string workloadName = "TestMyWorkload"; + bool result = await collection.ExistsAsync(workloadName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_WorkloadGet() + { + // Generated from example definition: 2025-05-01-preview/Workload_Get.json + // this example is just showing the usage of "WorkloadResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EnclaveResource created on azure + // for more information of creating EnclaveResource, please refer to the document of EnclaveResource + string subscriptionId = "CA1CB369-DD26-4DB2-9D43-9AFEF0F22093"; + string resourceGroupName = "rgopenapi"; + string virtualEnclaveName = "TestMyEnclave"; + ResourceIdentifier enclaveResourceId = EnclaveResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualEnclaveName); + EnclaveResource enclaveResource = client.GetEnclaveResource(enclaveResourceId); + + // get the collection of this WorkloadResource + WorkloadResourceCollection collection = enclaveResource.GetWorkloadResources(); + + // invoke the operation + string workloadName = "TestMyWorkload"; + NullableResponse response = await collection.GetIfExistsAsync(workloadName); + WorkloadResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Scenario/CommunityScenarioTests.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Scenario/CommunityScenarioTests.cs new file mode 100644 index 000000000000..0a46bdb0283e --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/Scenario/CommunityScenarioTests.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.VirtualEnclaves.Models; +using Azure.ResourceManager.VirtualEnclaves; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Resources.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.VirtualEnclaves.Tests.Scenario +{ + public class CommunityScenarioTests + { + [Test] + [Ignore("Only validating compilation of scenario")] + public async Task Create_CommunityWithBasicSettings() + { + // Arrange + TokenCredential cred = new DefaultAzureCredential(); + ArmClient client = new ArmClient(cred); + + string subscriptionId = "00000000-0000-0000-0000-000000000000"; // Replace with actual subscription in real test + string resourceGroupName = "TestCommunityRg"; + string communityName = "TestCommunity"; + + var communityData = new CommunityResourceData() + { + Location = "westus2", + Properties = new CommunityProperties + { + AddressSpace = "10.0.0.0/16", + FirewallSku = FirewallSKU.Standard, + PolicyOverride = CommunityPropertiesPolicyOverride.Enclave, + ApprovalSettings = new ApprovalSettings + { + EndpointCreation = ApprovalPolicy.Required, + EndpointUpdate = ApprovalPolicy.Required, + EndpointDeletion = ApprovalPolicy.Required, + ConnectionCreation = ApprovalPolicy.Required, + ConnectionUpdate = ApprovalPolicy.Required, + ConnectionDeletion = ApprovalPolicy.Required + } + }, + Tags = + { + { "Environment", "Test" }, + { "Department", "Engineering" } + } + }; + + // Add DNS servers + communityData.Properties.DnsServers.Add("168.63.129.16"); + + // Add governed service + communityData.Properties.GovernedServiceList.Add(new GovernedServiceItem(ServiceIdentifier.MicrosoftSql) + { + Option = GovernedServiceItemOption.Allow, + Enforcement = GovernedServiceItemEnforcement.Enabled + }); + + // Add role assignment + var roleAssignment = new RoleAssignmentItem("/providers/Microsoft.Authorization/roleDefinitions/8e3af657-a8ff-443c-a75c-2fe8c4bcb635"); // Owner role + roleAssignment.Principals.Add(new Principal(Guid.NewGuid().ToString(), PrincipalType.User)); // This would be an actual user ID in real test + communityData.Properties.CommunityRoleAssignments.Add(roleAssignment); + + // Get the subscription resource + SubscriptionResource subscription = client.GetSubscriptionResource(new ResourceIdentifier($"/subscriptions/{subscriptionId}")); + + // Get the resource group + var operation = await subscription.GetResourceGroups().CreateOrUpdateAsync( + WaitUntil.Completed, + resourceGroupName, + new ResourceGroupData(AzureLocation.WestUS2)); + ResourceGroupResource resourceGroup = operation.Value; + + // Act + var collection = resourceGroup.GetCommunityResources(); + var community = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communityName, communityData); + + // Assert + Assert.That(community.Value.Data.Name, Is.EqualTo(communityName)); + Assert.That(community.Value.Data.Properties.AddressSpace, Is.EqualTo("10.0.0.0/16")); + Assert.That(community.Value.Data.Properties.FirewallSku, Is.EqualTo(FirewallSKU.Standard)); + Assert.That(community.Value.Data.Properties.PolicyOverride, Is.EqualTo(CommunityPropertiesPolicyOverride.Enclave)); + Assert.That(community.Value.Data.Properties.ApprovalSettings.EndpointCreation, Is.EqualTo(ApprovalPolicy.Required)); + Assert.That(community.Value.Data.Properties.ApprovalSettings.ConnectionCreation, Is.EqualTo(ApprovalPolicy.Required)); + Assert.That(community.Value.Data.Properties.DnsServers, Has.Member("168.63.129.16")); + Assert.That(community.Value.Data.Properties.GovernedServiceList, Has.Count.EqualTo(1)); + Assert.That(community.Value.Data.Properties.CommunityRoleAssignments, Has.Count.EqualTo(1)); + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/VirtualEnclavesManagementTestBase.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/VirtualEnclavesManagementTestBase.cs new file mode 100644 index 000000000000..10683bad3f9b --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/VirtualEnclavesManagementTestBase.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.VirtualEnclaves.Tests +{ + public class VirtualEnclavesManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected VirtualEnclavesManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected VirtualEnclavesManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + } +} diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/VirtualEnclavesManagementTestEnvironment.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/VirtualEnclavesManagementTestEnvironment.cs new file mode 100644 index 000000000000..5b8b5a074a51 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tests/VirtualEnclavesManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.VirtualEnclaves.Tests +{ + public class VirtualEnclavesManagementTestEnvironment : TestEnvironment + { + } +} \ No newline at end of file diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tsp-location.yaml b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tsp-location.yaml new file mode 100644 index 000000000000..c2686d942140 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/tsp-location.yaml @@ -0,0 +1,3 @@ +directory: specification\mission\Mission.Management +commit: 4a4afb3773fa2c15ac51e3abc909bf520f686bc0 +repo: Azure/azure-rest-api-specs diff --git a/sdk/virtualenclaves/ci.mgmt.yml b/sdk/virtualenclaves/ci.mgmt.yml new file mode 100644 index 000000000000..7b073d9af30f --- /dev/null +++ b/sdk/virtualenclaves/ci.mgmt.yml @@ -0,0 +1,24 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: none + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/virtualenclaves/ci.mgmt.yml + - sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/ + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: virtualenclaves + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.VirtualEnclaves + safeName: AzureResourceManagerVirtualEnclaves From bce53c203856b4759b4689c2e45112a6c9a2eb95 Mon Sep 17 00:00:00 2001 From: jorgechav Date: Tue, 19 Aug 2025 13:15:37 -0600 Subject: [PATCH 2/6] Add CODEOWNERS entries for Virtual Enclaves service --- .github/CODEOWNERS | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 09fd6d33a97d..1a9f9edb354b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -645,10 +645,10 @@ # ServiceOwners: @omziv @anatse @raronen @ischrei @danhadari @azmonapplicationinsights # PRLabel: %Monitor - Distro -/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/ @rajkumar-rangaraj +/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/ @rajkumar-rangaraj # PRLabel: %Monitor - Distro -/sdk/monitor/Azure.Monitor.OpenTelemetry.sln @rajkumar-rangaraj +/sdk/monitor/Azure.Monitor.OpenTelemetry.sln @rajkumar-rangaraj # ServiceLabel: %Monitor - Distro # ServiceOwners: @rajkumar-rangaraj @@ -918,6 +918,12 @@ # ServiceLabel: %VideoAnalyzer # ServiceOwners: @giakas +# PRLabel: %VirtualEnclaves +/sdk/virtualenclaves/ @jchavaherrera @Azure/azure-virtual-enclaves + +# ServiceLabel: %VirtualEnclaves +# ServiceOwners: @jchavaherrera @Azure/azure-virtual-enclaves + # ServiceLabel: %Web Apps # ServiceOwners: @AzureAppServiceCLI @antcp From e880f8e545fd5a5cc9938201c12ad617dbf82693 Mon Sep 17 00:00:00 2001 From: jorgechav <54075564+jchavaherrera@users.noreply.github.com> Date: Tue, 19 Aug 2025 13:16:33 -0600 Subject: [PATCH 3/6] Update sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Azure.ResourceManager.VirtualEnclaves/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/README.md b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/README.md index 383f27c07c85..9137888fe41b 100644 --- a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/README.md +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/README.md @@ -1,6 +1,6 @@ # Microsoft Azure VirtualEnclaves management client library for .NET -**[Describe the service briefly first.]** +**Azure Virtual Enclaves provide secure, isolated execution environments within Azure, enabling organizations to run sensitive workloads with enhanced confidentiality and integrity. This SDK allows developers and administrators to manage Virtual Enclave resources, configure enclave properties, and integrate secure enclaves with other Azure services through a consistent .NET API.** This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: From 1e9afc95040af785fcff7449a6b1ad9c0230c03e Mon Sep 17 00:00:00 2001 From: jorgechav Date: Tue, 19 Aug 2025 13:24:27 -0600 Subject: [PATCH 4/6] Remove PRLabel CODEOWNERS entry for Virtual Enclaves service --- .github/CODEOWNERS | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1a9f9edb354b..7ac507611325 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -918,9 +918,6 @@ # ServiceLabel: %VideoAnalyzer # ServiceOwners: @giakas -# PRLabel: %VirtualEnclaves -/sdk/virtualenclaves/ @jchavaherrera @Azure/azure-virtual-enclaves - # ServiceLabel: %VirtualEnclaves # ServiceOwners: @jchavaherrera @Azure/azure-virtual-enclaves From 80920c5e89c39d2ee5ffe29fcee995a34fb93259 Mon Sep 17 00:00:00 2001 From: jorgechav Date: Thu, 21 Aug 2025 20:30:55 -0600 Subject: [PATCH 5/6] Added Sample --- ...urceManager.VirtualEnclaves.Samples.csproj | 18 +++- .../samples/Program.cs | 93 +++++++++++++++++++ 2 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Program.cs diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj index 9a8a60e50745..111262a356cb 100644 --- a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj @@ -1,10 +1,18 @@  + + + + Exe + net8.0 + disable + enable + + - - - + + - + - \ No newline at end of file + diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Program.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Program.cs new file mode 100644 index 000000000000..caa4334f8119 --- /dev/null +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Program.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Diagnostics; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.Identity; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.VirtualEnclaves; +using Azure.ResourceManager.VirtualEnclaves.Models; + +namespace Azure.ResourceManager.VirtualEnclaves.Samples +{ + public class Program + { + public static async Task Main(string[] args) + { + try + { + // Initialize the client with logging + var options = new ArmClientOptions(); + options.Diagnostics.IsLoggingEnabled = true; + options.Diagnostics.IsDistributedTracingEnabled = true; + + var credential = new DefaultAzureCredential(); + var client = new ArmClient(credential, default, options); + + // Get specific subscription + string subscriptionId = "1fbade44-8ae7-42be-a05b-7919a3938975"; + var subscription = await client.GetSubscriptions().GetAsync(subscriptionId); + + // Get existing resource group + string resourceGroupName = "jorgechav_rg"; + Console.WriteLine($"Getting resource group {resourceGroupName}..."); + var resourceGroup = await subscription.Value.GetResourceGroupAsync(resourceGroupName); + + // Create community configuration + var communityData = new CommunityResourceData(AzureLocation.WestUS) + { + Properties = new CommunityProperties + { + // Configure DNS servers (using same value as test) + DnsServers = { "168.63.129.16" }, + + // Configure address space with valid subnet mask between /8 and /17 + AddressSpace = "10.0.0.0/16" + }, + Tags = + { + ["purpose"] = "demo", + ["environment"] = "development" + } + }; + + // Create the community + string communityName = "jorgechav-community"; + Console.WriteLine($"Creating community {communityName}..."); + + var communities = resourceGroup.Value.GetCommunityResources(); + var operation = await communities.CreateOrUpdateAsync( + WaitUntil.Completed, + communityName, + communityData); + + var community = operation.Value; + Console.WriteLine($"Created community with ID: {community.Data.Id}"); + + // Verify address space availability + var addressSpaceCheck = new CheckAddressSpaceAvailabilityContent( + community.Id, + new EnclaveVirtualNetworkModel + { + NetworkSize = "small", + CustomCidrRange = "10.0.0.0/16", + SubnetConfigurations = { new SubnetConfiguration("default", 20) }, + AllowSubnetCommunication = true + }); + + Console.WriteLine("Checking address space availability..."); + var availabilityResponse = await community.CheckAddressSpaceAvailabilityAsync(addressSpaceCheck); + Console.WriteLine($"Address space availability check result: {availabilityResponse.Value.Value}"); + } + catch (Exception ex) + { + Console.WriteLine($"Error: {ex.Message}"); + Console.WriteLine(ex.StackTrace); + } + } + } +} From 18cccf337bccadf0db0e015ee2debf5b2b2c8869 Mon Sep 17 00:00:00 2001 From: jorgechav Date: Fri, 22 Aug 2025 09:19:32 -0600 Subject: [PATCH 6/6] Add Sample01_CreateCommunity to demonstrate community creation in Virtual Enclaves --- .../Azure.ResourceManager.VirtualEnclaves.Samples.csproj | 8 +------- .../samples/{Program.cs => Sample01_CreateCommunity.cs} | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) rename sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/{Program.cs => Sample01_CreateCommunity.cs} (97%) diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj index 111262a356cb..a0d3f65fcb44 100644 --- a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Azure.ResourceManager.VirtualEnclaves.Samples.csproj @@ -1,18 +1,12 @@  - - Exe net8.0 - disable - enable + Azure.ResourceManager.VirtualEnclaves.Samples.Sample01_CreateCommunity - - - diff --git a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Program.cs b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Sample01_CreateCommunity.cs similarity index 97% rename from sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Program.cs rename to sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Sample01_CreateCommunity.cs index caa4334f8119..e3cfdd8a0d34 100644 --- a/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Program.cs +++ b/sdk/virtualenclaves/Azure.ResourceManager.VirtualEnclaves/samples/Sample01_CreateCommunity.cs @@ -14,7 +14,7 @@ namespace Azure.ResourceManager.VirtualEnclaves.Samples { - public class Program + public class Sample01_CreateCommunity { public static async Task Main(string[] args) { @@ -56,7 +56,7 @@ public static async Task Main(string[] args) }; // Create the community - string communityName = "jorgechav-community"; + string communityName = "jorgechav-community2"; Console.WriteLine($"Creating community {communityName}..."); var communities = resourceGroup.Value.GetCommunityResources();