From 428b7bd57d03e233d032f76df65ded23b17ea493 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 12 Sep 2024 17:52:48 +0000 Subject: [PATCH] CodeGen from PR 30539 in Azure/azure-rest-api-specs Merge 5cd019e344ad38ac190c2ffec578c83fc5375c46 into 55607c6c0e191576e882db24811c0511cc5fef5e --- .../Azure.ResourceManager.IoTOperations.sln | 56 ++ .../CHANGELOG.md | 11 + .../Directory.Build.props | 6 + .../README.md | 86 ++ ...Azure.ResourceManager.IoTOperations.csproj | 10 + .../Generated/ArmIoTOperationsModelFactory.cs | 335 +++++++ ...kerAuthenticationResource.Serialization.cs | 26 + .../Generated/BrokerAuthenticationResource.cs | 348 +++++++ .../BrokerAuthenticationResourceCollection.cs | 493 ++++++++++ ...uthenticationResourceData.Serialization.cs | 191 ++++ .../BrokerAuthenticationResourceData.cs | 89 ++ ...okerAuthorizationResource.Serialization.cs | 26 + .../Generated/BrokerAuthorizationResource.cs | 348 +++++++ .../BrokerAuthorizationResourceCollection.cs | 493 ++++++++++ ...AuthorizationResourceData.Serialization.cs | 191 ++++ .../BrokerAuthorizationResourceData.cs | 89 ++ .../BrokerListenerResource.Serialization.cs | 26 + .../src/Generated/BrokerListenerResource.cs | 348 +++++++ .../BrokerListenerResourceCollection.cs | 493 ++++++++++ ...rokerListenerResourceData.Serialization.cs | 191 ++++ .../Generated/BrokerListenerResourceData.cs | 89 ++ .../Generated/BrokerResource.Serialization.cs | 26 + .../src/Generated/BrokerResource.cs | 554 +++++++++++ .../src/Generated/BrokerResourceCollection.cs | 493 ++++++++++ .../BrokerResourceData.Serialization.cs | 191 ++++ .../src/Generated/BrokerResourceData.cs | 89 ++ .../DataflowEndpointResource.Serialization.cs | 26 + .../src/Generated/DataflowEndpointResource.cs | 347 +++++++ .../DataflowEndpointResourceCollection.cs | 493 ++++++++++ ...aflowEndpointResourceData.Serialization.cs | 191 ++++ .../Generated/DataflowEndpointResourceData.cs | 89 ++ .../DataflowProfileResource.Serialization.cs | 26 + .../src/Generated/DataflowProfileResource.cs | 416 ++++++++ .../DataflowProfileResourceCollection.cs | 493 ++++++++++ ...taflowProfileResourceData.Serialization.cs | 191 ++++ .../Generated/DataflowProfileResourceData.cs | 89 ++ .../DataflowResource.Serialization.cs | 26 + .../src/Generated/DataflowResource.cs | 348 +++++++ .../Generated/DataflowResourceCollection.cs | 493 ++++++++++ .../DataflowResourceData.Serialization.cs | 191 ++++ .../src/Generated/DataflowResourceData.cs | 89 ++ .../Extensions/IoTOperationsExtensions.cs | 422 ++++++++ .../MockableIoTOperationsArmClient.cs | 133 +++ ...kableIoTOperationsResourceGroupResource.cs | 105 ++ ...ckableIoTOperationsSubscriptionResource.cs | 102 ++ .../MockableIoTOperationsTenantResource.cs | 95 ++ .../InstanceResource.Serialization.cs | 26 + .../src/Generated/InstanceResource.cs | 906 ++++++++++++++++++ .../Generated/InstanceResourceCollection.cs | 494 ++++++++++ .../InstanceResourceData.Serialization.cs | 245 +++++ .../src/Generated/InstanceResourceData.cs | 96 ++ .../src/Generated/Internal/Argument.cs | 129 +++ .../Internal/ChangeTrackingDictionary.cs | 167 ++++ .../Generated/Internal/ChangeTrackingList.cs | 153 +++ .../Internal/ModelSerializationExtensions.cs | 398 ++++++++ .../src/Generated/Internal/Optional.cs | 51 + .../Internal/Utf8JsonRequestContent.cs | 55 ++ ...erAuthenticationResourceOperationSource.cs | 38 + ...kerAuthorizationResourceOperationSource.cs | 38 + .../BrokerListenerResourceOperationSource.cs | 38 + .../BrokerResourceOperationSource.cs | 38 + ...DataflowEndpointResourceOperationSource.cs | 38 + .../DataflowProfileResourceOperationSource.cs | 38 + .../DataflowResourceOperationSource.cs | 38 + .../InstanceResourceOperationSource.cs | 38 + .../IoTOperationsArmOperation.cs | 94 ++ .../IoTOperationsArmOperationOfT.cs | 100 ++ .../src/Generated/Models/ActionType.cs | 48 + .../Models/AdrProperties.Serialization.cs | 119 +++ .../src/Generated/Models/AdrProperties.cs | 72 ++ .../Models/AdvancedSettings.Serialization.cs | 156 +++ .../src/Generated/Models/AdvancedSettings.cs | 73 ++ .../AkriInstanceProperties.Serialization.cs | 119 +++ .../Models/AkriInstanceProperties.cs | 72 ++ .../AuthorizationConfig.Serialization.cs | 151 +++ .../Generated/Models/AuthorizationConfig.cs | 70 ++ .../Models/AuthorizationRule.Serialization.cs | 162 ++++ .../src/Generated/Models/AuthorizationRule.cs | 88 ++ .../Models/BackendChain.Serialization.cs | 142 +++ .../src/Generated/Models/BackendChain.cs | 82 ++ .../BatchingConfiguration.Serialization.cs | 141 +++ .../Generated/Models/BatchingConfiguration.cs | 69 ++ .../Models/BrokerAuthenticationMethod.cs | 54 ++ ...rAuthenticationProperties.Serialization.cs | 144 +++ .../Models/BrokerAuthenticationProperties.cs | 80 ++ ...icationResourceListResult.Serialization.cs | 144 +++ .../BrokerAuthenticationResourceListResult.cs | 80 ++ ...erAuthenticatorCustomAuth.Serialization.cs | 119 +++ .../Models/BrokerAuthenticatorCustomAuth.cs | 81 ++ ...AuthenticatorMethodCustom.Serialization.cs | 171 ++++ .../Models/BrokerAuthenticatorMethodCustom.cs | 95 ++ ...kerAuthenticatorMethodSat.Serialization.cs | 129 +++ .../Models/BrokerAuthenticatorMethodSat.cs | 76 ++ ...erAuthenticatorMethodX509.Serialization.cs | 148 +++ .../Models/BrokerAuthenticatorMethodX509.cs | 70 ++ ...catorMethodX509Attributes.Serialization.cs | 138 +++ ...BrokerAuthenticatorMethodX509Attributes.cs | 82 ++ ...rokerAuthenticatorMethods.Serialization.cs | 164 ++++ .../Models/BrokerAuthenticatorMethods.cs | 91 ++ ...erAuthorizationProperties.Serialization.cs | 134 +++ .../Models/BrokerAuthorizationProperties.cs | 79 ++ ...izationResourceListResult.Serialization.cs | 144 +++ .../BrokerAuthorizationResourceListResult.cs | 80 ++ .../Models/BrokerDiagnostics.Serialization.cs | 171 ++++ .../src/Generated/Models/BrokerDiagnostics.cs | 77 ++ .../BrokerListenerProperties.Serialization.cs | 170 ++++ .../Models/BrokerListenerProperties.cs | 88 ++ ...istenerResourceListResult.Serialization.cs | 144 +++ .../BrokerListenerResourceListResult.cs | 80 ++ .../Generated/Models/BrokerMemoryProfile.cs | 57 ++ .../Models/BrokerProperties.Serialization.cs | 224 +++++ .../src/Generated/Models/BrokerProperties.cs | 101 ++ .../Generated/Models/BrokerProtocolType.cs | 51 + .../Models/BrokerResourceDefinitionMethod.cs | 54 ++ .../BrokerResourceListResult.Serialization.cs | 144 +++ .../Models/BrokerResourceListResult.cs | 80 ++ .../BrokerResourceRule.Serialization.cs | 169 ++++ .../Generated/Models/BrokerResourceRule.cs | 82 ++ .../Models/Cardinality.Serialization.cs | 127 +++ .../src/Generated/Models/Cardinality.cs | 82 ++ .../CertManagerCertOptions.Serialization.cs | 135 +++ .../Models/CertManagerCertOptions.cs | 89 ++ ...ertManagerCertificateSpec.Serialization.cs | 189 ++++ .../Models/CertManagerCertificateSpec.cs | 95 ++ .../Generated/Models/CertManagerIssuerKind.cs | 51 + .../CertManagerIssuerRef.Serialization.cs | 135 +++ .../Generated/Models/CertManagerIssuerRef.cs | 88 ++ .../CertManagerPrivateKey.Serialization.cs | 127 +++ .../Generated/Models/CertManagerPrivateKey.cs | 78 ++ .../Models/ClientConfig.Serialization.cs | 208 ++++ .../src/Generated/Models/ClientConfig.cs | 85 ++ .../Models/CloudEventAttributeType.cs | 51 + .../Models/Components.Serialization.cs | 192 ++++ .../src/Generated/Models/Components.cs | 130 +++ ...nnectorInstanceProperties.Serialization.cs | 119 +++ .../Models/ConnectorInstanceProperties.cs | 72 ++ .../Models/DataExplorerAuthMethod.cs | 51 + .../Models/DataLakeStorageAuthMethod.cs | 54 ++ ...ltInTransformationDataset.Serialization.cs | 176 ++++ .../DataflowBuiltInTransformationDataset.cs | 95 ++ ...iltInTransformationFilter.Serialization.cs | 163 ++++ .../DataflowBuiltInTransformationFilter.cs | 91 ++ ...wBuiltInTransformationMap.Serialization.cs | 180 ++++ .../DataflowBuiltInTransformationMap.cs | 95 ++ ...tInTransformationSettings.Serialization.cs | 218 +++++ .../DataflowBuiltInTransformationSettings.cs | 84 ++ ...tinationOperationSettings.Serialization.cs | 127 +++ .../DataflowDestinationOperationSettings.cs | 82 ++ ...AuthenticationAccessToken.Serialization.cs | 119 +++ ...taflowEndpointAuthenticationAccessToken.cs | 75 ++ ...ndpointAuthenticationSasl.Serialization.cs | 127 +++ .../DataflowEndpointAuthenticationSasl.cs | 81 ++ .../DataflowEndpointAuthenticationSaslType.cs | 54 ++ ...cationServiceAccountToken.Serialization.cs | 119 +++ ...dpointAuthenticationServiceAccountToken.cs | 75 ++ ...emAssignedManagedIdentity.Serialization.cs | 122 +++ ...enticationSystemAssignedManagedIdentity.cs | 65 ++ ...erAssignedManagedIdentity.Serialization.cs | 138 +++ ...thenticationUserAssignedManagedIdentity.cs | 86 ++ ...ndpointAuthenticationX509.Serialization.cs | 119 +++ .../DataflowEndpointAuthenticationX509.cs | 75 ++ ...aflowEndpointDataExplorer.Serialization.cs | 150 +++ .../Models/DataflowEndpointDataExplorer.cs | 93 ++ ...ataExplorerAuthentication.Serialization.cs | 149 +++ ...aflowEndpointDataExplorerAuthentication.cs | 92 ++ ...owEndpointDataLakeStorage.Serialization.cs | 142 +++ .../Models/DataflowEndpointDataLakeStorage.cs | 86 ++ ...LakeStorageAuthentication.Serialization.cs | 164 ++++ ...owEndpointDataLakeStorageAuthentication.cs | 103 ++ ...flowEndpointFabricOneLake.Serialization.cs | 164 ++++ .../Models/DataflowEndpointFabricOneLake.cs | 99 ++ ...bricOneLakeAuthentication.Serialization.cs | 149 +++ ...flowEndpointFabricOneLakeAuthentication.cs | 92 ++ ...ndpointFabricOneLakeNames.Serialization.cs | 127 +++ .../DataflowEndpointFabricOneLakeNames.cs | 82 ++ .../Models/DataflowEndpointFabricPathType.cs | 51 + .../DataflowEndpointKafka.Serialization.cs | 254 +++++ .../Generated/Models/DataflowEndpointKafka.cs | 114 +++ .../Models/DataflowEndpointKafkaAck.cs | 54 ++ ...dpointKafkaAuthentication.Serialization.cs | 185 ++++ .../DataflowEndpointKafkaAuthentication.cs | 106 ++ ...flowEndpointKafkaBatching.Serialization.cs | 171 ++++ .../Models/DataflowEndpointKafkaBatching.cs | 77 ++ .../DataflowEndpointKafkaCompression.cs | 57 ++ .../DataflowEndpointKafkaPartitionStrategy.cs | 57 ++ ...aflowEndpointLocalStorage.Serialization.cs | 119 +++ .../Models/DataflowEndpointLocalStorage.cs | 75 ++ .../DataflowEndpointMqtt.Serialization.cs | 273 ++++++ .../Generated/Models/DataflowEndpointMqtt.cs | 115 +++ ...ndpointMqttAuthentication.Serialization.cs | 185 ++++ .../DataflowEndpointMqttAuthentication.cs | 113 +++ ...ataflowEndpointProperties.Serialization.cs | 233 +++++ .../Models/DataflowEndpointProperties.cs | 107 +++ ...ndpointResourceListResult.Serialization.cs | 144 +++ .../DataflowEndpointResourceListResult.cs | 80 ++ ...ataflowInstanceProperties.Serialization.cs | 119 +++ .../Models/DataflowInstanceProperties.cs | 72 ++ .../Generated/Models/DataflowMappingType.cs | 60 ++ .../Models/DataflowOperation.Serialization.cs | 181 ++++ .../src/Generated/Models/DataflowOperation.cs | 88 ++ ...DataflowProfileProperties.Serialization.cs | 156 +++ .../Models/DataflowProfileProperties.cs | 73 ++ ...ProfileResourceListResult.Serialization.cs | 144 +++ .../DataflowProfileResourceListResult.cs | 80 ++ .../DataflowProperties.Serialization.cs | 159 +++ .../Generated/Models/DataflowProperties.cs | 84 ++ ...ataflowResourceListResult.Serialization.cs | 144 +++ .../Models/DataflowResourceListResult.cs | 80 ++ ...owSourceOperationSettings.Serialization.cs | 180 ++++ .../Models/DataflowSourceOperationSettings.cs | 95 ++ .../Models/DiagnosticsLogs.Serialization.cs | 137 +++ .../src/Generated/Models/DiagnosticsLogs.cs | 69 ++ .../DiskBackedMessageBuffer.Serialization.cs | 149 +++ .../Models/DiskBackedMessageBuffer.cs | 83 ++ .../src/Generated/Models/EndpointType.cs | 63 ++ .../Models/ExtendedLocation.Serialization.cs | 127 +++ .../src/Generated/Models/ExtendedLocation.cs | 81 ++ .../Generated/Models/ExtendedLocationType.cs | 48 + .../Models/FabricOneLakeAuthMethod.cs | 51 + .../src/Generated/Models/FilterType.cs | 48 + .../Models/Frontend.Serialization.cs | 134 +++ .../src/Generated/Models/Frontend.cs | 76 ++ .../GenerateResourceLimits.Serialization.cs | 126 +++ .../Models/GenerateResourceLimits.cs | 65 ++ .../InstanceProperties.Serialization.cs | 177 ++++ .../Generated/Models/InstanceProperties.cs | 91 ++ ...nstanceResourceListResult.Serialization.cs | 144 +++ .../Models/InstanceResourceListResult.cs | 80 ++ .../InstanceResourcePatch.Serialization.cs | 155 +++ .../Generated/Models/InstanceResourcePatch.cs | 71 ++ .../src/Generated/Models/KafkaAuthMethod.cs | 60 ++ .../KubernetesReference.Serialization.cs | 149 +++ .../Generated/Models/KubernetesReference.cs | 90 ++ .../Models/ListenerPort.Serialization.cs | 193 ++++ .../src/Generated/Models/ListenerPort.cs | 92 ++ .../LocalKubernetesReference.Serialization.cs | 138 +++ .../Models/LocalKubernetesReference.cs | 86 ++ .../Generated/Models/Metrics.Serialization.cs | 141 +++ .../src/Generated/Models/Metrics.cs | 69 ++ .../src/Generated/Models/MqttAuthMethod.cs | 60 ++ .../src/Generated/Models/MqttRetainType.cs | 51 + ...OpenTelemetryExportConfig.Serialization.cs | 134 +++ .../Models/OpenTelemetryExportConfig.cs | 79 ++ ...nTelemetryLogExportConfig.Serialization.cs | 145 +++ .../Models/OpenTelemetryLogExportConfig.cs | 83 ++ .../Models/Operation.Serialization.cs | 188 ++++ .../src/Generated/Models/Operation.cs | 81 ++ .../Models/OperationDisplay.Serialization.cs | 155 +++ .../src/Generated/Models/OperationDisplay.cs | 77 ++ .../OperationListResult.Serialization.cs | 144 +++ .../Generated/Models/OperationListResult.cs | 80 ++ .../src/Generated/Models/OperationType.cs | 54 ++ .../src/Generated/Models/OperationalMode.cs | 51 + .../src/Generated/Models/OperatorValue.cs | 57 ++ .../src/Generated/Models/Origin.cs | 54 ++ .../PrincipalDefinition.Serialization.cs | 209 ++++ .../Generated/Models/PrincipalDefinition.cs | 76 ++ .../Generated/Models/PrivateKeyAlgorithm.cs | 66 ++ .../Models/PrivateKeyRotationPolicy.cs | 51 + .../ProfileDiagnostics.Serialization.cs | 141 +++ .../Generated/Models/ProfileDiagnostics.cs | 69 ++ .../src/Generated/Models/ProvisioningState.cs | 66 ++ .../Models/SanForCert.Serialization.cs | 147 +++ .../src/Generated/Models/SanForCert.cs | 83 ++ ...egistryInstanceProperties.Serialization.cs | 119 +++ .../SchemaRegistryInstanceProperties.cs | 72 ++ .../Models/SelfCheck.Serialization.cs | 156 +++ .../src/Generated/Models/SelfCheck.cs | 73 ++ .../Models/SelfTracing.Serialization.cs | 141 +++ .../src/Generated/Models/SelfTracing.cs | 69 ++ .../src/Generated/Models/ServiceType.cs | 54 ++ .../Models/SourceSerializationFormat.cs | 48 + .../StateStoreResourceDefinitionMethod.cs | 54 ++ .../Models/StateStoreResourceKeyType.cs | 54 ++ .../StateStoreResourceRule.Serialization.cs | 145 +++ .../Models/StateStoreResourceRule.cs | 88 ++ .../Models/SubscriberMessageDropStrategy.cs | 51 + .../SubscriberQueueLimit.Serialization.cs | 141 +++ .../Generated/Models/SubscriberQueueLimit.cs | 69 ++ .../Models/TlsCertMethod.Serialization.cs | 149 +++ .../src/Generated/Models/TlsCertMethod.cs | 86 ++ .../src/Generated/Models/TlsCertMethodMode.cs | 51 + .../Models/TlsProperties.Serialization.cs | 137 +++ .../src/Generated/Models/TlsProperties.cs | 69 ++ .../Generated/Models/Traces.Serialization.cs | 192 ++++ .../src/Generated/Models/Traces.cs | 81 ++ .../TransformationSerializationFormat.cs | 54 ++ ...ClaimResourceRequirements.Serialization.cs | 163 ++++ .../Models/VolumeClaimResourceRequirements.cs | 71 ++ .../Models/VolumeClaimSpec.Serialization.cs | 238 +++++ .../src/Generated/Models/VolumeClaimSpec.cs | 94 ++ .../VolumeClaimSpecSelector.Serialization.cs | 162 ++++ .../Models/VolumeClaimSpecSelector.cs | 71 ++ ...cSelectorMatchExpressions.Serialization.cs | 152 +++ ...VolumeClaimSpecSelectorMatchExpressions.cs | 86 ++ .../X509ManualCertificate.Serialization.cs | 119 +++ .../Generated/Models/X509ManualCertificate.cs | 75 ++ .../src/Generated/ProviderConstants.cs | 16 + .../BrokerAuthenticationRestOperations.cs | 549 +++++++++++ .../BrokerAuthorizationRestOperations.cs | 549 +++++++++++ .../BrokerListenerRestOperations.cs | 549 +++++++++++ .../RestOperations/BrokerRestOperations.cs | 513 ++++++++++ .../DataflowEndpointRestOperations.cs | 513 ++++++++++ .../DataflowProfileRestOperations.cs | 513 ++++++++++ .../RestOperations/DataflowRestOperations.cs | 549 +++++++++++ .../RestOperations/InstanceRestOperations.cs | 731 ++++++++++++++ .../OperationsRestOperations.cs | 173 ++++ .../src/Properties/AssemblyInfo.cs | 11 + ...ResourceManager.IoTOperations.Tests.csproj | 12 + .../tsp-location.yaml | 4 + sdk/iotoperations/ci.yml | 35 + 311 files changed, 42636 insertions(+) create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/Azure.ResourceManager.IoTOperations.sln create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/CHANGELOG.md create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/Directory.Build.props create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/README.md create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Azure.ResourceManager.IoTOperations.csproj create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/ArmIoTOperationsModelFactory.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/IoTOperationsExtensions.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsArmClient.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsResourceGroupResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsSubscriptionResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsTenantResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/Argument.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/ChangeTrackingList.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/ModelSerializationExtensions.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/Optional.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/Utf8JsonRequestContent.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerAuthenticationResourceOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerAuthorizationResourceOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerListenerResourceOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerResourceOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowEndpointResourceOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowProfileResourceOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowResourceOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/InstanceResourceOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/IoTOperationsArmOperation.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/IoTOperationsArmOperationOfT.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ActionType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdrProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdrProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdvancedSettings.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdvancedSettings.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AkriInstanceProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AkriInstanceProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationConfig.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationConfig.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationRule.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationRule.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BackendChain.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BackendChain.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BatchingConfiguration.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BatchingConfiguration.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationMethod.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationResourceListResult.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationResourceListResult.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorCustomAuth.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorCustomAuth.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodCustom.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodCustom.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodSat.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodSat.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509Attributes.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509Attributes.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethods.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethods.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationResourceListResult.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationResourceListResult.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerDiagnostics.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerDiagnostics.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerResourceListResult.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerResourceListResult.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerMemoryProfile.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProtocolType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceDefinitionMethod.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceListResult.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceListResult.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceRule.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceRule.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Cardinality.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Cardinality.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertOptions.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertOptions.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertificateSpec.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertificateSpec.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerKind.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerRef.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerRef.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerPrivateKey.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerPrivateKey.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ClientConfig.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ClientConfig.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CloudEventAttributeType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Components.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Components.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ConnectorInstanceProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ConnectorInstanceProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataExplorerAuthMethod.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataLakeStorageAuthMethod.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationDataset.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationDataset.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationFilter.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationFilter.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationMap.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationMap.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationSettings.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationSettings.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowDestinationOperationSettings.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowDestinationOperationSettings.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationAccessToken.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationAccessToken.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSasl.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSasl.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSaslType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationServiceAccountToken.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationServiceAccountToken.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSystemAssignedManagedIdentity.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSystemAssignedManagedIdentity.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationUserAssignedManagedIdentity.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationUserAssignedManagedIdentity.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationX509.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationX509.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorer.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorer.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorerAuthentication.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorerAuthentication.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorage.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorage.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorageAuthentication.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorageAuthentication.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLake.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLake.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeAuthentication.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeAuthentication.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeNames.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeNames.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricPathType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafka.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafka.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAck.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAuthentication.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAuthentication.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaBatching.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaBatching.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaCompression.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaPartitionStrategy.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointLocalStorage.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointLocalStorage.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqtt.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqtt.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqttAuthentication.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqttAuthentication.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointResourceListResult.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointResourceListResult.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowInstanceProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowInstanceProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowMappingType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowOperation.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowOperation.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileResourceListResult.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileResourceListResult.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowResourceListResult.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowResourceListResult.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowSourceOperationSettings.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowSourceOperationSettings.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiagnosticsLogs.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiagnosticsLogs.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiskBackedMessageBuffer.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiskBackedMessageBuffer.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/EndpointType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocation.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocation.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocationType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/FabricOneLakeAuthMethod.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/FilterType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Frontend.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Frontend.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/GenerateResourceLimits.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/GenerateResourceLimits.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourceListResult.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourceListResult.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourcePatch.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourcePatch.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KafkaAuthMethod.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KubernetesReference.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KubernetesReference.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ListenerPort.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ListenerPort.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/LocalKubernetesReference.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/LocalKubernetesReference.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Metrics.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Metrics.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/MqttAuthMethod.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/MqttRetainType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryExportConfig.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryExportConfig.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryLogExportConfig.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryLogExportConfig.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Operation.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Operation.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationDisplay.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationDisplay.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationListResult.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationListResult.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationalMode.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperatorValue.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Origin.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrincipalDefinition.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrincipalDefinition.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrivateKeyAlgorithm.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrivateKeyRotationPolicy.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProfileDiagnostics.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProfileDiagnostics.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProvisioningState.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SanForCert.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SanForCert.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SchemaRegistryInstanceProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SchemaRegistryInstanceProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfCheck.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfCheck.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfTracing.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfTracing.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ServiceType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SourceSerializationFormat.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceDefinitionMethod.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceKeyType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceRule.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceRule.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberMessageDropStrategy.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberQueueLimit.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberQueueLimit.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethod.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethod.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethodMode.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Traces.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Traces.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TransformationSerializationFormat.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimResourceRequirements.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimResourceRequirements.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpec.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpec.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelector.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelector.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelectorMatchExpressions.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelectorMatchExpressions.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/X509ManualCertificate.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/X509ManualCertificate.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/ProviderConstants.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerAuthenticationRestOperations.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerAuthorizationRestOperations.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerListenerRestOperations.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerRestOperations.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowEndpointRestOperations.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowProfileRestOperations.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowRestOperations.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/InstanceRestOperations.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/OperationsRestOperations.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Properties/AssemblyInfo.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/tests/Azure.ResourceManager.IoTOperations.Tests.csproj create mode 100644 sdk/iotoperations/Azure.ResourceManager.IoTOperations/tsp-location.yaml create mode 100644 sdk/iotoperations/ci.yml diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/Azure.ResourceManager.IoTOperations.sln b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/Azure.ResourceManager.IoTOperations.sln new file mode 100644 index 000000000000..3528878c41ce --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/Azure.ResourceManager.IoTOperations.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.IoTOperations", "src\Azure.ResourceManager.IoTOperations.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.IoTOperations.Tests", "tests\Azure.ResourceManager.IoTOperations.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/CHANGELOG.md b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/CHANGELOG.md new file mode 100644 index 000000000000..13dd08af78ab --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/Directory.Build.props b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/README.md b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/README.md new file mode 100644 index 000000000000..92abdc4c0f4c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/README.md @@ -0,0 +1,86 @@ +# Azure.ResourceManager.IoTOperations client library for .NET + +Azure.ResourceManager.IoTOperations is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.ResourceManager.IoTOperations --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/iotoperations/Azure.ResourceManager.IoTOperations/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/iotoperations/Azure.ResourceManager.IoTOperations/README.png) diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Azure.ResourceManager.IoTOperations.csproj b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Azure.ResourceManager.IoTOperations.csproj new file mode 100644 index 000000000000..f35cdf07bb01 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Azure.ResourceManager.IoTOperations.csproj @@ -0,0 +1,10 @@ + + + This is the Azure.ResourceManager.IoTOperations client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.ResourceManager.IoTOperations for Azure Data Plane + 1.0.0-beta.1 + Azure.ResourceManager.IoTOperations + $(RequiredTargetFrameworks) + true + + diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/ArmIoTOperationsModelFactory.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/ArmIoTOperationsModelFactory.cs new file mode 100644 index 000000000000..041283839209 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/ArmIoTOperationsModelFactory.cs @@ -0,0 +1,335 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Model factory for models. + public static partial class ArmIoTOperationsModelFactory + { + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// A new instance for mocking. + public static DataflowEndpointResourceData DataflowEndpointResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, DataflowEndpointProperties properties = null, ExtendedLocation extendedLocation = null) + { + return new DataflowEndpointResourceData( + id, + name, + resourceType, + systemData, + properties, + extendedLocation, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Endpoint Type. + /// Azure Data Explorer endpoint. + /// Azure Data Lake endpoint. + /// Microsoft Fabric endpoint. + /// Kafka endpoint. + /// Local persistent volume endpoint. + /// Broker endpoint. + /// The status of the last operation. + /// A new instance for mocking. + public static DataflowEndpointProperties DataflowEndpointProperties(EndpointType endpointType = default, DataflowEndpointDataExplorer dataExplorerSettings = null, DataflowEndpointDataLakeStorage dataLakeStorageSettings = null, DataflowEndpointFabricOneLake fabricOneLakeSettings = null, DataflowEndpointKafka kafkaSettings = null, string localStoragePersistentVolumeClaimRef = null, DataflowEndpointMqtt mqttSettings = null, ProvisioningState? provisioningState = null) + { + return new DataflowEndpointProperties( + endpointType, + dataExplorerSettings, + dataLakeStorageSettings, + fabricOneLakeSettings, + kafkaSettings, + localStoragePersistentVolumeClaimRef != null ? new DataflowEndpointLocalStorage(localStoragePersistentVolumeClaimRef, serializedAdditionalRawData: null) : null, + mqttSettings, + provisioningState, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// A new instance for mocking. + public static DataflowResourceData DataflowResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, DataflowProperties properties = null, ExtendedLocation extendedLocation = null) + { + return new DataflowResourceData( + id, + name, + resourceType, + systemData, + properties, + extendedLocation, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Mode for Dataflow. Optional; defaults to Enabled. + /// List of operations including source and destination references as well as transformation. + /// The status of the last operation. + /// A new instance for mocking. + public static DataflowProperties DataflowProperties(OperationalMode? mode = null, IEnumerable operations = null, ProvisioningState? provisioningState = null) + { + operations ??= new List(); + + return new DataflowProperties(mode, operations?.ToList(), provisioningState, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// A new instance for mocking. + public static DataflowProfileResourceData DataflowProfileResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, DataflowProfileProperties properties = null, ExtendedLocation extendedLocation = null) + { + return new DataflowProfileResourceData( + id, + name, + resourceType, + systemData, + properties, + extendedLocation, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Spec defines the desired identities of NBC diagnostics settings. + /// To manually scale the dataflow profile, specify the maximum number of instances you want to run. + /// The status of the last operation. + /// A new instance for mocking. + public static DataflowProfileProperties DataflowProfileProperties(ProfileDiagnostics diagnostics = null, int? instanceCount = null, ProvisioningState? provisioningState = null) + { + return new DataflowProfileProperties(diagnostics, instanceCount, provisioningState, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// A new instance for mocking. + public static BrokerAuthorizationResourceData BrokerAuthorizationResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, BrokerAuthorizationProperties properties = null, ExtendedLocation extendedLocation = null) + { + return new BrokerAuthorizationResourceData( + id, + name, + resourceType, + systemData, + properties, + extendedLocation, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The list of authorization policies supported by the Authorization Resource. + /// The status of the last operation. + /// A new instance for mocking. + public static BrokerAuthorizationProperties BrokerAuthorizationProperties(AuthorizationConfig authorizationPolicies = null, ProvisioningState? provisioningState = null) + { + return new BrokerAuthorizationProperties(authorizationPolicies, provisioningState, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// A new instance for mocking. + public static BrokerAuthenticationResourceData BrokerAuthenticationResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, BrokerAuthenticationProperties properties = null, ExtendedLocation extendedLocation = null) + { + return new BrokerAuthenticationResourceData( + id, + name, + resourceType, + systemData, + properties, + extendedLocation, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Defines a set of Broker authentication methods to be used on `BrokerListeners`. For each array element one authenticator type supported. + /// The status of the last operation. + /// A new instance for mocking. + public static BrokerAuthenticationProperties BrokerAuthenticationProperties(IEnumerable authenticationMethods = null, ProvisioningState? provisioningState = null) + { + authenticationMethods ??= new List(); + + return new BrokerAuthenticationProperties(authenticationMethods?.ToList(), provisioningState, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// A new instance for mocking. + public static BrokerListenerResourceData BrokerListenerResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, BrokerListenerProperties properties = null, ExtendedLocation extendedLocation = null) + { + return new BrokerListenerResourceData( + id, + name, + resourceType, + systemData, + properties, + extendedLocation, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Kubernetes Service name of this listener. + /// Ports on which this listener accepts client connections. + /// Kubernetes Service type of this listener. + /// The status of the last operation. + /// A new instance for mocking. + public static BrokerListenerProperties BrokerListenerProperties(string serviceName = null, IEnumerable ports = null, ServiceType? serviceType = null, ProvisioningState? provisioningState = null) + { + ports ??= new List(); + + return new BrokerListenerProperties(serviceName, ports?.ToList(), serviceType, provisioningState, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// A new instance for mocking. + public static BrokerResourceData BrokerResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, BrokerProperties properties = null, ExtendedLocation extendedLocation = null) + { + return new BrokerResourceData( + id, + name, + resourceType, + systemData, + properties, + extendedLocation, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Advanced settings of Broker. + /// The cardinality details of the broker. + /// Spec defines the desired identities of Broker diagnostics settings. + /// Settings of Disk Backed Message Buffer. + /// This setting controls whether Kubernetes CPU resource limits are requested. Increasing the number of replicas or workers proportionally increases the amount of CPU resources requested. If this setting is enabled and there are insufficient CPU resources, an error will be emitted. + /// Memory profile of Broker. + /// The status of the last operation. + /// A new instance for mocking. + public static BrokerProperties BrokerProperties(AdvancedSettings advanced = null, Cardinality cardinality = null, BrokerDiagnostics diagnostics = null, DiskBackedMessageBuffer diskBackedMessageBuffer = null, OperationalMode? generateResourceLimitsCpu = null, BrokerMemoryProfile? memoryProfile = null, ProvisioningState? provisioningState = null) + { + return new BrokerProperties( + advanced, + cardinality, + diagnostics, + diskBackedMessageBuffer, + generateResourceLimitsCpu != null ? new GenerateResourceLimits(generateResourceLimitsCpu, serializedAdditionalRawData: null) : null, + memoryProfile, + 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. + /// Edge location of the resource. + /// The managed service identities assigned to this resource. + /// A new instance for mocking. + public static InstanceResourceData InstanceResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, InstanceProperties properties = null, ExtendedLocation extendedLocation = null, ManagedServiceIdentity identity = null) + { + tags ??= new Dictionary(); + + return new InstanceResourceData( + id, + name, + resourceType, + systemData, + tags, + location, + properties, + extendedLocation, + identity, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Detailed description of the Instance. + /// The status of the last operation. + /// The Azure IoT Operations version. + /// The reference to the Schema Registry for this AIO Instance. + /// The configuration for components of the AIO Instance. + /// A new instance for mocking. + public static InstanceProperties InstanceProperties(string description = null, ProvisioningState? provisioningState = null, string version = null, string schemaRegistryNamespace = null, Components components = null) + { + return new InstanceProperties( + description, + provisioningState, + version, + schemaRegistryNamespace, + components, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + /// Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. + /// Localized display information for this particular operation. + /// The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". + /// Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + /// A new instance for mocking. + public static Operation Operation(string name = null, bool? isDataAction = null, OperationDisplay display = null, Origin? origin = null, ActionType? actionType = null) + { + return new Operation( + name, + isDataAction, + display, + origin, + actionType, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + /// The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + /// The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + /// The short, localized friendly description of the operation; suitable for tool tips and detailed views. + /// A new instance for mocking. + public static OperationDisplay OperationDisplay(string provider = null, string resource = null, string operation = null, string description = null) + { + return new OperationDisplay(provider, resource, operation, description, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResource.Serialization.cs new file mode 100644 index 000000000000..d5475abe9159 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.IoTOperations +{ + public partial class BrokerAuthenticationResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + BrokerAuthenticationResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + BrokerAuthenticationResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResource.cs new file mode 100644 index 000000000000..48182ae5fa1a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResource.cs @@ -0,0 +1,348 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A Class representing a BrokerAuthenticationResource 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 GetBrokerAuthenticationResource method. + /// Otherwise you can get one from its parent resource using the GetBrokerAuthenticationResource method. + /// + public partial class BrokerAuthenticationResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The instanceName. + /// The brokerName. + /// The authenticationName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authenticationName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics; + private readonly BrokerAuthenticationRestOperations _brokerAuthenticationResourceBrokerAuthenticationRestClient; + private readonly BrokerAuthenticationResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.IoTOperations/instances/brokers/authentications"; + + /// Initializes a new instance of the class for mocking. + protected BrokerAuthenticationResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal BrokerAuthenticationResource(ArmClient client, BrokerAuthenticationResourceData 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 BrokerAuthenticationResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string brokerAuthenticationResourceBrokerAuthenticationApiVersion); + _brokerAuthenticationResourceBrokerAuthenticationRestClient = new BrokerAuthenticationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, brokerAuthenticationResourceBrokerAuthenticationApiVersion); +#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 BrokerAuthenticationResourceData 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 BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResource.Get"); + scope.Start(); + try + { + var response = await _brokerAuthenticationResourceBrokerAuthenticationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthenticationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResource.Get"); + scope.Start(); + try + { + var response = _brokerAuthenticationResourceBrokerAuthenticationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthenticationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResource.Delete"); + scope.Start(); + try + { + var response = await _brokerAuthenticationResourceBrokerAuthenticationRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(_brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics, Pipeline, _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, 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 BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResource.Delete"); + scope.Start(); + try + { + var response = _brokerAuthenticationResourceBrokerAuthenticationRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IoTOperationsArmOperation(_brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics, Pipeline, _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, 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; + } + } + + /// + /// Create a BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, BrokerAuthenticationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResource.Update"); + scope.Start(); + try + { + var response = await _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new BrokerAuthenticationResourceOperationSource(Client), _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics, Pipeline, _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, 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 BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, BrokerAuthenticationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResource.Update"); + scope.Start(); + try + { + var response = _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new BrokerAuthenticationResourceOperationSource(Client), _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics, Pipeline, _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceCollection.cs new file mode 100644 index 000000000000..fa5acbc86490 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceCollection.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.IoTOperations +{ + /// + /// 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 GetBrokerAuthenticationResources method from an instance of . + /// + public partial class BrokerAuthenticationResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics; + private readonly BrokerAuthenticationRestOperations _brokerAuthenticationResourceBrokerAuthenticationRestClient; + + /// Initializes a new instance of the class for mocking. + protected BrokerAuthenticationResourceCollection() + { + } + + /// 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 BrokerAuthenticationResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", BrokerAuthenticationResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(BrokerAuthenticationResource.ResourceType, out string brokerAuthenticationResourceBrokerAuthenticationApiVersion); + _brokerAuthenticationResourceBrokerAuthenticationRestClient = new BrokerAuthenticationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, brokerAuthenticationResourceBrokerAuthenticationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != BrokerResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, BrokerResource.ResourceType), nameof(id)); + } + + /// + /// Create a BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance broker authentication 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 authenticationName, BrokerAuthenticationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new BrokerAuthenticationResourceOperationSource(Client), _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics, Pipeline, _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, 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 BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance broker authentication 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 authenticationName, BrokerAuthenticationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new BrokerAuthenticationResourceOperationSource(Client), _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics, Pipeline, _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authentication 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 authenticationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResourceCollection.Get"); + scope.Start(); + try + { + var response = await _brokerAuthenticationResourceBrokerAuthenticationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthenticationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authentication resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string authenticationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResourceCollection.Get"); + scope.Start(); + try + { + var response = _brokerAuthenticationResourceBrokerAuthenticationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthenticationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List BrokerAuthenticationResource resources by BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications + /// + /// + /// Operation Id + /// BrokerAuthenticationResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new BrokerAuthenticationResource(Client, BrokerAuthenticationResourceData.DeserializeBrokerAuthenticationResourceData(e)), _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics, Pipeline, "BrokerAuthenticationResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List BrokerAuthenticationResource resources by BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications + /// + /// + /// Operation Id + /// BrokerAuthenticationResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _brokerAuthenticationResourceBrokerAuthenticationRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new BrokerAuthenticationResource(Client, BrokerAuthenticationResourceData.DeserializeBrokerAuthenticationResourceData(e)), _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics, Pipeline, "BrokerAuthenticationResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authentication 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 authenticationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _brokerAuthenticationResourceBrokerAuthenticationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, 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.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authentication resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string authenticationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResourceCollection.Exists"); + scope.Start(); + try + { + var response = _brokerAuthenticationResourceBrokerAuthenticationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, 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.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authentication 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 authenticationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _brokerAuthenticationResourceBrokerAuthenticationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthenticationResource(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.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authentication resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string authenticationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + + using var scope = _brokerAuthenticationResourceBrokerAuthenticationClientDiagnostics.CreateScope("BrokerAuthenticationResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _brokerAuthenticationResourceBrokerAuthenticationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthenticationResource(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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceData.Serialization.cs new file mode 100644 index 000000000000..85b0a4386685 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceData.Serialization.cs @@ -0,0 +1,191 @@ +// 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; +using Azure.ResourceManager.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + public partial class BrokerAuthenticationResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticationResourceData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthenticationResourceData 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(BrokerAuthenticationResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthenticationResourceData(document.RootElement, options); + } + + internal static BrokerAuthenticationResourceData DeserializeBrokerAuthenticationResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrokerAuthenticationProperties properties = default; + ExtendedLocation extendedLocation = 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 = BrokerAuthenticationProperties.DeserializeBrokerAuthenticationProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = ExtendedLocation.DeserializeExtendedLocation(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 = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerAuthenticationResourceData( + id, + name, + type, + systemData, + properties, + extendedLocation, + 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); + default: + throw new FormatException($"The model {nameof(BrokerAuthenticationResourceData)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthenticationResourceData 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); + return DeserializeBrokerAuthenticationResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthenticationResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceData.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceData.cs new file mode 100644 index 000000000000..7b6ef1b609e1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthenticationResourceData.cs @@ -0,0 +1,89 @@ +// 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.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A class representing the BrokerAuthenticationResource data model. + /// Instance broker authentication resource + /// + public partial class BrokerAuthenticationResourceData : 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 . + /// Edge location of the resource. + /// is null. + public BrokerAuthenticationResourceData(ExtendedLocation extendedLocation) + { + Argument.AssertNotNull(extendedLocation, nameof(extendedLocation)); + + ExtendedLocation = extendedLocation; + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthenticationResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BrokerAuthenticationProperties properties, ExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthenticationResourceData() + { + } + + /// The resource-specific properties for this resource. + public BrokerAuthenticationProperties Properties { get; set; } + /// Edge location of the resource. + public ExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResource.Serialization.cs new file mode 100644 index 000000000000..ee32487ae044 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.IoTOperations +{ + public partial class BrokerAuthorizationResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + BrokerAuthorizationResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + BrokerAuthorizationResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResource.cs new file mode 100644 index 000000000000..889063d2b6ae --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResource.cs @@ -0,0 +1,348 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A Class representing a BrokerAuthorizationResource 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 GetBrokerAuthorizationResource method. + /// Otherwise you can get one from its parent resource using the GetBrokerAuthorizationResource method. + /// + public partial class BrokerAuthorizationResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The instanceName. + /// The brokerName. + /// The authorizationName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authorizationName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics; + private readonly BrokerAuthorizationRestOperations _brokerAuthorizationResourceBrokerAuthorizationRestClient; + private readonly BrokerAuthorizationResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.IoTOperations/instances/brokers/authorizations"; + + /// Initializes a new instance of the class for mocking. + protected BrokerAuthorizationResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal BrokerAuthorizationResource(ArmClient client, BrokerAuthorizationResourceData 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 BrokerAuthorizationResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string brokerAuthorizationResourceBrokerAuthorizationApiVersion); + _brokerAuthorizationResourceBrokerAuthorizationRestClient = new BrokerAuthorizationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, brokerAuthorizationResourceBrokerAuthorizationApiVersion); +#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 BrokerAuthorizationResourceData 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 BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResource.Get"); + scope.Start(); + try + { + var response = await _brokerAuthorizationResourceBrokerAuthorizationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthorizationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResource.Get"); + scope.Start(); + try + { + var response = _brokerAuthorizationResourceBrokerAuthorizationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthorizationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResource.Delete"); + scope.Start(); + try + { + var response = await _brokerAuthorizationResourceBrokerAuthorizationRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(_brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics, Pipeline, _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, 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 BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResource.Delete"); + scope.Start(); + try + { + var response = _brokerAuthorizationResourceBrokerAuthorizationRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IoTOperationsArmOperation(_brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics, Pipeline, _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, 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; + } + } + + /// + /// Create a BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, BrokerAuthorizationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResource.Update"); + scope.Start(); + try + { + var response = await _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new BrokerAuthorizationResourceOperationSource(Client), _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics, Pipeline, _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, 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 BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, BrokerAuthorizationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResource.Update"); + scope.Start(); + try + { + var response = _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new BrokerAuthorizationResourceOperationSource(Client), _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics, Pipeline, _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceCollection.cs new file mode 100644 index 000000000000..fc6869c08cc0 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceCollection.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.IoTOperations +{ + /// + /// 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 GetBrokerAuthorizationResources method from an instance of . + /// + public partial class BrokerAuthorizationResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics; + private readonly BrokerAuthorizationRestOperations _brokerAuthorizationResourceBrokerAuthorizationRestClient; + + /// Initializes a new instance of the class for mocking. + protected BrokerAuthorizationResourceCollection() + { + } + + /// 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 BrokerAuthorizationResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", BrokerAuthorizationResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(BrokerAuthorizationResource.ResourceType, out string brokerAuthorizationResourceBrokerAuthorizationApiVersion); + _brokerAuthorizationResourceBrokerAuthorizationRestClient = new BrokerAuthorizationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, brokerAuthorizationResourceBrokerAuthorizationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != BrokerResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, BrokerResource.ResourceType), nameof(id)); + } + + /// + /// Create a BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance broker authorization 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 authorizationName, BrokerAuthorizationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new BrokerAuthorizationResourceOperationSource(Client), _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics, Pipeline, _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, 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 BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance broker authorization 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 authorizationName, BrokerAuthorizationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new BrokerAuthorizationResourceOperationSource(Client), _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics, Pipeline, _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authorization 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 authorizationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResourceCollection.Get"); + scope.Start(); + try + { + var response = await _brokerAuthorizationResourceBrokerAuthorizationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthorizationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authorization resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string authorizationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResourceCollection.Get"); + scope.Start(); + try + { + var response = _brokerAuthorizationResourceBrokerAuthorizationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthorizationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List BrokerAuthorizationResource resources by BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations + /// + /// + /// Operation Id + /// BrokerAuthorizationResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new BrokerAuthorizationResource(Client, BrokerAuthorizationResourceData.DeserializeBrokerAuthorizationResourceData(e)), _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics, Pipeline, "BrokerAuthorizationResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List BrokerAuthorizationResource resources by BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations + /// + /// + /// Operation Id + /// BrokerAuthorizationResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _brokerAuthorizationResourceBrokerAuthorizationRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new BrokerAuthorizationResource(Client, BrokerAuthorizationResourceData.DeserializeBrokerAuthorizationResourceData(e)), _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics, Pipeline, "BrokerAuthorizationResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authorization 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 authorizationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _brokerAuthorizationResourceBrokerAuthorizationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, 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.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authorization resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string authorizationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResourceCollection.Exists"); + scope.Start(); + try + { + var response = _brokerAuthorizationResourceBrokerAuthorizationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, 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.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authorization 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 authorizationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _brokerAuthorizationResourceBrokerAuthorizationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthorizationResource(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.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authorization resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string authorizationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + + using var scope = _brokerAuthorizationResourceBrokerAuthorizationClientDiagnostics.CreateScope("BrokerAuthorizationResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _brokerAuthorizationResourceBrokerAuthorizationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new BrokerAuthorizationResource(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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceData.Serialization.cs new file mode 100644 index 000000000000..9508fde75e51 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceData.Serialization.cs @@ -0,0 +1,191 @@ +// 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; +using Azure.ResourceManager.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + public partial class BrokerAuthorizationResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthorizationResourceData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthorizationResourceData 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(BrokerAuthorizationResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthorizationResourceData(document.RootElement, options); + } + + internal static BrokerAuthorizationResourceData DeserializeBrokerAuthorizationResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrokerAuthorizationProperties properties = default; + ExtendedLocation extendedLocation = 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 = BrokerAuthorizationProperties.DeserializeBrokerAuthorizationProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = ExtendedLocation.DeserializeExtendedLocation(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 = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerAuthorizationResourceData( + id, + name, + type, + systemData, + properties, + extendedLocation, + 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); + default: + throw new FormatException($"The model {nameof(BrokerAuthorizationResourceData)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthorizationResourceData 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); + return DeserializeBrokerAuthorizationResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthorizationResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceData.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceData.cs new file mode 100644 index 000000000000..006a048e3b06 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerAuthorizationResourceData.cs @@ -0,0 +1,89 @@ +// 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.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A class representing the BrokerAuthorizationResource data model. + /// Instance broker authorizations resource + /// + public partial class BrokerAuthorizationResourceData : 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 . + /// Edge location of the resource. + /// is null. + public BrokerAuthorizationResourceData(ExtendedLocation extendedLocation) + { + Argument.AssertNotNull(extendedLocation, nameof(extendedLocation)); + + ExtendedLocation = extendedLocation; + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthorizationResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BrokerAuthorizationProperties properties, ExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthorizationResourceData() + { + } + + /// The resource-specific properties for this resource. + public BrokerAuthorizationProperties Properties { get; set; } + /// Edge location of the resource. + public ExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResource.Serialization.cs new file mode 100644 index 000000000000..e2cf75c6f20f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.IoTOperations +{ + public partial class BrokerListenerResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + BrokerListenerResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + BrokerListenerResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResource.cs new file mode 100644 index 000000000000..659dca2f8000 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResource.cs @@ -0,0 +1,348 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A Class representing a BrokerListenerResource 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 GetBrokerListenerResource method. + /// Otherwise you can get one from its parent resource using the GetBrokerListenerResource method. + /// + public partial class BrokerListenerResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The instanceName. + /// The brokerName. + /// The listenerName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string listenerName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _brokerListenerResourceBrokerListenerClientDiagnostics; + private readonly BrokerListenerRestOperations _brokerListenerResourceBrokerListenerRestClient; + private readonly BrokerListenerResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.IoTOperations/instances/brokers/listeners"; + + /// Initializes a new instance of the class for mocking. + protected BrokerListenerResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal BrokerListenerResource(ArmClient client, BrokerListenerResourceData 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 BrokerListenerResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _brokerListenerResourceBrokerListenerClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string brokerListenerResourceBrokerListenerApiVersion); + _brokerListenerResourceBrokerListenerRestClient = new BrokerListenerRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, brokerListenerResourceBrokerListenerApiVersion); +#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 BrokerListenerResourceData 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 BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResource.Get"); + scope.Start(); + try + { + var response = await _brokerListenerResourceBrokerListenerRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerListenerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResource.Get"); + scope.Start(); + try + { + var response = _brokerListenerResourceBrokerListenerRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerListenerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResource.Delete"); + scope.Start(); + try + { + var response = await _brokerListenerResourceBrokerListenerRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(_brokerListenerResourceBrokerListenerClientDiagnostics, Pipeline, _brokerListenerResourceBrokerListenerRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, 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 BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResource.Delete"); + scope.Start(); + try + { + var response = _brokerListenerResourceBrokerListenerRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IoTOperationsArmOperation(_brokerListenerResourceBrokerListenerClientDiagnostics, Pipeline, _brokerListenerResourceBrokerListenerRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, 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; + } + } + + /// + /// Create a BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, BrokerListenerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResource.Update"); + scope.Start(); + try + { + var response = await _brokerListenerResourceBrokerListenerRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new BrokerListenerResourceOperationSource(Client), _brokerListenerResourceBrokerListenerClientDiagnostics, Pipeline, _brokerListenerResourceBrokerListenerRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, 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 BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, BrokerListenerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResource.Update"); + scope.Start(); + try + { + var response = _brokerListenerResourceBrokerListenerRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new BrokerListenerResourceOperationSource(Client), _brokerListenerResourceBrokerListenerClientDiagnostics, Pipeline, _brokerListenerResourceBrokerListenerRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceCollection.cs new file mode 100644 index 000000000000..e9c1a8c1dbb5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceCollection.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.IoTOperations +{ + /// + /// 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 GetBrokerListenerResources method from an instance of . + /// + public partial class BrokerListenerResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _brokerListenerResourceBrokerListenerClientDiagnostics; + private readonly BrokerListenerRestOperations _brokerListenerResourceBrokerListenerRestClient; + + /// Initializes a new instance of the class for mocking. + protected BrokerListenerResourceCollection() + { + } + + /// 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 BrokerListenerResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _brokerListenerResourceBrokerListenerClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", BrokerListenerResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(BrokerListenerResource.ResourceType, out string brokerListenerResourceBrokerListenerApiVersion); + _brokerListenerResourceBrokerListenerRestClient = new BrokerListenerRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, brokerListenerResourceBrokerListenerApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != BrokerResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, BrokerResource.ResourceType), nameof(id)); + } + + /// + /// Create a BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance broker listener 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 listenerName, BrokerListenerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _brokerListenerResourceBrokerListenerRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new BrokerListenerResourceOperationSource(Client), _brokerListenerResourceBrokerListenerClientDiagnostics, Pipeline, _brokerListenerResourceBrokerListenerRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, 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 BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance broker listener 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 listenerName, BrokerListenerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _brokerListenerResourceBrokerListenerRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new BrokerListenerResourceOperationSource(Client), _brokerListenerResourceBrokerListenerClientDiagnostics, Pipeline, _brokerListenerResourceBrokerListenerRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker listener 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 listenerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResourceCollection.Get"); + scope.Start(); + try + { + var response = await _brokerListenerResourceBrokerListenerRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerListenerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker listener resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string listenerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResourceCollection.Get"); + scope.Start(); + try + { + var response = _brokerListenerResourceBrokerListenerRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerListenerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List BrokerListenerResource resources by BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners + /// + /// + /// Operation Id + /// BrokerListenerResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _brokerListenerResourceBrokerListenerRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _brokerListenerResourceBrokerListenerRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new BrokerListenerResource(Client, BrokerListenerResourceData.DeserializeBrokerListenerResourceData(e)), _brokerListenerResourceBrokerListenerClientDiagnostics, Pipeline, "BrokerListenerResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List BrokerListenerResource resources by BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners + /// + /// + /// Operation Id + /// BrokerListenerResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _brokerListenerResourceBrokerListenerRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _brokerListenerResourceBrokerListenerRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new BrokerListenerResource(Client, BrokerListenerResourceData.DeserializeBrokerListenerResourceData(e)), _brokerListenerResourceBrokerListenerClientDiagnostics, Pipeline, "BrokerListenerResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker listener 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 listenerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _brokerListenerResourceBrokerListenerRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, 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.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker listener resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string listenerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResourceCollection.Exists"); + scope.Start(); + try + { + var response = _brokerListenerResourceBrokerListenerRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, 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.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker listener 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 listenerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _brokerListenerResourceBrokerListenerRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new BrokerListenerResource(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.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker listener resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string listenerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + + using var scope = _brokerListenerResourceBrokerListenerClientDiagnostics.CreateScope("BrokerListenerResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _brokerListenerResourceBrokerListenerRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new BrokerListenerResource(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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceData.Serialization.cs new file mode 100644 index 000000000000..ccf986d0675c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceData.Serialization.cs @@ -0,0 +1,191 @@ +// 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; +using Azure.ResourceManager.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + public partial class BrokerListenerResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerListenerResourceData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerListenerResourceData 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(BrokerListenerResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerListenerResourceData(document.RootElement, options); + } + + internal static BrokerListenerResourceData DeserializeBrokerListenerResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrokerListenerProperties properties = default; + ExtendedLocation extendedLocation = 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 = BrokerListenerProperties.DeserializeBrokerListenerProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = ExtendedLocation.DeserializeExtendedLocation(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 = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerListenerResourceData( + id, + name, + type, + systemData, + properties, + extendedLocation, + 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); + default: + throw new FormatException($"The model {nameof(BrokerListenerResourceData)} does not support writing '{options.Format}' format."); + } + } + + BrokerListenerResourceData 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); + return DeserializeBrokerListenerResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerListenerResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceData.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceData.cs new file mode 100644 index 000000000000..e78c861ec340 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerListenerResourceData.cs @@ -0,0 +1,89 @@ +// 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.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A class representing the BrokerListenerResource data model. + /// Instance broker resource + /// + public partial class BrokerListenerResourceData : 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 . + /// Edge location of the resource. + /// is null. + public BrokerListenerResourceData(ExtendedLocation extendedLocation) + { + Argument.AssertNotNull(extendedLocation, nameof(extendedLocation)); + + ExtendedLocation = extendedLocation; + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// Keeps track of any properties unknown to the library. + internal BrokerListenerResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BrokerListenerProperties properties, ExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerListenerResourceData() + { + } + + /// The resource-specific properties for this resource. + public BrokerListenerProperties Properties { get; set; } + /// Edge location of the resource. + public ExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResource.Serialization.cs new file mode 100644 index 000000000000..1c57df972270 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.IoTOperations +{ + public partial class BrokerResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + BrokerResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + BrokerResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResource.cs new file mode 100644 index 000000000000..c818dff510f8 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResource.cs @@ -0,0 +1,554 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A Class representing a BrokerResource 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 GetBrokerResource method. + /// Otherwise you can get one from its parent resource using the GetBrokerResource method. + /// + public partial class BrokerResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The instanceName. + /// The brokerName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _brokerResourceBrokerClientDiagnostics; + private readonly BrokerRestOperations _brokerResourceBrokerRestClient; + private readonly BrokerResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.IoTOperations/instances/brokers"; + + /// Initializes a new instance of the class for mocking. + protected BrokerResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal BrokerResource(ArmClient client, BrokerResourceData 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 BrokerResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _brokerResourceBrokerClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string brokerResourceBrokerApiVersion); + _brokerResourceBrokerRestClient = new BrokerRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, brokerResourceBrokerApiVersion); +#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 BrokerResourceData 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 BrokerListenerResources in the BrokerResource. + /// An object representing collection of BrokerListenerResources and their operations over a BrokerListenerResource. + public virtual BrokerListenerResourceCollection GetBrokerListenerResources() + { + return GetCachedClient(client => new BrokerListenerResourceCollection(client, Id)); + } + + /// + /// Get a BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker listener resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetBrokerListenerResourceAsync(string listenerName, CancellationToken cancellationToken = default) + { + return await GetBrokerListenerResources().GetAsync(listenerName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListener_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker listener resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetBrokerListenerResource(string listenerName, CancellationToken cancellationToken = default) + { + return GetBrokerListenerResources().Get(listenerName, cancellationToken); + } + + /// Gets a collection of BrokerAuthenticationResources in the BrokerResource. + /// An object representing collection of BrokerAuthenticationResources and their operations over a BrokerAuthenticationResource. + public virtual BrokerAuthenticationResourceCollection GetBrokerAuthenticationResources() + { + return GetCachedClient(client => new BrokerAuthenticationResourceCollection(client, Id)); + } + + /// + /// Get a BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authentication resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetBrokerAuthenticationResourceAsync(string authenticationName, CancellationToken cancellationToken = default) + { + return await GetBrokerAuthenticationResources().GetAsync(authenticationName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthentication_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authentication resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetBrokerAuthenticationResource(string authenticationName, CancellationToken cancellationToken = default) + { + return GetBrokerAuthenticationResources().Get(authenticationName, cancellationToken); + } + + /// Gets a collection of BrokerAuthorizationResources in the BrokerResource. + /// An object representing collection of BrokerAuthorizationResources and their operations over a BrokerAuthorizationResource. + public virtual BrokerAuthorizationResourceCollection GetBrokerAuthorizationResources() + { + return GetCachedClient(client => new BrokerAuthorizationResourceCollection(client, Id)); + } + + /// + /// Get a BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authorization resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetBrokerAuthorizationResourceAsync(string authorizationName, CancellationToken cancellationToken = default) + { + return await GetBrokerAuthorizationResources().GetAsync(authorizationName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorization_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance broker authorization resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetBrokerAuthorizationResource(string authorizationName, CancellationToken cancellationToken = default) + { + return GetBrokerAuthorizationResources().Get(authorizationName, cancellationToken); + } + + /// + /// Get a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResource.Get"); + scope.Start(); + try + { + var response = await _brokerResourceBrokerRestClient.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 BrokerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResource.Get"); + scope.Start(); + try + { + var response = _brokerResourceBrokerRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResource.Delete"); + scope.Start(); + try + { + var response = await _brokerResourceBrokerRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(_brokerResourceBrokerClientDiagnostics, Pipeline, _brokerResourceBrokerRestClient.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 BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResource.Delete"); + scope.Start(); + try + { + var response = _brokerResourceBrokerRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IoTOperationsArmOperation(_brokerResourceBrokerClientDiagnostics, Pipeline, _brokerResourceBrokerRestClient.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; + } + } + + /// + /// Create a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, BrokerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResource.Update"); + scope.Start(); + try + { + var response = await _brokerResourceBrokerRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new BrokerResourceOperationSource(Client), _brokerResourceBrokerClientDiagnostics, Pipeline, _brokerResourceBrokerRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, 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 BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, BrokerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResource.Update"); + scope.Start(); + try + { + var response = _brokerResourceBrokerRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new BrokerResourceOperationSource(Client), _brokerResourceBrokerClientDiagnostics, Pipeline, _brokerResourceBrokerRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceCollection.cs new file mode 100644 index 000000000000..ed7babb2fee2 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceCollection.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.IoTOperations +{ + /// + /// 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 GetBrokerResources method from an instance of . + /// + public partial class BrokerResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _brokerResourceBrokerClientDiagnostics; + private readonly BrokerRestOperations _brokerResourceBrokerRestClient; + + /// Initializes a new instance of the class for mocking. + protected BrokerResourceCollection() + { + } + + /// 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 BrokerResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _brokerResourceBrokerClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", BrokerResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(BrokerResource.ResourceType, out string brokerResourceBrokerApiVersion); + _brokerResourceBrokerRestClient = new BrokerRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, brokerResourceBrokerApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != InstanceResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, InstanceResource.ResourceType), nameof(id)); + } + + /// + /// Create a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of broker. + /// 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 brokerName, BrokerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _brokerResourceBrokerRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new BrokerResourceOperationSource(Client), _brokerResourceBrokerClientDiagnostics, Pipeline, _brokerResourceBrokerRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, 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 BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of broker. + /// 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 brokerName, BrokerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _brokerResourceBrokerRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new BrokerResourceOperationSource(Client), _brokerResourceBrokerClientDiagnostics, Pipeline, _brokerResourceBrokerRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of broker. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResourceCollection.Get"); + scope.Start(); + try + { + var response = await _brokerResourceBrokerRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of broker. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResourceCollection.Get"); + scope.Start(); + try + { + var response = _brokerResourceBrokerRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new BrokerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List BrokerResource resources by InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers + /// + /// + /// Operation Id + /// BrokerResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _brokerResourceBrokerRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _brokerResourceBrokerRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new BrokerResource(Client, BrokerResourceData.DeserializeBrokerResourceData(e)), _brokerResourceBrokerClientDiagnostics, Pipeline, "BrokerResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List BrokerResource resources by InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers + /// + /// + /// Operation Id + /// BrokerResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _brokerResourceBrokerRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _brokerResourceBrokerRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new BrokerResource(Client, BrokerResourceData.DeserializeBrokerResourceData(e)), _brokerResourceBrokerClientDiagnostics, Pipeline, "BrokerResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of broker. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _brokerResourceBrokerRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, 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.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of broker. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResourceCollection.Exists"); + scope.Start(); + try + { + var response = _brokerResourceBrokerRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, 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.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of broker. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _brokerResourceBrokerRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new BrokerResource(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.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of broker. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var scope = _brokerResourceBrokerClientDiagnostics.CreateScope("BrokerResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _brokerResourceBrokerRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new BrokerResource(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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceData.Serialization.cs new file mode 100644 index 000000000000..21ee52effeb6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceData.Serialization.cs @@ -0,0 +1,191 @@ +// 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; +using Azure.ResourceManager.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + public partial class BrokerResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerResourceData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerResourceData 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(BrokerResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerResourceData(document.RootElement, options); + } + + internal static BrokerResourceData DeserializeBrokerResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrokerProperties properties = default; + ExtendedLocation extendedLocation = 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 = BrokerProperties.DeserializeBrokerProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = ExtendedLocation.DeserializeExtendedLocation(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 = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerResourceData( + id, + name, + type, + systemData, + properties, + extendedLocation, + 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); + default: + throw new FormatException($"The model {nameof(BrokerResourceData)} does not support writing '{options.Format}' format."); + } + } + + BrokerResourceData 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); + return DeserializeBrokerResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceData.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceData.cs new file mode 100644 index 000000000000..f53dd7c8822a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/BrokerResourceData.cs @@ -0,0 +1,89 @@ +// 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.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A class representing the BrokerResource data model. + /// Instance broker resource + /// + public partial class BrokerResourceData : 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 . + /// Edge location of the resource. + /// is null. + public BrokerResourceData(ExtendedLocation extendedLocation) + { + Argument.AssertNotNull(extendedLocation, nameof(extendedLocation)); + + ExtendedLocation = extendedLocation; + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// Keeps track of any properties unknown to the library. + internal BrokerResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BrokerProperties properties, ExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerResourceData() + { + } + + /// The resource-specific properties for this resource. + public BrokerProperties Properties { get; set; } + /// Edge location of the resource. + public ExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResource.Serialization.cs new file mode 100644 index 000000000000..f76b1d2fb551 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.IoTOperations +{ + public partial class DataflowEndpointResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + DataflowEndpointResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + DataflowEndpointResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResource.cs new file mode 100644 index 000000000000..f62d6f376b78 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResource.cs @@ -0,0 +1,347 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A Class representing a DataflowEndpointResource 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 GetDataflowEndpointResource method. + /// Otherwise you can get one from its parent resource using the GetDataflowEndpointResource method. + /// + public partial class DataflowEndpointResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The instanceName. + /// The dataflowEndpointName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string instanceName, string dataflowEndpointName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _dataflowEndpointResourceDataflowEndpointClientDiagnostics; + private readonly DataflowEndpointRestOperations _dataflowEndpointResourceDataflowEndpointRestClient; + private readonly DataflowEndpointResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.IoTOperations/instances/dataflowEndpoints"; + + /// Initializes a new instance of the class for mocking. + protected DataflowEndpointResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal DataflowEndpointResource(ArmClient client, DataflowEndpointResourceData 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 DataflowEndpointResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _dataflowEndpointResourceDataflowEndpointClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string dataflowEndpointResourceDataflowEndpointApiVersion); + _dataflowEndpointResourceDataflowEndpointRestClient = new DataflowEndpointRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, dataflowEndpointResourceDataflowEndpointApiVersion); +#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 DataflowEndpointResourceData 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 DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResource.Get"); + scope.Start(); + try + { + var response = await _dataflowEndpointResourceDataflowEndpointRestClient.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 DataflowEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResource.Get"); + scope.Start(); + try + { + var response = _dataflowEndpointResourceDataflowEndpointRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DataflowEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResource.Delete"); + scope.Start(); + try + { + var response = await _dataflowEndpointResourceDataflowEndpointRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(_dataflowEndpointResourceDataflowEndpointClientDiagnostics, Pipeline, _dataflowEndpointResourceDataflowEndpointRestClient.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 DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResource.Delete"); + scope.Start(); + try + { + var response = _dataflowEndpointResourceDataflowEndpointRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IoTOperationsArmOperation(_dataflowEndpointResourceDataflowEndpointClientDiagnostics, Pipeline, _dataflowEndpointResourceDataflowEndpointRestClient.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; + } + } + + /// + /// Create a DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DataflowEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResource.Update"); + scope.Start(); + try + { + var response = await _dataflowEndpointResourceDataflowEndpointRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new DataflowEndpointResourceOperationSource(Client), _dataflowEndpointResourceDataflowEndpointClientDiagnostics, Pipeline, _dataflowEndpointResourceDataflowEndpointRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, 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 DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, DataflowEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResource.Update"); + scope.Start(); + try + { + var response = _dataflowEndpointResourceDataflowEndpointRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new DataflowEndpointResourceOperationSource(Client), _dataflowEndpointResourceDataflowEndpointClientDiagnostics, Pipeline, _dataflowEndpointResourceDataflowEndpointRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceCollection.cs new file mode 100644 index 000000000000..1e324839347a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceCollection.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.IoTOperations +{ + /// + /// 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 GetDataflowEndpointResources method from an instance of . + /// + public partial class DataflowEndpointResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _dataflowEndpointResourceDataflowEndpointClientDiagnostics; + private readonly DataflowEndpointRestOperations _dataflowEndpointResourceDataflowEndpointRestClient; + + /// Initializes a new instance of the class for mocking. + protected DataflowEndpointResourceCollection() + { + } + + /// 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 DataflowEndpointResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _dataflowEndpointResourceDataflowEndpointClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", DataflowEndpointResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(DataflowEndpointResource.ResourceType, out string dataflowEndpointResourceDataflowEndpointApiVersion); + _dataflowEndpointResourceDataflowEndpointRestClient = new DataflowEndpointRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, dataflowEndpointResourceDataflowEndpointApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != InstanceResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, InstanceResource.ResourceType), nameof(id)); + } + + /// + /// Create a DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance dataflowEndpoint 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 dataflowEndpointName, DataflowEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _dataflowEndpointResourceDataflowEndpointRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new DataflowEndpointResourceOperationSource(Client), _dataflowEndpointResourceDataflowEndpointClientDiagnostics, Pipeline, _dataflowEndpointResourceDataflowEndpointRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, 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 DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance dataflowEndpoint 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 dataflowEndpointName, DataflowEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _dataflowEndpointResourceDataflowEndpointRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new DataflowEndpointResourceOperationSource(Client), _dataflowEndpointResourceDataflowEndpointClientDiagnostics, Pipeline, _dataflowEndpointResourceDataflowEndpointRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowEndpoint 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 dataflowEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResourceCollection.Get"); + scope.Start(); + try + { + var response = await _dataflowEndpointResourceDataflowEndpointRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DataflowEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowEndpoint resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string dataflowEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResourceCollection.Get"); + scope.Start(); + try + { + var response = _dataflowEndpointResourceDataflowEndpointRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DataflowEndpointResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List DataflowEndpointResource resources by InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints + /// + /// + /// Operation Id + /// DataflowEndpointResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _dataflowEndpointResourceDataflowEndpointRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dataflowEndpointResourceDataflowEndpointRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DataflowEndpointResource(Client, DataflowEndpointResourceData.DeserializeDataflowEndpointResourceData(e)), _dataflowEndpointResourceDataflowEndpointClientDiagnostics, Pipeline, "DataflowEndpointResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List DataflowEndpointResource resources by InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints + /// + /// + /// Operation Id + /// DataflowEndpointResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _dataflowEndpointResourceDataflowEndpointRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dataflowEndpointResourceDataflowEndpointRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DataflowEndpointResource(Client, DataflowEndpointResourceData.DeserializeDataflowEndpointResourceData(e)), _dataflowEndpointResourceDataflowEndpointClientDiagnostics, Pipeline, "DataflowEndpointResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowEndpoint 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 dataflowEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _dataflowEndpointResourceDataflowEndpointRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, 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.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowEndpoint resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string dataflowEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResourceCollection.Exists"); + scope.Start(); + try + { + var response = _dataflowEndpointResourceDataflowEndpointRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, 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.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowEndpoint 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 dataflowEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _dataflowEndpointResourceDataflowEndpointRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new DataflowEndpointResource(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.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowEndpoint resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string dataflowEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + + using var scope = _dataflowEndpointResourceDataflowEndpointClientDiagnostics.CreateScope("DataflowEndpointResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _dataflowEndpointResourceDataflowEndpointRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new DataflowEndpointResource(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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceData.Serialization.cs new file mode 100644 index 000000000000..be6f6ef64ed1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceData.Serialization.cs @@ -0,0 +1,191 @@ +// 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; +using Azure.ResourceManager.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + public partial class DataflowEndpointResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointResourceData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointResourceData 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(DataflowEndpointResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointResourceData(document.RootElement, options); + } + + internal static DataflowEndpointResourceData DeserializeDataflowEndpointResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowEndpointProperties properties = default; + ExtendedLocation extendedLocation = 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 = DataflowEndpointProperties.DeserializeDataflowEndpointProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = ExtendedLocation.DeserializeExtendedLocation(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 = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointResourceData( + id, + name, + type, + systemData, + properties, + extendedLocation, + 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointResourceData)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointResourceData 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); + return DeserializeDataflowEndpointResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceData.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceData.cs new file mode 100644 index 000000000000..1ec697dfac10 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowEndpointResourceData.cs @@ -0,0 +1,89 @@ +// 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.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A class representing the DataflowEndpointResource data model. + /// Instance dataflowEndpoint resource + /// + public partial class DataflowEndpointResourceData : 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 . + /// Edge location of the resource. + /// is null. + public DataflowEndpointResourceData(ExtendedLocation extendedLocation) + { + Argument.AssertNotNull(extendedLocation, nameof(extendedLocation)); + + ExtendedLocation = extendedLocation; + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, DataflowEndpointProperties properties, ExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointResourceData() + { + } + + /// The resource-specific properties for this resource. + public DataflowEndpointProperties Properties { get; set; } + /// Edge location of the resource. + public ExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResource.Serialization.cs new file mode 100644 index 000000000000..fb34f9925a03 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.IoTOperations +{ + public partial class DataflowProfileResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + DataflowProfileResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + DataflowProfileResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResource.cs new file mode 100644 index 000000000000..16fd43b297a2 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResource.cs @@ -0,0 +1,416 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A Class representing a DataflowProfileResource 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 GetDataflowProfileResource method. + /// Otherwise you can get one from its parent resource using the GetDataflowProfileResource method. + /// + public partial class DataflowProfileResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The instanceName. + /// The dataflowProfileName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _dataflowProfileResourceDataflowProfileClientDiagnostics; + private readonly DataflowProfileRestOperations _dataflowProfileResourceDataflowProfileRestClient; + private readonly DataflowProfileResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.IoTOperations/instances/dataflowProfiles"; + + /// Initializes a new instance of the class for mocking. + protected DataflowProfileResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal DataflowProfileResource(ArmClient client, DataflowProfileResourceData 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 DataflowProfileResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _dataflowProfileResourceDataflowProfileClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string dataflowProfileResourceDataflowProfileApiVersion); + _dataflowProfileResourceDataflowProfileRestClient = new DataflowProfileRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, dataflowProfileResourceDataflowProfileApiVersion); +#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 DataflowProfileResourceData 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 DataflowResources in the DataflowProfileResource. + /// An object representing collection of DataflowResources and their operations over a DataflowResource. + public virtual DataflowResourceCollection GetDataflowResources() + { + return GetCachedClient(client => new DataflowResourceCollection(client, Id)); + } + + /// + /// Get a DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile dataflow resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDataflowResourceAsync(string dataflowName, CancellationToken cancellationToken = default) + { + return await GetDataflowResources().GetAsync(dataflowName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile dataflow resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDataflowResource(string dataflowName, CancellationToken cancellationToken = default) + { + return GetDataflowResources().Get(dataflowName, cancellationToken); + } + + /// + /// Get a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResource.Get"); + scope.Start(); + try + { + var response = await _dataflowProfileResourceDataflowProfileRestClient.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 DataflowProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResource.Get"); + scope.Start(); + try + { + var response = _dataflowProfileResourceDataflowProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DataflowProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResource.Delete"); + scope.Start(); + try + { + var response = await _dataflowProfileResourceDataflowProfileRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(_dataflowProfileResourceDataflowProfileClientDiagnostics, Pipeline, _dataflowProfileResourceDataflowProfileRestClient.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 DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResource.Delete"); + scope.Start(); + try + { + var response = _dataflowProfileResourceDataflowProfileRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IoTOperationsArmOperation(_dataflowProfileResourceDataflowProfileClientDiagnostics, Pipeline, _dataflowProfileResourceDataflowProfileRestClient.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; + } + } + + /// + /// Create a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DataflowProfileResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResource.Update"); + scope.Start(); + try + { + var response = await _dataflowProfileResourceDataflowProfileRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new DataflowProfileResourceOperationSource(Client), _dataflowProfileResourceDataflowProfileClientDiagnostics, Pipeline, _dataflowProfileResourceDataflowProfileRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, 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 DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, DataflowProfileResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResource.Update"); + scope.Start(); + try + { + var response = _dataflowProfileResourceDataflowProfileRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new DataflowProfileResourceOperationSource(Client), _dataflowProfileResourceDataflowProfileClientDiagnostics, Pipeline, _dataflowProfileResourceDataflowProfileRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceCollection.cs new file mode 100644 index 000000000000..55224388c46d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceCollection.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.IoTOperations +{ + /// + /// 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 GetDataflowProfileResources method from an instance of . + /// + public partial class DataflowProfileResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _dataflowProfileResourceDataflowProfileClientDiagnostics; + private readonly DataflowProfileRestOperations _dataflowProfileResourceDataflowProfileRestClient; + + /// Initializes a new instance of the class for mocking. + protected DataflowProfileResourceCollection() + { + } + + /// 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 DataflowProfileResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _dataflowProfileResourceDataflowProfileClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", DataflowProfileResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(DataflowProfileResource.ResourceType, out string dataflowProfileResourceDataflowProfileApiVersion); + _dataflowProfileResourceDataflowProfileRestClient = new DataflowProfileRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, dataflowProfileResourceDataflowProfileApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != InstanceResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, InstanceResource.ResourceType), nameof(id)); + } + + /// + /// Create a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance dataflowProfile 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 dataflowProfileName, DataflowProfileResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _dataflowProfileResourceDataflowProfileRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new DataflowProfileResourceOperationSource(Client), _dataflowProfileResourceDataflowProfileClientDiagnostics, Pipeline, _dataflowProfileResourceDataflowProfileRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, 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 DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance dataflowProfile 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 dataflowProfileName, DataflowProfileResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _dataflowProfileResourceDataflowProfileRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new DataflowProfileResourceOperationSource(Client), _dataflowProfileResourceDataflowProfileClientDiagnostics, Pipeline, _dataflowProfileResourceDataflowProfileRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile 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 dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResourceCollection.Get"); + scope.Start(); + try + { + var response = await _dataflowProfileResourceDataflowProfileRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DataflowProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResourceCollection.Get"); + scope.Start(); + try + { + var response = _dataflowProfileResourceDataflowProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DataflowProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List DataflowProfileResource resources by InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles + /// + /// + /// Operation Id + /// DataflowProfileResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _dataflowProfileResourceDataflowProfileRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dataflowProfileResourceDataflowProfileRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DataflowProfileResource(Client, DataflowProfileResourceData.DeserializeDataflowProfileResourceData(e)), _dataflowProfileResourceDataflowProfileClientDiagnostics, Pipeline, "DataflowProfileResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List DataflowProfileResource resources by InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles + /// + /// + /// Operation Id + /// DataflowProfileResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _dataflowProfileResourceDataflowProfileRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dataflowProfileResourceDataflowProfileRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DataflowProfileResource(Client, DataflowProfileResourceData.DeserializeDataflowProfileResourceData(e)), _dataflowProfileResourceDataflowProfileClientDiagnostics, Pipeline, "DataflowProfileResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile 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 dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _dataflowProfileResourceDataflowProfileRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, 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.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResourceCollection.Exists"); + scope.Start(); + try + { + var response = _dataflowProfileResourceDataflowProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, 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.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile 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 dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _dataflowProfileResourceDataflowProfileRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new DataflowProfileResource(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.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var scope = _dataflowProfileResourceDataflowProfileClientDiagnostics.CreateScope("DataflowProfileResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _dataflowProfileResourceDataflowProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new DataflowProfileResource(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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceData.Serialization.cs new file mode 100644 index 000000000000..39f9ab94b26f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceData.Serialization.cs @@ -0,0 +1,191 @@ +// 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; +using Azure.ResourceManager.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + public partial class DataflowProfileResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowProfileResourceData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowProfileResourceData 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(DataflowProfileResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowProfileResourceData(document.RootElement, options); + } + + internal static DataflowProfileResourceData DeserializeDataflowProfileResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowProfileProperties properties = default; + ExtendedLocation extendedLocation = 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 = DataflowProfileProperties.DeserializeDataflowProfileProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = ExtendedLocation.DeserializeExtendedLocation(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 = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowProfileResourceData( + id, + name, + type, + systemData, + properties, + extendedLocation, + 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); + default: + throw new FormatException($"The model {nameof(DataflowProfileResourceData)} does not support writing '{options.Format}' format."); + } + } + + DataflowProfileResourceData 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); + return DeserializeDataflowProfileResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowProfileResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceData.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceData.cs new file mode 100644 index 000000000000..84ffbdd6b712 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowProfileResourceData.cs @@ -0,0 +1,89 @@ +// 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.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A class representing the DataflowProfileResource data model. + /// Instance dataflowProfile resource + /// + public partial class DataflowProfileResourceData : 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 . + /// Edge location of the resource. + /// is null. + public DataflowProfileResourceData(ExtendedLocation extendedLocation) + { + Argument.AssertNotNull(extendedLocation, nameof(extendedLocation)); + + ExtendedLocation = extendedLocation; + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// Keeps track of any properties unknown to the library. + internal DataflowProfileResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, DataflowProfileProperties properties, ExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowProfileResourceData() + { + } + + /// The resource-specific properties for this resource. + public DataflowProfileProperties Properties { get; set; } + /// Edge location of the resource. + public ExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResource.Serialization.cs new file mode 100644 index 000000000000..fc198d94f68a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.IoTOperations +{ + public partial class DataflowResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + DataflowResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + DataflowResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResource.cs new file mode 100644 index 000000000000..be2cf1af50c1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResource.cs @@ -0,0 +1,348 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A Class representing a DataflowResource 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 GetDataflowResource method. + /// Otherwise you can get one from its parent resource using the GetDataflowResource method. + /// + public partial class DataflowResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The instanceName. + /// The dataflowProfileName. + /// The dataflowName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName, string dataflowName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _dataflowResourceDataflowClientDiagnostics; + private readonly DataflowRestOperations _dataflowResourceDataflowRestClient; + private readonly DataflowResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.IoTOperations/instances/dataflowProfiles/dataflows"; + + /// Initializes a new instance of the class for mocking. + protected DataflowResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal DataflowResource(ArmClient client, DataflowResourceData 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 DataflowResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _dataflowResourceDataflowClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string dataflowResourceDataflowApiVersion); + _dataflowResourceDataflowRestClient = new DataflowRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, dataflowResourceDataflowApiVersion); +#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 DataflowResourceData 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 DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResource.Get"); + scope.Start(); + try + { + var response = await _dataflowResourceDataflowRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DataflowResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResource.Get"); + scope.Start(); + try + { + var response = _dataflowResourceDataflowRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DataflowResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResource.Delete"); + scope.Start(); + try + { + var response = await _dataflowResourceDataflowRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(_dataflowResourceDataflowClientDiagnostics, Pipeline, _dataflowResourceDataflowRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, 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 DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResource.Delete"); + scope.Start(); + try + { + var response = _dataflowResourceDataflowRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IoTOperationsArmOperation(_dataflowResourceDataflowClientDiagnostics, Pipeline, _dataflowResourceDataflowRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, 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; + } + } + + /// + /// Create a DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DataflowResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResource.Update"); + scope.Start(); + try + { + var response = await _dataflowResourceDataflowRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new DataflowResourceOperationSource(Client), _dataflowResourceDataflowClientDiagnostics, Pipeline, _dataflowResourceDataflowRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, 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 DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, DataflowResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResource.Update"); + scope.Start(); + try + { + var response = _dataflowResourceDataflowRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new DataflowResourceOperationSource(Client), _dataflowResourceDataflowClientDiagnostics, Pipeline, _dataflowResourceDataflowRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceCollection.cs new file mode 100644 index 000000000000..87f88cc47fbc --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceCollection.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.IoTOperations +{ + /// + /// 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 GetDataflowResources method from an instance of . + /// + public partial class DataflowResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _dataflowResourceDataflowClientDiagnostics; + private readonly DataflowRestOperations _dataflowResourceDataflowRestClient; + + /// Initializes a new instance of the class for mocking. + protected DataflowResourceCollection() + { + } + + /// 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 DataflowResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _dataflowResourceDataflowClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", DataflowResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(DataflowResource.ResourceType, out string dataflowResourceDataflowApiVersion); + _dataflowResourceDataflowRestClient = new DataflowRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, dataflowResourceDataflowApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != DataflowProfileResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DataflowProfileResource.ResourceType), nameof(id)); + } + + /// + /// Create a DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance dataflowProfile dataflow 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 dataflowName, DataflowResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _dataflowResourceDataflowRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new DataflowResourceOperationSource(Client), _dataflowResourceDataflowClientDiagnostics, Pipeline, _dataflowResourceDataflowRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, 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 DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of Instance dataflowProfile dataflow 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 dataflowName, DataflowResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _dataflowResourceDataflowRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new DataflowResourceOperationSource(Client), _dataflowResourceDataflowClientDiagnostics, Pipeline, _dataflowResourceDataflowRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile dataflow 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 dataflowName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResourceCollection.Get"); + scope.Start(); + try + { + var response = await _dataflowResourceDataflowRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DataflowResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile dataflow resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string dataflowName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResourceCollection.Get"); + scope.Start(); + try + { + var response = _dataflowResourceDataflowRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DataflowResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List DataflowResource resources by DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows + /// + /// + /// Operation Id + /// DataflowResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _dataflowResourceDataflowRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dataflowResourceDataflowRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DataflowResource(Client, DataflowResourceData.DeserializeDataflowResourceData(e)), _dataflowResourceDataflowClientDiagnostics, Pipeline, "DataflowResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List DataflowResource resources by DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows + /// + /// + /// Operation Id + /// DataflowResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _dataflowResourceDataflowRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dataflowResourceDataflowRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DataflowResource(Client, DataflowResourceData.DeserializeDataflowResourceData(e)), _dataflowResourceDataflowClientDiagnostics, Pipeline, "DataflowResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile dataflow 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 dataflowName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _dataflowResourceDataflowRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, 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.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile dataflow resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string dataflowName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResourceCollection.Exists"); + scope.Start(); + try + { + var response = _dataflowResourceDataflowRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, 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.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile dataflow 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 dataflowName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _dataflowResourceDataflowRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new DataflowResource(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.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// Dataflow_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile dataflow resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string dataflowName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + + using var scope = _dataflowResourceDataflowClientDiagnostics.CreateScope("DataflowResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _dataflowResourceDataflowRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new DataflowResource(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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceData.Serialization.cs new file mode 100644 index 000000000000..df71438827c4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceData.Serialization.cs @@ -0,0 +1,191 @@ +// 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; +using Azure.ResourceManager.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + public partial class DataflowResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowResourceData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowResourceData 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(DataflowResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowResourceData(document.RootElement, options); + } + + internal static DataflowResourceData DeserializeDataflowResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowProperties properties = default; + ExtendedLocation extendedLocation = 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 = DataflowProperties.DeserializeDataflowProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = ExtendedLocation.DeserializeExtendedLocation(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 = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowResourceData( + id, + name, + type, + systemData, + properties, + extendedLocation, + 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); + default: + throw new FormatException($"The model {nameof(DataflowResourceData)} does not support writing '{options.Format}' format."); + } + } + + DataflowResourceData 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); + return DeserializeDataflowResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceData.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceData.cs new file mode 100644 index 000000000000..13f7d477956c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/DataflowResourceData.cs @@ -0,0 +1,89 @@ +// 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.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A class representing the DataflowResource data model. + /// Instance dataflowProfile dataflow resource + /// + public partial class DataflowResourceData : 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 . + /// Edge location of the resource. + /// is null. + public DataflowResourceData(ExtendedLocation extendedLocation) + { + Argument.AssertNotNull(extendedLocation, nameof(extendedLocation)); + + ExtendedLocation = extendedLocation; + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// Keeps track of any properties unknown to the library. + internal DataflowResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, DataflowProperties properties, ExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowResourceData() + { + } + + /// The resource-specific properties for this resource. + public DataflowProperties Properties { get; set; } + /// Edge location of the resource. + public ExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/IoTOperationsExtensions.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/IoTOperationsExtensions.cs new file mode 100644 index 000000000000..2e770ef0c03a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/IoTOperationsExtensions.cs @@ -0,0 +1,422 @@ +// 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.IoTOperations.Mocking; +using Azure.ResourceManager.IoTOperations.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.IoTOperations +{ + /// A class to add extension methods to Azure.ResourceManager.IoTOperations. + public static partial class IoTOperationsExtensions + { + private static MockableIoTOperationsArmClient GetMockableIoTOperationsArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableIoTOperationsArmClient(client0)); + } + + private static MockableIoTOperationsResourceGroupResource GetMockableIoTOperationsResourceGroupResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableIoTOperationsResourceGroupResource(client, resource.Id)); + } + + private static MockableIoTOperationsSubscriptionResource GetMockableIoTOperationsSubscriptionResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableIoTOperationsSubscriptionResource(client, resource.Id)); + } + + private static MockableIoTOperationsTenantResource GetMockableIoTOperationsTenantResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableIoTOperationsTenantResource(client, resource.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 InstanceResource GetInstanceResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIoTOperationsArmClient(client).GetInstanceResource(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 BrokerResource GetBrokerResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIoTOperationsArmClient(client).GetBrokerResource(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 BrokerListenerResource GetBrokerListenerResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIoTOperationsArmClient(client).GetBrokerListenerResource(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 BrokerAuthenticationResource GetBrokerAuthenticationResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIoTOperationsArmClient(client).GetBrokerAuthenticationResource(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 BrokerAuthorizationResource GetBrokerAuthorizationResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIoTOperationsArmClient(client).GetBrokerAuthorizationResource(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 DataflowProfileResource GetDataflowProfileResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIoTOperationsArmClient(client).GetDataflowProfileResource(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 DataflowResource GetDataflowResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIoTOperationsArmClient(client).GetDataflowResource(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 DataflowEndpointResource GetDataflowEndpointResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIoTOperationsArmClient(client).GetDataflowEndpointResource(id); + } + + /// + /// Gets a collection of InstanceResources 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 InstanceResources and their operations over a InstanceResource. + public static InstanceResourceCollection GetInstanceResources(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableIoTOperationsResourceGroupResource(resourceGroupResource).GetInstanceResources(); + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of instance. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetInstanceResourceAsync(this ResourceGroupResource resourceGroupResource, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableIoTOperationsResourceGroupResource(resourceGroupResource).GetInstanceResourceAsync(instanceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of instance. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetInstanceResource(this ResourceGroupResource resourceGroupResource, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableIoTOperationsResourceGroupResource(resourceGroupResource).GetInstanceResource(instanceName, cancellationToken); + } + + /// + /// List InstanceResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.IoTOperations/instances + /// + /// + /// Operation Id + /// InstanceResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-08-15-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 GetInstanceResourcesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableIoTOperationsSubscriptionResource(subscriptionResource).GetInstanceResourcesAsync(cancellationToken); + } + + /// + /// List InstanceResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.IoTOperations/instances + /// + /// + /// Operation Id + /// InstanceResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-08-15-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 GetInstanceResources(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableIoTOperationsSubscriptionResource(subscriptionResource).GetInstanceResources(cancellationToken); + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.IoTOperations/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// 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 GetOperationsAsync(this TenantResource tenantResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableIoTOperationsTenantResource(tenantResource).GetOperationsAsync(cancellationToken); + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.IoTOperations/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// 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 GetOperations(this TenantResource tenantResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableIoTOperationsTenantResource(tenantResource).GetOperations(cancellationToken); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsArmClient.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsArmClient.cs new file mode 100644 index 000000000000..00ca2a20d7e9 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsArmClient.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; + +namespace Azure.ResourceManager.IoTOperations.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableIoTOperationsArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableIoTOperationsArmClient() + { + } + + /// 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 MockableIoTOperationsArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableIoTOperationsArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 InstanceResource GetInstanceResource(ResourceIdentifier id) + { + InstanceResource.ValidateResourceId(id); + return new InstanceResource(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 BrokerResource GetBrokerResource(ResourceIdentifier id) + { + BrokerResource.ValidateResourceId(id); + return new BrokerResource(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 BrokerListenerResource GetBrokerListenerResource(ResourceIdentifier id) + { + BrokerListenerResource.ValidateResourceId(id); + return new BrokerListenerResource(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 BrokerAuthenticationResource GetBrokerAuthenticationResource(ResourceIdentifier id) + { + BrokerAuthenticationResource.ValidateResourceId(id); + return new BrokerAuthenticationResource(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 BrokerAuthorizationResource GetBrokerAuthorizationResource(ResourceIdentifier id) + { + BrokerAuthorizationResource.ValidateResourceId(id); + return new BrokerAuthorizationResource(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 DataflowProfileResource GetDataflowProfileResource(ResourceIdentifier id) + { + DataflowProfileResource.ValidateResourceId(id); + return new DataflowProfileResource(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 DataflowResource GetDataflowResource(ResourceIdentifier id) + { + DataflowResource.ValidateResourceId(id); + return new DataflowResource(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 DataflowEndpointResource GetDataflowEndpointResource(ResourceIdentifier id) + { + DataflowEndpointResource.ValidateResourceId(id); + return new DataflowEndpointResource(Client, id); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsResourceGroupResource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsResourceGroupResource.cs new file mode 100644 index 000000000000..0bb34d6aa36b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsResourceGroupResource.cs @@ -0,0 +1,105 @@ +// 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.IoTOperations.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableIoTOperationsResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableIoTOperationsResourceGroupResource() + { + } + + /// 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 MockableIoTOperationsResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of InstanceResources in the ResourceGroupResource. + /// An object representing collection of InstanceResources and their operations over a InstanceResource. + public virtual InstanceResourceCollection GetInstanceResources() + { + return GetCachedClient(client => new InstanceResourceCollection(client, Id)); + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of instance. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetInstanceResourceAsync(string instanceName, CancellationToken cancellationToken = default) + { + return await GetInstanceResources().GetAsync(instanceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of instance. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetInstanceResource(string instanceName, CancellationToken cancellationToken = default) + { + return GetInstanceResources().Get(instanceName, cancellationToken); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsSubscriptionResource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsSubscriptionResource.cs new file mode 100644 index 000000000000..31e628bffff2 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsSubscriptionResource.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.IoTOperations.Mocking +{ + /// A class to add extension methods to SubscriptionResource. + public partial class MockableIoTOperationsSubscriptionResource : ArmResource + { + private ClientDiagnostics _instanceResourceInstanceClientDiagnostics; + private InstanceRestOperations _instanceResourceInstanceRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableIoTOperationsSubscriptionResource() + { + } + + /// 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 MockableIoTOperationsSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics InstanceResourceInstanceClientDiagnostics => _instanceResourceInstanceClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.IoTOperations", InstanceResource.ResourceType.Namespace, Diagnostics); + private InstanceRestOperations InstanceResourceInstanceRestClient => _instanceResourceInstanceRestClient ??= new InstanceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(InstanceResource.ResourceType)); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// List InstanceResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.IoTOperations/instances + /// + /// + /// Operation Id + /// InstanceResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetInstanceResourcesAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => InstanceResourceInstanceRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => InstanceResourceInstanceRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new InstanceResource(Client, InstanceResourceData.DeserializeInstanceResourceData(e)), InstanceResourceInstanceClientDiagnostics, Pipeline, "MockableIoTOperationsSubscriptionResource.GetInstanceResources", "value", "nextLink", cancellationToken); + } + + /// + /// List InstanceResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.IoTOperations/instances + /// + /// + /// Operation Id + /// InstanceResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetInstanceResources(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => InstanceResourceInstanceRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => InstanceResourceInstanceRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new InstanceResource(Client, InstanceResourceData.DeserializeInstanceResourceData(e)), InstanceResourceInstanceClientDiagnostics, Pipeline, "MockableIoTOperationsSubscriptionResource.GetInstanceResources", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsTenantResource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsTenantResource.cs new file mode 100644 index 000000000000..1068ab6b6c7e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Extensions/MockableIoTOperationsTenantResource.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.IoTOperations.Models; + +namespace Azure.ResourceManager.IoTOperations.Mocking +{ + /// A class to add extension methods to TenantResource. + public partial class MockableIoTOperationsTenantResource : ArmResource + { + private ClientDiagnostics _operationsClientDiagnostics; + private OperationsRestOperations _operationsRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableIoTOperationsTenantResource() + { + } + + /// 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 MockableIoTOperationsTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics OperationsClientDiagnostics => _operationsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.IoTOperations", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private OperationsRestOperations OperationsRestClient => _operationsRestClient ??= new OperationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.IoTOperations/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetOperationsAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => OperationsRestClient.CreateListRequest(); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OperationsRestClient.CreateListNextPageRequest(nextLink); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Models.Operation.DeserializeOperation(e), OperationsClientDiagnostics, Pipeline, "MockableIoTOperationsTenantResource.GetOperations", "value", "nextLink", cancellationToken); + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.IoTOperations/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetOperations(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => OperationsRestClient.CreateListRequest(); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OperationsRestClient.CreateListNextPageRequest(nextLink); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Models.Operation.DeserializeOperation(e), OperationsClientDiagnostics, Pipeline, "MockableIoTOperationsTenantResource.GetOperations", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResource.Serialization.cs new file mode 100644 index 000000000000..2daa5a465cdc --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.IoTOperations +{ + public partial class InstanceResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + InstanceResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + InstanceResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResource.cs new file mode 100644 index 000000000000..8362581bc533 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResource.cs @@ -0,0 +1,906 @@ +// 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.IoTOperations.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A Class representing an InstanceResource 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 GetInstanceResource method. + /// Otherwise you can get one from its parent resource using the GetInstanceResource method. + /// + public partial class InstanceResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The instanceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string instanceName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _instanceResourceInstanceClientDiagnostics; + private readonly InstanceRestOperations _instanceResourceInstanceRestClient; + private readonly InstanceResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.IoTOperations/instances"; + + /// Initializes a new instance of the class for mocking. + protected InstanceResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal InstanceResource(ArmClient client, InstanceResourceData 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 InstanceResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _instanceResourceInstanceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string instanceResourceInstanceApiVersion); + _instanceResourceInstanceRestClient = new InstanceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, instanceResourceInstanceApiVersion); +#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 InstanceResourceData 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 BrokerResources in the InstanceResource. + /// An object representing collection of BrokerResources and their operations over a BrokerResource. + public virtual BrokerResourceCollection GetBrokerResources() + { + return GetCachedClient(client => new BrokerResourceCollection(client, Id)); + } + + /// + /// Get a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of broker. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetBrokerResourceAsync(string brokerName, CancellationToken cancellationToken = default) + { + return await GetBrokerResources().GetAsync(brokerName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// Broker_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of broker. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetBrokerResource(string brokerName, CancellationToken cancellationToken = default) + { + return GetBrokerResources().Get(brokerName, cancellationToken); + } + + /// Gets a collection of DataflowProfileResources in the InstanceResource. + /// An object representing collection of DataflowProfileResources and their operations over a DataflowProfileResource. + public virtual DataflowProfileResourceCollection GetDataflowProfileResources() + { + return GetCachedClient(client => new DataflowProfileResourceCollection(client, Id)); + } + + /// + /// Get a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDataflowProfileResourceAsync(string dataflowProfileName, CancellationToken cancellationToken = default) + { + return await GetDataflowProfileResources().GetAsync(dataflowProfileName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfile_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowProfile resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDataflowProfileResource(string dataflowProfileName, CancellationToken cancellationToken = default) + { + return GetDataflowProfileResources().Get(dataflowProfileName, cancellationToken); + } + + /// Gets a collection of DataflowEndpointResources in the InstanceResource. + /// An object representing collection of DataflowEndpointResources and their operations over a DataflowEndpointResource. + public virtual DataflowEndpointResourceCollection GetDataflowEndpointResources() + { + return GetCachedClient(client => new DataflowEndpointResourceCollection(client, Id)); + } + + /// + /// Get a DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowEndpoint resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDataflowEndpointResourceAsync(string dataflowEndpointName, CancellationToken cancellationToken = default) + { + return await GetDataflowEndpointResources().GetAsync(dataflowEndpointName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpoint_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Instance dataflowEndpoint resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDataflowEndpointResource(string dataflowEndpointName, CancellationToken cancellationToken = default) + { + return GetDataflowEndpointResources().Get(dataflowEndpointName, cancellationToken); + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.Get"); + scope.Start(); + try + { + var response = await _instanceResourceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new InstanceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.Get"); + scope.Start(); + try + { + var response = _instanceResourceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new InstanceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.Delete"); + scope.Start(); + try + { + var response = await _instanceResourceInstanceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(_instanceResourceInstanceClientDiagnostics, Pipeline, _instanceResourceInstanceRestClient.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 InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Delete + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.Delete"); + scope.Start(); + try + { + var response = _instanceResourceInstanceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new IoTOperationsArmOperation(_instanceResourceInstanceClientDiagnostics, Pipeline, _instanceResourceInstanceRestClient.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 InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Update + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(InstanceResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.Update"); + scope.Start(); + try + { + var response = await _instanceResourceInstanceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new InstanceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Update + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(InstanceResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.Update"); + scope.Start(); + try + { + var response = _instanceResourceInstanceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + return Response.FromValue(new InstanceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.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 _instanceResourceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new InstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new InstanceResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.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 = _instanceResourceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new InstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new InstanceResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + 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.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.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 _instanceResourceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new InstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new InstanceResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + 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.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.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 = _instanceResourceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new InstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new InstanceResourcePatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.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 _instanceResourceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new InstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new InstanceResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-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 = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResource.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 = _instanceResourceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new InstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new InstanceResourcePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceCollection.cs new file mode 100644 index 000000000000..741e1c9dbc12 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceCollection.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.IoTOperations +{ + /// + /// 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 GetInstanceResources method from an instance of . + /// + public partial class InstanceResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _instanceResourceInstanceClientDiagnostics; + private readonly InstanceRestOperations _instanceResourceInstanceRestClient; + + /// Initializes a new instance of the class for mocking. + protected InstanceResourceCollection() + { + } + + /// 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 InstanceResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _instanceResourceInstanceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IoTOperations", InstanceResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(InstanceResource.ResourceType, out string instanceResourceInstanceApiVersion); + _instanceResourceInstanceRestClient = new InstanceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, instanceResourceInstanceApiVersion); +#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 InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of instance. + /// 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 instanceName, InstanceResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _instanceResourceInstanceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, instanceName, data, cancellationToken).ConfigureAwait(false); + var operation = new IoTOperationsArmOperation(new InstanceResourceOperationSource(Client), _instanceResourceInstanceClientDiagnostics, Pipeline, _instanceResourceInstanceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, instanceName, 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 InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-08-15-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. + /// Name of instance. + /// 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 instanceName, InstanceResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _instanceResourceInstanceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, instanceName, data, cancellationToken); + var operation = new IoTOperationsArmOperation(new InstanceResourceOperationSource(Client), _instanceResourceInstanceClientDiagnostics, Pipeline, _instanceResourceInstanceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, instanceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of instance. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResourceCollection.Get"); + scope.Start(); + try + { + var response = await _instanceResourceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, instanceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new InstanceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of instance. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResourceCollection.Get"); + scope.Start(); + try + { + var response = _instanceResourceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, instanceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new InstanceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List InstanceResource resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances + /// + /// + /// Operation Id + /// InstanceResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _instanceResourceInstanceRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _instanceResourceInstanceRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new InstanceResource(Client, InstanceResourceData.DeserializeInstanceResourceData(e)), _instanceResourceInstanceClientDiagnostics, Pipeline, "InstanceResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List InstanceResource resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances + /// + /// + /// Operation Id + /// InstanceResource_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-08-15-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) => _instanceResourceInstanceRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _instanceResourceInstanceRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new InstanceResource(Client, InstanceResourceData.DeserializeInstanceResourceData(e)), _instanceResourceInstanceClientDiagnostics, Pipeline, "InstanceResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of instance. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _instanceResourceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, instanceName, 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.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of instance. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResourceCollection.Exists"); + scope.Start(); + try + { + var response = _instanceResourceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, instanceName, 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.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of instance. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _instanceResourceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, instanceName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new InstanceResource(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.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// Instance_Get + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of instance. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var scope = _instanceResourceInstanceClientDiagnostics.CreateScope("InstanceResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _instanceResourceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, instanceName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new InstanceResource(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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceData.Serialization.cs new file mode 100644 index 000000000000..82931e4ce59c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceData.Serialization.cs @@ -0,0 +1,245 @@ +// 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; +using Azure.ResourceManager.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + public partial class InstanceResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InstanceResourceData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + JsonSerializer.Serialize(writer, Identity, serializeOptions); + } + 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(); + } + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InstanceResourceData 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(InstanceResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInstanceResourceData(document.RootElement, options); + } + + internal static InstanceResourceData DeserializeInstanceResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InstanceProperties properties = default; + ExtendedLocation extendedLocation = 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 = InstanceProperties.DeserializeInstanceProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = ExtendedLocation.DeserializeExtendedLocation(property.Value, options); + continue; + } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + 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 = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InstanceResourceData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + extendedLocation, + 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); + default: + throw new FormatException($"The model {nameof(InstanceResourceData)} does not support writing '{options.Format}' format."); + } + } + + InstanceResourceData 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); + return DeserializeInstanceResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InstanceResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceData.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceData.cs new file mode 100644 index 000000000000..dc09f776f48e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/InstanceResourceData.cs @@ -0,0 +1,96 @@ +// 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.IoTOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + /// + /// A class representing the InstanceResource data model. + /// A Instance resource is a logical container for a set of child resources. + /// + public partial class InstanceResourceData : 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. + /// Edge location of the resource. + /// is null. + public InstanceResourceData(AzureLocation location, ExtendedLocation extendedLocation) : base(location) + { + Argument.AssertNotNull(extendedLocation, nameof(extendedLocation)); + + ExtendedLocation = extendedLocation; + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// Edge location of the resource. + /// The managed service identities assigned to this resource. + /// Keeps track of any properties unknown to the library. + internal InstanceResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, InstanceProperties properties, ExtendedLocation extendedLocation, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Properties = properties; + ExtendedLocation = extendedLocation; + Identity = identity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InstanceResourceData() + { + } + + /// The resource-specific properties for this resource. + public InstanceProperties Properties { get; set; } + /// Edge location of the resource. + public ExtendedLocation ExtendedLocation { get; set; } + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/Argument.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..0ec4444a51f6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/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.IoTOperations +{ + 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..4b585e4ae23c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/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.IoTOperations +{ + 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/ChangeTrackingList.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..dec119e3255e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/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.IoTOperations +{ + 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..6239700cd422 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,398 @@ +// 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.IoTOperations +{ + internal static class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + 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 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/Optional.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..2f37e2116697 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/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.IoTOperations +{ + 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..a829e34d2020 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/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.IoTOperations +{ + 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerAuthenticationResourceOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerAuthenticationResourceOperationSource.cs new file mode 100644 index 000000000000..b8f106f34973 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerAuthenticationResourceOperationSource.cs @@ -0,0 +1,38 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + internal class BrokerAuthenticationResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal BrokerAuthenticationResourceOperationSource(ArmClient client) + { + _client = client; + } + + BrokerAuthenticationResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = BrokerAuthenticationResourceData.DeserializeBrokerAuthenticationResourceData(document.RootElement); + return new BrokerAuthenticationResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = BrokerAuthenticationResourceData.DeserializeBrokerAuthenticationResourceData(document.RootElement); + return new BrokerAuthenticationResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerAuthorizationResourceOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerAuthorizationResourceOperationSource.cs new file mode 100644 index 000000000000..5312441a1085 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerAuthorizationResourceOperationSource.cs @@ -0,0 +1,38 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + internal class BrokerAuthorizationResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal BrokerAuthorizationResourceOperationSource(ArmClient client) + { + _client = client; + } + + BrokerAuthorizationResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = BrokerAuthorizationResourceData.DeserializeBrokerAuthorizationResourceData(document.RootElement); + return new BrokerAuthorizationResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = BrokerAuthorizationResourceData.DeserializeBrokerAuthorizationResourceData(document.RootElement); + return new BrokerAuthorizationResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerListenerResourceOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerListenerResourceOperationSource.cs new file mode 100644 index 000000000000..c2d9454983fc --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerListenerResourceOperationSource.cs @@ -0,0 +1,38 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + internal class BrokerListenerResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal BrokerListenerResourceOperationSource(ArmClient client) + { + _client = client; + } + + BrokerListenerResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = BrokerListenerResourceData.DeserializeBrokerListenerResourceData(document.RootElement); + return new BrokerListenerResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = BrokerListenerResourceData.DeserializeBrokerListenerResourceData(document.RootElement); + return new BrokerListenerResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerResourceOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerResourceOperationSource.cs new file mode 100644 index 000000000000..59d7a6f98f32 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/BrokerResourceOperationSource.cs @@ -0,0 +1,38 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + internal class BrokerResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal BrokerResourceOperationSource(ArmClient client) + { + _client = client; + } + + BrokerResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = BrokerResourceData.DeserializeBrokerResourceData(document.RootElement); + return new BrokerResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = BrokerResourceData.DeserializeBrokerResourceData(document.RootElement); + return new BrokerResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowEndpointResourceOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowEndpointResourceOperationSource.cs new file mode 100644 index 000000000000..e90184329f66 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowEndpointResourceOperationSource.cs @@ -0,0 +1,38 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + internal class DataflowEndpointResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal DataflowEndpointResourceOperationSource(ArmClient client) + { + _client = client; + } + + DataflowEndpointResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = DataflowEndpointResourceData.DeserializeDataflowEndpointResourceData(document.RootElement); + return new DataflowEndpointResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = DataflowEndpointResourceData.DeserializeDataflowEndpointResourceData(document.RootElement); + return new DataflowEndpointResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowProfileResourceOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowProfileResourceOperationSource.cs new file mode 100644 index 000000000000..ea2ad439a143 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowProfileResourceOperationSource.cs @@ -0,0 +1,38 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + internal class DataflowProfileResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal DataflowProfileResourceOperationSource(ArmClient client) + { + _client = client; + } + + DataflowProfileResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = DataflowProfileResourceData.DeserializeDataflowProfileResourceData(document.RootElement); + return new DataflowProfileResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = DataflowProfileResourceData.DeserializeDataflowProfileResourceData(document.RootElement); + return new DataflowProfileResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowResourceOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowResourceOperationSource.cs new file mode 100644 index 000000000000..10270263937d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/DataflowResourceOperationSource.cs @@ -0,0 +1,38 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + internal class DataflowResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal DataflowResourceOperationSource(ArmClient client) + { + _client = client; + } + + DataflowResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = DataflowResourceData.DeserializeDataflowResourceData(document.RootElement); + return new DataflowResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = DataflowResourceData.DeserializeDataflowResourceData(document.RootElement); + return new DataflowResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/InstanceResourceOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/InstanceResourceOperationSource.cs new file mode 100644 index 000000000000..e3e16d0a7f8d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/InstanceResourceOperationSource.cs @@ -0,0 +1,38 @@ +// 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; + +namespace Azure.ResourceManager.IoTOperations +{ + internal class InstanceResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal InstanceResourceOperationSource(ArmClient client) + { + _client = client; + } + + InstanceResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = InstanceResourceData.DeserializeInstanceResourceData(document.RootElement); + return new InstanceResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = InstanceResourceData.DeserializeInstanceResourceData(document.RootElement); + return new InstanceResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/IoTOperationsArmOperation.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/IoTOperationsArmOperation.cs new file mode 100644 index 000000000000..1fe85ac9e64e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/IoTOperationsArmOperation.cs @@ -0,0 +1,94 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.IoTOperations +{ +#pragma warning disable SA1649 // File name should match first type name + internal class IoTOperationsArmOperation : 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 IoTOperationsArmOperation for mocking. + protected IoTOperationsArmOperation() + { + } + + internal IoTOperationsArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal IoTOperationsArmOperation(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, "IoTOperationsArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json).ToObjectFromJson>(); + return lroDetails["id"]; + } + /// + 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/IoTOperationsArmOperationOfT.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/IoTOperationsArmOperationOfT.cs new file mode 100644 index 000000000000..5faed18fa995 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/LongRunningOperation/IoTOperationsArmOperationOfT.cs @@ -0,0 +1,100 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.IoTOperations +{ +#pragma warning disable SA1649 // File name should match first type name + internal class IoTOperationsArmOperation : 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 IoTOperationsArmOperation for mocking. + protected IoTOperationsArmOperation() + { + } + + internal IoTOperationsArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal IoTOperationsArmOperation(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, "IoTOperationsArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json).ToObjectFromJson>(); + return lroDetails["id"]; + } + /// + 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ActionType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ActionType.cs new file mode 100644 index 000000000000..006035db4ffe --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ActionType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + public readonly partial struct ActionType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ActionType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InternalValue = "Internal"; + + /// Actions are for internal-only APIs. + public static ActionType Internal { get; } = new ActionType(InternalValue); + /// Determines if two values are the same. + public static bool operator ==(ActionType left, ActionType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ActionType left, ActionType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ActionType(string value) => new ActionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ActionType other && Equals(other); + /// + public bool Equals(ActionType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdrProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdrProperties.Serialization.cs new file mode 100644 index 000000000000..169f932b11fc --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdrProperties.Serialization.cs @@ -0,0 +1,119 @@ +// 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.IoTOperations.Models +{ + internal partial class AdrProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AdrProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AdrProperties 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(AdrProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAdrProperties(document.RootElement, options); + } + + internal static AdrProperties DeserializeAdrProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode state = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("state"u8)) + { + state = new OperationalMode(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AdrProperties(state, 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); + default: + throw new FormatException($"The model {nameof(AdrProperties)} does not support writing '{options.Format}' format."); + } + } + + AdrProperties 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); + return DeserializeAdrProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AdrProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdrProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdrProperties.cs new file mode 100644 index 000000000000..53993bf18f68 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdrProperties.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.IoTOperations.Models +{ + /// The properties of an ADR instance. + internal partial class AdrProperties + { + /// + /// 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 . + /// This determines if the ADR service is enabled. + public AdrProperties(OperationalMode state) + { + State = state; + } + + /// Initializes a new instance of . + /// This determines if the ADR service is enabled. + /// Keeps track of any properties unknown to the library. + internal AdrProperties(OperationalMode state, IDictionary serializedAdditionalRawData) + { + State = state; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AdrProperties() + { + } + + /// This determines if the ADR service is enabled. + public OperationalMode State { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdvancedSettings.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdvancedSettings.Serialization.cs new file mode 100644 index 000000000000..1674d74a7df5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdvancedSettings.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.Json; +using Azure.Core; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + public partial class AdvancedSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AdvancedSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Clients)) + { + writer.WritePropertyName("clients"u8); + writer.WriteObjectValue(Clients, options); + } + if (Optional.IsDefined(EncryptInternalTraffic)) + { + writer.WritePropertyName("encryptInternalTraffic"u8); + writer.WriteStringValue(EncryptInternalTraffic.Value.ToString()); + } + if (Optional.IsDefined(InternalCerts)) + { + writer.WritePropertyName("internalCerts"u8); + writer.WriteObjectValue(InternalCerts, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AdvancedSettings 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(AdvancedSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAdvancedSettings(document.RootElement, options); + } + + internal static AdvancedSettings DeserializeAdvancedSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ClientConfig clients = default; + OperationalMode? encryptInternalTraffic = default; + CertManagerCertOptions internalCerts = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("clients"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + clients = ClientConfig.DeserializeClientConfig(property.Value, options); + continue; + } + if (property.NameEquals("encryptInternalTraffic"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + encryptInternalTraffic = new OperationalMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("internalCerts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + internalCerts = CertManagerCertOptions.DeserializeCertManagerCertOptions(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AdvancedSettings(clients, encryptInternalTraffic, internalCerts, 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); + default: + throw new FormatException($"The model {nameof(AdvancedSettings)} does not support writing '{options.Format}' format."); + } + } + + AdvancedSettings 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); + return DeserializeAdvancedSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AdvancedSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdvancedSettings.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdvancedSettings.cs new file mode 100644 index 000000000000..c4a28a3c7846 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AdvancedSettings.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Broker Advanced Settings. + public partial class AdvancedSettings + { + /// + /// 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 AdvancedSettings() + { + } + + /// Initializes a new instance of . + /// Configurations related to All Clients. + /// The setting to enable or disable encryption of internal Traffic. + /// Certificate rotation and private key configuration. + /// Keeps track of any properties unknown to the library. + internal AdvancedSettings(ClientConfig clients, OperationalMode? encryptInternalTraffic, CertManagerCertOptions internalCerts, IDictionary serializedAdditionalRawData) + { + Clients = clients; + EncryptInternalTraffic = encryptInternalTraffic; + InternalCerts = internalCerts; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Configurations related to All Clients. + public ClientConfig Clients { get; set; } + /// The setting to enable or disable encryption of internal Traffic. + public OperationalMode? EncryptInternalTraffic { get; set; } + /// Certificate rotation and private key configuration. + public CertManagerCertOptions InternalCerts { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AkriInstanceProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AkriInstanceProperties.Serialization.cs new file mode 100644 index 000000000000..9c026ee8e86f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AkriInstanceProperties.Serialization.cs @@ -0,0 +1,119 @@ +// 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.IoTOperations.Models +{ + internal partial class AkriInstanceProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AkriInstanceProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AkriInstanceProperties 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(AkriInstanceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAkriInstanceProperties(document.RootElement, options); + } + + internal static AkriInstanceProperties DeserializeAkriInstanceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode state = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("state"u8)) + { + state = new OperationalMode(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AkriInstanceProperties(state, 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); + default: + throw new FormatException($"The model {nameof(AkriInstanceProperties)} does not support writing '{options.Format}' format."); + } + } + + AkriInstanceProperties 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); + return DeserializeAkriInstanceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AkriInstanceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AkriInstanceProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AkriInstanceProperties.cs new file mode 100644 index 000000000000..41d508fcd5f5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AkriInstanceProperties.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.IoTOperations.Models +{ + /// The properties of an AKRI instance. + internal partial class AkriInstanceProperties + { + /// + /// 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 . + /// This determines if the AKRI service is enabled. + public AkriInstanceProperties(OperationalMode state) + { + State = state; + } + + /// Initializes a new instance of . + /// This determines if the AKRI service is enabled. + /// Keeps track of any properties unknown to the library. + internal AkriInstanceProperties(OperationalMode state, IDictionary serializedAdditionalRawData) + { + State = state; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AkriInstanceProperties() + { + } + + /// This determines if the AKRI service is enabled. + public OperationalMode State { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationConfig.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationConfig.Serialization.cs new file mode 100644 index 000000000000..aea4f32d6a9d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationConfig.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.IoTOperations.Models +{ + public partial class AuthorizationConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AuthorizationConfig)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Cache)) + { + writer.WritePropertyName("cache"u8); + writer.WriteStringValue(Cache.Value.ToString()); + } + if (Optional.IsCollectionDefined(Rules)) + { + writer.WritePropertyName("rules"u8); + writer.WriteStartArray(); + foreach (var item in Rules) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AuthorizationConfig 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(AuthorizationConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAuthorizationConfig(document.RootElement, options); + } + + internal static AuthorizationConfig DeserializeAuthorizationConfig(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode? cache = default; + IList rules = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("cache"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + cache = new OperationalMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("rules"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AuthorizationRule.DeserializeAuthorizationRule(item, options)); + } + rules = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AuthorizationConfig(cache, rules ?? 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); + default: + throw new FormatException($"The model {nameof(AuthorizationConfig)} does not support writing '{options.Format}' format."); + } + } + + AuthorizationConfig 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); + return DeserializeAuthorizationConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AuthorizationConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationConfig.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationConfig.cs new file mode 100644 index 000000000000..07b0d0a02bb6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationConfig.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.IoTOperations.Models +{ + /// Broker AuthorizationConfig properties. + public partial class AuthorizationConfig + { + /// + /// 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 AuthorizationConfig() + { + Rules = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Enable caching of the authorization rules. + /// The authorization rules to follow. If no rule is set, but Authorization Resource is used that would mean DenyAll. + /// Keeps track of any properties unknown to the library. + internal AuthorizationConfig(OperationalMode? cache, IList rules, IDictionary serializedAdditionalRawData) + { + Cache = cache; + Rules = rules; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Enable caching of the authorization rules. + public OperationalMode? Cache { get; set; } + /// The authorization rules to follow. If no rule is set, but Authorization Resource is used that would mean DenyAll. + public IList Rules { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationRule.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationRule.Serialization.cs new file mode 100644 index 000000000000..56c434279946 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationRule.Serialization.cs @@ -0,0 +1,162 @@ +// 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.IoTOperations.Models +{ + public partial class AuthorizationRule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AuthorizationRule)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("brokerResources"u8); + writer.WriteStartArray(); + foreach (var item in BrokerResources) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("principals"u8); + writer.WriteObjectValue(Principals, options); + if (Optional.IsCollectionDefined(StateStoreResources)) + { + writer.WritePropertyName("stateStoreResources"u8); + writer.WriteStartArray(); + foreach (var item in StateStoreResources) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AuthorizationRule 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(AuthorizationRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAuthorizationRule(document.RootElement, options); + } + + internal static AuthorizationRule DeserializeAuthorizationRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList brokerResources = default; + PrincipalDefinition principals = default; + IList stateStoreResources = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("brokerResources"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(BrokerResourceRule.DeserializeBrokerResourceRule(item, options)); + } + brokerResources = array; + continue; + } + if (property.NameEquals("principals"u8)) + { + principals = PrincipalDefinition.DeserializePrincipalDefinition(property.Value, options); + continue; + } + if (property.NameEquals("stateStoreResources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StateStoreResourceRule.DeserializeStateStoreResourceRule(item, options)); + } + stateStoreResources = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AuthorizationRule(brokerResources, principals, stateStoreResources ?? 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); + default: + throw new FormatException($"The model {nameof(AuthorizationRule)} does not support writing '{options.Format}' format."); + } + } + + AuthorizationRule 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); + return DeserializeAuthorizationRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AuthorizationRule)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationRule.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationRule.cs new file mode 100644 index 000000000000..0092827c06b4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/AuthorizationRule.cs @@ -0,0 +1,88 @@ +// 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.IoTOperations.Models +{ + /// AuthorizationConfig Rule Properties. + public partial class AuthorizationRule + { + /// + /// 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 . + /// Give access to Broker methods and topics. + /// Give access to clients based on the following properties. + /// or is null. + public AuthorizationRule(IEnumerable brokerResources, PrincipalDefinition principals) + { + Argument.AssertNotNull(brokerResources, nameof(brokerResources)); + Argument.AssertNotNull(principals, nameof(principals)); + + BrokerResources = brokerResources.ToList(); + Principals = principals; + StateStoreResources = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Give access to Broker methods and topics. + /// Give access to clients based on the following properties. + /// Give access to state store resources. + /// Keeps track of any properties unknown to the library. + internal AuthorizationRule(IList brokerResources, PrincipalDefinition principals, IList stateStoreResources, IDictionary serializedAdditionalRawData) + { + BrokerResources = brokerResources; + Principals = principals; + StateStoreResources = stateStoreResources; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AuthorizationRule() + { + } + + /// Give access to Broker methods and topics. + public IList BrokerResources { get; } + /// Give access to clients based on the following properties. + public PrincipalDefinition Principals { get; set; } + /// Give access to state store resources. + public IList StateStoreResources { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BackendChain.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BackendChain.Serialization.cs new file mode 100644 index 000000000000..7bc5944e20e7 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BackendChain.Serialization.cs @@ -0,0 +1,142 @@ +// 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.IoTOperations.Models +{ + public partial class BackendChain : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BackendChain)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("partitions"u8); + writer.WriteNumberValue(Partitions); + writer.WritePropertyName("redundancyFactor"u8); + writer.WriteNumberValue(RedundancyFactor); + if (Optional.IsDefined(Workers)) + { + writer.WritePropertyName("workers"u8); + writer.WriteNumberValue(Workers.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BackendChain 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(BackendChain)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBackendChain(document.RootElement, options); + } + + internal static BackendChain DeserializeBackendChain(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int partitions = default; + int redundancyFactor = default; + int? workers = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("partitions"u8)) + { + partitions = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("redundancyFactor"u8)) + { + redundancyFactor = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("workers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + workers = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BackendChain(partitions, redundancyFactor, workers, 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); + default: + throw new FormatException($"The model {nameof(BackendChain)} does not support writing '{options.Format}' format."); + } + } + + BackendChain 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); + return DeserializeBackendChain(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BackendChain)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BackendChain.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BackendChain.cs new file mode 100644 index 000000000000..b0b9f8497ef8 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BackendChain.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.IoTOperations.Models +{ + /// Desired properties of the backend instances of the broker. + public partial class BackendChain + { + /// + /// 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 desired number of physical backend partitions. + /// The desired numbers of backend replicas (pods) in a physical partition. + public BackendChain(int partitions, int redundancyFactor) + { + Partitions = partitions; + RedundancyFactor = redundancyFactor; + } + + /// Initializes a new instance of . + /// The desired number of physical backend partitions. + /// The desired numbers of backend replicas (pods) in a physical partition. + /// Number of logical backend workers per replica (pod). + /// Keeps track of any properties unknown to the library. + internal BackendChain(int partitions, int redundancyFactor, int? workers, IDictionary serializedAdditionalRawData) + { + Partitions = partitions; + RedundancyFactor = redundancyFactor; + Workers = workers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BackendChain() + { + } + + /// The desired number of physical backend partitions. + public int Partitions { get; set; } + /// The desired numbers of backend replicas (pods) in a physical partition. + public int RedundancyFactor { get; set; } + /// Number of logical backend workers per replica (pod). + public int? Workers { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BatchingConfiguration.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BatchingConfiguration.Serialization.cs new file mode 100644 index 000000000000..7e873187c805 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BatchingConfiguration.Serialization.cs @@ -0,0 +1,141 @@ +// 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.IoTOperations.Models +{ + public partial class BatchingConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BatchingConfiguration)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(LatencySeconds)) + { + writer.WritePropertyName("latencySeconds"u8); + writer.WriteNumberValue(LatencySeconds.Value); + } + if (Optional.IsDefined(MaxMessages)) + { + writer.WritePropertyName("maxMessages"u8); + writer.WriteNumberValue(MaxMessages.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BatchingConfiguration 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(BatchingConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBatchingConfiguration(document.RootElement, options); + } + + internal static BatchingConfiguration DeserializeBatchingConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? latencySeconds = default; + int? maxMessages = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("latencySeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + latencySeconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("maxMessages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxMessages = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BatchingConfiguration(latencySeconds, maxMessages, 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); + default: + throw new FormatException($"The model {nameof(BatchingConfiguration)} does not support writing '{options.Format}' format."); + } + } + + BatchingConfiguration 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); + return DeserializeBatchingConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BatchingConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BatchingConfiguration.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BatchingConfiguration.cs new file mode 100644 index 000000000000..7add4c05aa00 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BatchingConfiguration.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.IoTOperations.Models +{ + /// Batching configuration. + public partial class BatchingConfiguration + { + /// + /// 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 BatchingConfiguration() + { + } + + /// Initializes a new instance of . + /// Batching latency in seconds. + /// Maximum number of messages in a batch. + /// Keeps track of any properties unknown to the library. + internal BatchingConfiguration(int? latencySeconds, int? maxMessages, IDictionary serializedAdditionalRawData) + { + LatencySeconds = latencySeconds; + MaxMessages = maxMessages; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Batching latency in seconds. + public int? LatencySeconds { get; set; } + /// Maximum number of messages in a batch. + public int? MaxMessages { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationMethod.cs new file mode 100644 index 000000000000..a772938f1721 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationMethod.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.IoTOperations.Models +{ + /// Broker Authentication Mode. + public readonly partial struct BrokerAuthenticationMethod : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public BrokerAuthenticationMethod(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CustomValue = "Custom"; + private const string ServiceAccountTokenValue = "ServiceAccountToken"; + private const string X509Value = "X509"; + + /// Custom authentication configuration. + public static BrokerAuthenticationMethod Custom { get; } = new BrokerAuthenticationMethod(CustomValue); + /// ServiceAccountToken authentication configuration. + public static BrokerAuthenticationMethod ServiceAccountToken { get; } = new BrokerAuthenticationMethod(ServiceAccountTokenValue); + /// X.509 authentication configuration. + public static BrokerAuthenticationMethod X509 { get; } = new BrokerAuthenticationMethod(X509Value); + /// Determines if two values are the same. + public static bool operator ==(BrokerAuthenticationMethod left, BrokerAuthenticationMethod right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(BrokerAuthenticationMethod left, BrokerAuthenticationMethod right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator BrokerAuthenticationMethod(string value) => new BrokerAuthenticationMethod(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is BrokerAuthenticationMethod other && Equals(other); + /// + public bool Equals(BrokerAuthenticationMethod 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationProperties.Serialization.cs new file mode 100644 index 000000000000..0d5e8f53a1ff --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationProperties.Serialization.cs @@ -0,0 +1,144 @@ +// 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.IoTOperations.Models +{ + public partial class BrokerAuthenticationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticationProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("authenticationMethods"u8); + writer.WriteStartArray(); + foreach (var item in AuthenticationMethods) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthenticationProperties 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(BrokerAuthenticationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthenticationProperties(document.RootElement, options); + } + + internal static BrokerAuthenticationProperties DeserializeBrokerAuthenticationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList authenticationMethods = default; + ProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("authenticationMethods"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(BrokerAuthenticatorMethods.DeserializeBrokerAuthenticatorMethods(item, options)); + } + authenticationMethods = 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 BrokerAuthenticationProperties(authenticationMethods, 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); + default: + throw new FormatException($"The model {nameof(BrokerAuthenticationProperties)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthenticationProperties 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); + return DeserializeBrokerAuthenticationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthenticationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationProperties.cs new file mode 100644 index 000000000000..413753cb59e1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationProperties.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.IoTOperations.Models +{ + /// BrokerAuthentication Resource properties. + public partial class BrokerAuthenticationProperties + { + /// + /// 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 . + /// Defines a set of Broker authentication methods to be used on `BrokerListeners`. For each array element one authenticator type supported. + /// is null. + public BrokerAuthenticationProperties(IEnumerable authenticationMethods) + { + Argument.AssertNotNull(authenticationMethods, nameof(authenticationMethods)); + + AuthenticationMethods = authenticationMethods.ToList(); + } + + /// Initializes a new instance of . + /// Defines a set of Broker authentication methods to be used on `BrokerListeners`. For each array element one authenticator type supported. + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthenticationProperties(IList authenticationMethods, ProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + AuthenticationMethods = authenticationMethods; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthenticationProperties() + { + } + + /// Defines a set of Broker authentication methods to be used on `BrokerListeners`. For each array element one authenticator type supported. + public IList AuthenticationMethods { get; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationResourceListResult.Serialization.cs new file mode 100644 index 000000000000..09454c032af1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationResourceListResult.Serialization.cs @@ -0,0 +1,144 @@ +// 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.IoTOperations.Models +{ + internal partial class BrokerAuthenticationResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticationResourceListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthenticationResourceListResult 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(BrokerAuthenticationResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthenticationResourceListResult(document.RootElement, options); + } + + internal static BrokerAuthenticationResourceListResult DeserializeBrokerAuthenticationResourceListResult(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(BrokerAuthenticationResourceData.DeserializeBrokerAuthenticationResourceData(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 BrokerAuthenticationResourceListResult(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); + default: + throw new FormatException($"The model {nameof(BrokerAuthenticationResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthenticationResourceListResult 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); + return DeserializeBrokerAuthenticationResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthenticationResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationResourceListResult.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationResourceListResult.cs new file mode 100644 index 000000000000..ba558a4df5b4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticationResourceListResult.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.IoTOperations.Models +{ + /// The response of a BrokerAuthenticationResource list operation. + internal partial class BrokerAuthenticationResourceListResult + { + /// + /// 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 BrokerAuthenticationResource items on this page. + /// is null. + internal BrokerAuthenticationResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The BrokerAuthenticationResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthenticationResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthenticationResourceListResult() + { + } + + /// The BrokerAuthenticationResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorCustomAuth.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorCustomAuth.Serialization.cs new file mode 100644 index 000000000000..ca5103dc0fa6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorCustomAuth.Serialization.cs @@ -0,0 +1,119 @@ +// 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.IoTOperations.Models +{ + internal partial class BrokerAuthenticatorCustomAuth : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorCustomAuth)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("x509"u8); + writer.WriteObjectValue(X509, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthenticatorCustomAuth 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(BrokerAuthenticatorCustomAuth)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthenticatorCustomAuth(document.RootElement, options); + } + + internal static BrokerAuthenticatorCustomAuth DeserializeBrokerAuthenticatorCustomAuth(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + X509ManualCertificate x509 = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("x509"u8)) + { + x509 = X509ManualCertificate.DeserializeX509ManualCertificate(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerAuthenticatorCustomAuth(x509, 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); + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorCustomAuth)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthenticatorCustomAuth 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); + return DeserializeBrokerAuthenticatorCustomAuth(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorCustomAuth)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorCustomAuth.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorCustomAuth.cs new file mode 100644 index 000000000000..f37c7232a43c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorCustomAuth.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.IoTOperations.Models +{ + /// Custom Authentication properties. + internal partial class BrokerAuthenticatorCustomAuth + { + /// + /// 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 . + /// X509 Custom Auth type details. + /// is null. + public BrokerAuthenticatorCustomAuth(X509ManualCertificate x509) + { + Argument.AssertNotNull(x509, nameof(x509)); + + X509 = x509; + } + + /// Initializes a new instance of . + /// X509 Custom Auth type details. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthenticatorCustomAuth(X509ManualCertificate x509, IDictionary serializedAdditionalRawData) + { + X509 = x509; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthenticatorCustomAuth() + { + } + + /// X509 Custom Auth type details. + internal X509ManualCertificate X509 { get; set; } + /// Kubernetes secret containing an X.509 client certificate. This is a reference to the secret through an identifying name, not the secret itself. + public string X509SecretRef + { + get => X509 is null ? default : X509.SecretRef; + set => X509 = new X509ManualCertificate(value); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodCustom.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodCustom.Serialization.cs new file mode 100644 index 000000000000..97b2fcf8eab0 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodCustom.Serialization.cs @@ -0,0 +1,171 @@ +// 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.IoTOperations.Models +{ + public partial class BrokerAuthenticatorMethodCustom : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodCustom)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Auth)) + { + writer.WritePropertyName("auth"u8); + writer.WriteObjectValue(Auth, options); + } + if (Optional.IsDefined(CaCertConfigMap)) + { + writer.WritePropertyName("caCertConfigMap"u8); + writer.WriteStringValue(CaCertConfigMap); + } + writer.WritePropertyName("endpoint"u8); + writer.WriteStringValue(Endpoint.AbsoluteUri); + if (Optional.IsCollectionDefined(Headers)) + { + writer.WritePropertyName("headers"u8); + writer.WriteStartObject(); + foreach (var item in Headers) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthenticatorMethodCustom 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(BrokerAuthenticatorMethodCustom)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthenticatorMethodCustom(document.RootElement, options); + } + + internal static BrokerAuthenticatorMethodCustom DeserializeBrokerAuthenticatorMethodCustom(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrokerAuthenticatorCustomAuth auth = default; + string caCertConfigMap = default; + Uri endpoint = default; + IDictionary headers = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("auth"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + auth = BrokerAuthenticatorCustomAuth.DeserializeBrokerAuthenticatorCustomAuth(property.Value, options); + continue; + } + if (property.NameEquals("caCertConfigMap"u8)) + { + caCertConfigMap = property.Value.GetString(); + continue; + } + if (property.NameEquals("endpoint"u8)) + { + endpoint = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("headers"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()); + } + headers = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerAuthenticatorMethodCustom(auth, caCertConfigMap, endpoint, headers ?? 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); + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodCustom)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthenticatorMethodCustom 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); + return DeserializeBrokerAuthenticatorMethodCustom(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodCustom)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodCustom.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodCustom.cs new file mode 100644 index 000000000000..e2d9ff6e5ff3 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodCustom.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Custom method for BrokerAuthentication. + public partial class BrokerAuthenticatorMethodCustom + { + /// + /// 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 . + /// Endpoint of the custom authentication server. Must be an HTTPS endpoint. + /// is null. + public BrokerAuthenticatorMethodCustom(Uri endpoint) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + + Endpoint = endpoint; + Headers = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Optional authentication needed for authenticating with the custom authentication server. + /// Optional CA certificate for validating the custom authentication server's certificate. + /// Endpoint of the custom authentication server. Must be an HTTPS endpoint. + /// Additional HTTP headers to pass to the custom authentication server. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthenticatorMethodCustom(BrokerAuthenticatorCustomAuth auth, string caCertConfigMap, Uri endpoint, IDictionary headers, IDictionary serializedAdditionalRawData) + { + Auth = auth; + CaCertConfigMap = caCertConfigMap; + Endpoint = endpoint; + Headers = headers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthenticatorMethodCustom() + { + } + + /// Optional authentication needed for authenticating with the custom authentication server. + internal BrokerAuthenticatorCustomAuth Auth { get; set; } + /// Kubernetes secret containing an X.509 client certificate. This is a reference to the secret through an identifying name, not the secret itself. + public string X509SecretRef + { + get => Auth is null ? default : Auth.X509SecretRef; + set => Auth = new BrokerAuthenticatorCustomAuth(value); + } + + /// Optional CA certificate for validating the custom authentication server's certificate. + public string CaCertConfigMap { get; set; } + /// Endpoint of the custom authentication server. Must be an HTTPS endpoint. + public Uri Endpoint { get; set; } + /// Additional HTTP headers to pass to the custom authentication server. + public IDictionary Headers { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodSat.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodSat.Serialization.cs new file mode 100644 index 000000000000..b07a5f80208d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodSat.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.IoTOperations.Models +{ + internal partial class BrokerAuthenticatorMethodSat : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodSat)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("audiences"u8); + writer.WriteStartArray(); + foreach (var item in Audiences) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthenticatorMethodSat 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(BrokerAuthenticatorMethodSat)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthenticatorMethodSat(document.RootElement, options); + } + + internal static BrokerAuthenticatorMethodSat DeserializeBrokerAuthenticatorMethodSat(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList audiences = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("audiences"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + audiences = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerAuthenticatorMethodSat(audiences, 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); + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodSat)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthenticatorMethodSat 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); + return DeserializeBrokerAuthenticatorMethodSat(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodSat)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodSat.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodSat.cs new file mode 100644 index 000000000000..8b6667d9fc9d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodSat.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.IoTOperations.Models +{ + /// Service Account Token for BrokerAuthentication. + internal partial class BrokerAuthenticatorMethodSat + { + /// + /// 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 . + /// List of allowed audience. + /// is null. + public BrokerAuthenticatorMethodSat(IEnumerable audiences) + { + Argument.AssertNotNull(audiences, nameof(audiences)); + + Audiences = audiences.ToList(); + } + + /// Initializes a new instance of . + /// List of allowed audience. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthenticatorMethodSat(IList audiences, IDictionary serializedAdditionalRawData) + { + Audiences = audiences; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthenticatorMethodSat() + { + } + + /// List of allowed audience. + public IList Audiences { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509.Serialization.cs new file mode 100644 index 000000000000..c162118d6745 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509.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.IoTOperations.Models +{ + public partial class BrokerAuthenticatorMethodX509 : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodX509)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(AuthorizationAttributes)) + { + writer.WritePropertyName("authorizationAttributes"u8); + writer.WriteStartObject(); + foreach (var item in AuthorizationAttributes) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(TrustedClientCaCert)) + { + writer.WritePropertyName("trustedClientCaCert"u8); + writer.WriteStringValue(TrustedClientCaCert); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthenticatorMethodX509 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(BrokerAuthenticatorMethodX509)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthenticatorMethodX509(document.RootElement, options); + } + + internal static BrokerAuthenticatorMethodX509 DeserializeBrokerAuthenticatorMethodX509(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary authorizationAttributes = default; + string trustedClientCaCert = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("authorizationAttributes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, BrokerAuthenticatorMethodX509Attributes.DeserializeBrokerAuthenticatorMethodX509Attributes(property0.Value, options)); + } + authorizationAttributes = dictionary; + continue; + } + if (property.NameEquals("trustedClientCaCert"u8)) + { + trustedClientCaCert = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerAuthenticatorMethodX509(authorizationAttributes ?? new ChangeTrackingDictionary(), trustedClientCaCert, 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); + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodX509)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthenticatorMethodX509 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); + return DeserializeBrokerAuthenticatorMethodX509(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodX509)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509.cs new file mode 100644 index 000000000000..d34e965e3ae1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509.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.IoTOperations.Models +{ + /// X509 for BrokerAuthentication. + public partial class BrokerAuthenticatorMethodX509 + { + /// + /// 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 BrokerAuthenticatorMethodX509() + { + AuthorizationAttributes = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// X509 authorization attributes properties. + /// Name of the trusted client ca cert resource. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthenticatorMethodX509(IDictionary authorizationAttributes, string trustedClientCaCert, IDictionary serializedAdditionalRawData) + { + AuthorizationAttributes = authorizationAttributes; + TrustedClientCaCert = trustedClientCaCert; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// X509 authorization attributes properties. + public IDictionary AuthorizationAttributes { get; } + /// Name of the trusted client ca cert resource. + public string TrustedClientCaCert { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509Attributes.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509Attributes.Serialization.cs new file mode 100644 index 000000000000..acdaf6340f06 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509Attributes.Serialization.cs @@ -0,0 +1,138 @@ +// 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.IoTOperations.Models +{ + public partial class BrokerAuthenticatorMethodX509Attributes : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodX509Attributes)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("attributes"u8); + writer.WriteStartObject(); + foreach (var item in Attributes) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + writer.WritePropertyName("subject"u8); + writer.WriteStringValue(Subject); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthenticatorMethodX509Attributes 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(BrokerAuthenticatorMethodX509Attributes)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthenticatorMethodX509Attributes(document.RootElement, options); + } + + internal static BrokerAuthenticatorMethodX509Attributes DeserializeBrokerAuthenticatorMethodX509Attributes(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary attributes = default; + string subject = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("attributes"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + attributes = dictionary; + continue; + } + if (property.NameEquals("subject"u8)) + { + subject = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerAuthenticatorMethodX509Attributes(attributes, subject, 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); + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodX509Attributes)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthenticatorMethodX509Attributes 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); + return DeserializeBrokerAuthenticatorMethodX509Attributes(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodX509Attributes)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509Attributes.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509Attributes.cs new file mode 100644 index 000000000000..abe670d40495 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethodX509Attributes.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.IoTOperations.Models +{ + /// BrokerAuthenticatorMethodX509Attributes properties. + public partial class BrokerAuthenticatorMethodX509Attributes + { + /// + /// 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 . + /// Attributes object. + /// Subject of the X509 attribute. + /// or is null. + public BrokerAuthenticatorMethodX509Attributes(IDictionary attributes, string subject) + { + Argument.AssertNotNull(attributes, nameof(attributes)); + Argument.AssertNotNull(subject, nameof(subject)); + + Attributes = attributes; + Subject = subject; + } + + /// Initializes a new instance of . + /// Attributes object. + /// Subject of the X509 attribute. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthenticatorMethodX509Attributes(IDictionary attributes, string subject, IDictionary serializedAdditionalRawData) + { + Attributes = attributes; + Subject = subject; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthenticatorMethodX509Attributes() + { + } + + /// Attributes object. + public IDictionary Attributes { get; } + /// Subject of the X509 attribute. + public string Subject { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethods.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethods.Serialization.cs new file mode 100644 index 000000000000..9b8177317513 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethods.Serialization.cs @@ -0,0 +1,164 @@ +// 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.IoTOperations.Models +{ + public partial class BrokerAuthenticatorMethods : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethods)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method.ToString()); + if (Optional.IsDefined(CustomSettings)) + { + writer.WritePropertyName("customSettings"u8); + writer.WriteObjectValue(CustomSettings, options); + } + if (Optional.IsDefined(ServiceAccountTokenSettings)) + { + writer.WritePropertyName("serviceAccountTokenSettings"u8); + writer.WriteObjectValue(ServiceAccountTokenSettings, options); + } + if (Optional.IsDefined(X509Settings)) + { + writer.WritePropertyName("x509Settings"u8); + writer.WriteObjectValue(X509Settings, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthenticatorMethods 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(BrokerAuthenticatorMethods)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthenticatorMethods(document.RootElement, options); + } + + internal static BrokerAuthenticatorMethods DeserializeBrokerAuthenticatorMethods(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrokerAuthenticationMethod method = default; + BrokerAuthenticatorMethodCustom customSettings = default; + BrokerAuthenticatorMethodSat serviceAccountTokenSettings = default; + BrokerAuthenticatorMethodX509 x509Settings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("method"u8)) + { + method = new BrokerAuthenticationMethod(property.Value.GetString()); + continue; + } + if (property.NameEquals("customSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + customSettings = BrokerAuthenticatorMethodCustom.DeserializeBrokerAuthenticatorMethodCustom(property.Value, options); + continue; + } + if (property.NameEquals("serviceAccountTokenSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + serviceAccountTokenSettings = BrokerAuthenticatorMethodSat.DeserializeBrokerAuthenticatorMethodSat(property.Value, options); + continue; + } + if (property.NameEquals("x509Settings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + x509Settings = BrokerAuthenticatorMethodX509.DeserializeBrokerAuthenticatorMethodX509(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerAuthenticatorMethods(method, customSettings, serviceAccountTokenSettings, x509Settings, 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); + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethods)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthenticatorMethods 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); + return DeserializeBrokerAuthenticatorMethods(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethods)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethods.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethods.cs new file mode 100644 index 000000000000..1959b155b27c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthenticatorMethods.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Set of broker authentication policies. Only one method is supported for each entry. + public partial class BrokerAuthenticatorMethods + { + /// + /// 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 . + /// Custom authentication configuration. + public BrokerAuthenticatorMethods(BrokerAuthenticationMethod method) + { + Method = method; + } + + /// Initializes a new instance of . + /// Custom authentication configuration. + /// Custom authentication configuration. + /// ServiceAccountToken authentication configuration. + /// X.509 authentication configuration. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthenticatorMethods(BrokerAuthenticationMethod method, BrokerAuthenticatorMethodCustom customSettings, BrokerAuthenticatorMethodSat serviceAccountTokenSettings, BrokerAuthenticatorMethodX509 x509Settings, IDictionary serializedAdditionalRawData) + { + Method = method; + CustomSettings = customSettings; + ServiceAccountTokenSettings = serviceAccountTokenSettings; + X509Settings = x509Settings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthenticatorMethods() + { + } + + /// Custom authentication configuration. + public BrokerAuthenticationMethod Method { get; set; } + /// Custom authentication configuration. + public BrokerAuthenticatorMethodCustom CustomSettings { get; set; } + /// ServiceAccountToken authentication configuration. + internal BrokerAuthenticatorMethodSat ServiceAccountTokenSettings { get; set; } + /// List of allowed audience. + public IList ServiceAccountTokenAudiences + { + get => ServiceAccountTokenSettings is null ? default : ServiceAccountTokenSettings.Audiences; + set => ServiceAccountTokenSettings = new BrokerAuthenticatorMethodSat(value); + } + + /// X.509 authentication configuration. + public BrokerAuthenticatorMethodX509 X509Settings { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationProperties.Serialization.cs new file mode 100644 index 000000000000..189938535acc --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationProperties.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.IoTOperations.Models +{ + public partial class BrokerAuthorizationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthorizationProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("authorizationPolicies"u8); + writer.WriteObjectValue(AuthorizationPolicies, options); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthorizationProperties 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(BrokerAuthorizationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthorizationProperties(document.RootElement, options); + } + + internal static BrokerAuthorizationProperties DeserializeBrokerAuthorizationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AuthorizationConfig authorizationPolicies = default; + ProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("authorizationPolicies"u8)) + { + authorizationPolicies = AuthorizationConfig.DeserializeAuthorizationConfig(property.Value, options); + 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 BrokerAuthorizationProperties(authorizationPolicies, 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); + default: + throw new FormatException($"The model {nameof(BrokerAuthorizationProperties)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthorizationProperties 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); + return DeserializeBrokerAuthorizationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthorizationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationProperties.cs new file mode 100644 index 000000000000..760e3a3dac6c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationProperties.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// BrokerAuthorization Resource properties. + public partial class BrokerAuthorizationProperties + { + /// + /// 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 list of authorization policies supported by the Authorization Resource. + /// is null. + public BrokerAuthorizationProperties(AuthorizationConfig authorizationPolicies) + { + Argument.AssertNotNull(authorizationPolicies, nameof(authorizationPolicies)); + + AuthorizationPolicies = authorizationPolicies; + } + + /// Initializes a new instance of . + /// The list of authorization policies supported by the Authorization Resource. + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthorizationProperties(AuthorizationConfig authorizationPolicies, ProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + AuthorizationPolicies = authorizationPolicies; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthorizationProperties() + { + } + + /// The list of authorization policies supported by the Authorization Resource. + public AuthorizationConfig AuthorizationPolicies { get; set; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationResourceListResult.Serialization.cs new file mode 100644 index 000000000000..205d51741ec4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationResourceListResult.Serialization.cs @@ -0,0 +1,144 @@ +// 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.IoTOperations.Models +{ + internal partial class BrokerAuthorizationResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthorizationResourceListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerAuthorizationResourceListResult 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(BrokerAuthorizationResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthorizationResourceListResult(document.RootElement, options); + } + + internal static BrokerAuthorizationResourceListResult DeserializeBrokerAuthorizationResourceListResult(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(BrokerAuthorizationResourceData.DeserializeBrokerAuthorizationResourceData(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 BrokerAuthorizationResourceListResult(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); + default: + throw new FormatException($"The model {nameof(BrokerAuthorizationResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthorizationResourceListResult 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); + return DeserializeBrokerAuthorizationResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthorizationResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationResourceListResult.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationResourceListResult.cs new file mode 100644 index 000000000000..faac07e07534 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerAuthorizationResourceListResult.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.IoTOperations.Models +{ + /// The response of a BrokerAuthorizationResource list operation. + internal partial class BrokerAuthorizationResourceListResult + { + /// + /// 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 BrokerAuthorizationResource items on this page. + /// is null. + internal BrokerAuthorizationResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The BrokerAuthorizationResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal BrokerAuthorizationResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthorizationResourceListResult() + { + } + + /// The BrokerAuthorizationResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerDiagnostics.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerDiagnostics.Serialization.cs new file mode 100644 index 000000000000..3c70bbc9f15f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerDiagnostics.Serialization.cs @@ -0,0 +1,171 @@ +// 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.IoTOperations.Models +{ + public partial class BrokerDiagnostics : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerDiagnostics)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Logs)) + { + writer.WritePropertyName("logs"u8); + writer.WriteObjectValue(Logs, options); + } + if (Optional.IsDefined(Metrics)) + { + writer.WritePropertyName("metrics"u8); + writer.WriteObjectValue(Metrics, options); + } + if (Optional.IsDefined(SelfCheck)) + { + writer.WritePropertyName("selfCheck"u8); + writer.WriteObjectValue(SelfCheck, options); + } + if (Optional.IsDefined(Traces)) + { + writer.WritePropertyName("traces"u8); + writer.WriteObjectValue(Traces, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerDiagnostics 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(BrokerDiagnostics)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerDiagnostics(document.RootElement, options); + } + + internal static BrokerDiagnostics DeserializeBrokerDiagnostics(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DiagnosticsLogs logs = default; + Metrics metrics = default; + SelfCheck selfCheck = default; + Traces traces = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("logs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + logs = DiagnosticsLogs.DeserializeDiagnosticsLogs(property.Value, options); + continue; + } + if (property.NameEquals("metrics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + metrics = Metrics.DeserializeMetrics(property.Value, options); + continue; + } + if (property.NameEquals("selfCheck"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + selfCheck = SelfCheck.DeserializeSelfCheck(property.Value, options); + continue; + } + if (property.NameEquals("traces"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + traces = Traces.DeserializeTraces(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerDiagnostics(logs, metrics, selfCheck, traces, 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); + default: + throw new FormatException($"The model {nameof(BrokerDiagnostics)} does not support writing '{options.Format}' format."); + } + } + + BrokerDiagnostics 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); + return DeserializeBrokerDiagnostics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerDiagnostics)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerDiagnostics.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerDiagnostics.cs new file mode 100644 index 000000000000..2c90ec2cd857 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerDiagnostics.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.IoTOperations.Models +{ + /// Broker Diagnostic Setting properties. + public partial class BrokerDiagnostics + { + /// + /// 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 BrokerDiagnostics() + { + } + + /// Initializes a new instance of . + /// Diagnostic log settings for the resource. + /// The metrics settings for the resource. + /// The self check properties. + /// The trace properties. + /// Keeps track of any properties unknown to the library. + internal BrokerDiagnostics(DiagnosticsLogs logs, Metrics metrics, SelfCheck selfCheck, Traces traces, IDictionary serializedAdditionalRawData) + { + Logs = logs; + Metrics = metrics; + SelfCheck = selfCheck; + Traces = traces; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Diagnostic log settings for the resource. + public DiagnosticsLogs Logs { get; set; } + /// The metrics settings for the resource. + public Metrics Metrics { get; set; } + /// The self check properties. + public SelfCheck SelfCheck { get; set; } + /// The trace properties. + public Traces Traces { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerProperties.Serialization.cs new file mode 100644 index 000000000000..8c1630cb51ab --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerProperties.Serialization.cs @@ -0,0 +1,170 @@ +// 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.IoTOperations.Models +{ + public partial class BrokerListenerProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerListenerProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ServiceName)) + { + writer.WritePropertyName("serviceName"u8); + writer.WriteStringValue(ServiceName); + } + writer.WritePropertyName("ports"u8); + writer.WriteStartArray(); + foreach (var item in Ports) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(ServiceType)) + { + writer.WritePropertyName("serviceType"u8); + writer.WriteStringValue(ServiceType.Value.ToString()); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerListenerProperties 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(BrokerListenerProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerListenerProperties(document.RootElement, options); + } + + internal static BrokerListenerProperties DeserializeBrokerListenerProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string serviceName = default; + IList ports = default; + ServiceType? serviceType = default; + ProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("serviceName"u8)) + { + serviceName = property.Value.GetString(); + continue; + } + if (property.NameEquals("ports"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ListenerPort.DeserializeListenerPort(item, options)); + } + ports = array; + continue; + } + if (property.NameEquals("serviceType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + serviceType = new ServiceType(property.Value.GetString()); + 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 BrokerListenerProperties(serviceName, ports, serviceType, 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); + default: + throw new FormatException($"The model {nameof(BrokerListenerProperties)} does not support writing '{options.Format}' format."); + } + } + + BrokerListenerProperties 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); + return DeserializeBrokerListenerProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerListenerProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerProperties.cs new file mode 100644 index 000000000000..db42f23bfbab --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerProperties.cs @@ -0,0 +1,88 @@ +// 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.IoTOperations.Models +{ + /// Defines a Broker listener. A listener is a collection of ports on which the broker accepts connections from clients. + public partial class BrokerListenerProperties + { + /// + /// 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 . + /// Ports on which this listener accepts client connections. + /// is null. + public BrokerListenerProperties(IEnumerable ports) + { + Argument.AssertNotNull(ports, nameof(ports)); + + Ports = ports.ToList(); + } + + /// Initializes a new instance of . + /// Kubernetes Service name of this listener. + /// Ports on which this listener accepts client connections. + /// Kubernetes Service type of this listener. + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal BrokerListenerProperties(string serviceName, IList ports, ServiceType? serviceType, ProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + ServiceName = serviceName; + Ports = ports; + ServiceType = serviceType; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerListenerProperties() + { + } + + /// Kubernetes Service name of this listener. + public string ServiceName { get; set; } + /// Ports on which this listener accepts client connections. + public IList Ports { get; } + /// Kubernetes Service type of this listener. + public ServiceType? ServiceType { get; set; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerResourceListResult.Serialization.cs new file mode 100644 index 000000000000..b47967268697 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerResourceListResult.Serialization.cs @@ -0,0 +1,144 @@ +// 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.IoTOperations.Models +{ + internal partial class BrokerListenerResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerListenerResourceListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerListenerResourceListResult 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(BrokerListenerResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerListenerResourceListResult(document.RootElement, options); + } + + internal static BrokerListenerResourceListResult DeserializeBrokerListenerResourceListResult(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(BrokerListenerResourceData.DeserializeBrokerListenerResourceData(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 BrokerListenerResourceListResult(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); + default: + throw new FormatException($"The model {nameof(BrokerListenerResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + BrokerListenerResourceListResult 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); + return DeserializeBrokerListenerResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerListenerResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerResourceListResult.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerResourceListResult.cs new file mode 100644 index 000000000000..aa31f24de421 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerListenerResourceListResult.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.IoTOperations.Models +{ + /// The response of a BrokerListenerResource list operation. + internal partial class BrokerListenerResourceListResult + { + /// + /// 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 BrokerListenerResource items on this page. + /// is null. + internal BrokerListenerResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The BrokerListenerResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal BrokerListenerResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerListenerResourceListResult() + { + } + + /// The BrokerListenerResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerMemoryProfile.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerMemoryProfile.cs new file mode 100644 index 000000000000..e5ec6a168299 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerMemoryProfile.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.IoTOperations.Models +{ + /// The memory profile settings of the Broker. + public readonly partial struct BrokerMemoryProfile : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public BrokerMemoryProfile(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TinyValue = "Tiny"; + private const string LowValue = "Low"; + private const string MediumValue = "Medium"; + private const string HighValue = "High"; + + /// Tiny memory profile. + public static BrokerMemoryProfile Tiny { get; } = new BrokerMemoryProfile(TinyValue); + /// Low memory profile. + public static BrokerMemoryProfile Low { get; } = new BrokerMemoryProfile(LowValue); + /// Medium memory profile. + public static BrokerMemoryProfile Medium { get; } = new BrokerMemoryProfile(MediumValue); + /// High memory profile. + public static BrokerMemoryProfile High { get; } = new BrokerMemoryProfile(HighValue); + /// Determines if two values are the same. + public static bool operator ==(BrokerMemoryProfile left, BrokerMemoryProfile right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(BrokerMemoryProfile left, BrokerMemoryProfile right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator BrokerMemoryProfile(string value) => new BrokerMemoryProfile(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is BrokerMemoryProfile other && Equals(other); + /// + public bool Equals(BrokerMemoryProfile 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProperties.Serialization.cs new file mode 100644 index 000000000000..99b84f6e20ff --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProperties.Serialization.cs @@ -0,0 +1,224 @@ +// 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.IoTOperations.Models +{ + public partial class BrokerProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Advanced)) + { + writer.WritePropertyName("advanced"u8); + writer.WriteObjectValue(Advanced, options); + } + if (Optional.IsDefined(Cardinality)) + { + writer.WritePropertyName("cardinality"u8); + writer.WriteObjectValue(Cardinality, options); + } + if (Optional.IsDefined(Diagnostics)) + { + writer.WritePropertyName("diagnostics"u8); + writer.WriteObjectValue(Diagnostics, options); + } + if (Optional.IsDefined(DiskBackedMessageBuffer)) + { + writer.WritePropertyName("diskBackedMessageBuffer"u8); + writer.WriteObjectValue(DiskBackedMessageBuffer, options); + } + if (Optional.IsDefined(GenerateResourceLimits)) + { + writer.WritePropertyName("generateResourceLimits"u8); + writer.WriteObjectValue(GenerateResourceLimits, options); + } + if (Optional.IsDefined(MemoryProfile)) + { + writer.WritePropertyName("memoryProfile"u8); + writer.WriteStringValue(MemoryProfile.Value.ToString()); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerProperties 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(BrokerProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerProperties(document.RootElement, options); + } + + internal static BrokerProperties DeserializeBrokerProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AdvancedSettings advanced = default; + Cardinality cardinality = default; + BrokerDiagnostics diagnostics = default; + DiskBackedMessageBuffer diskBackedMessageBuffer = default; + GenerateResourceLimits generateResourceLimits = default; + BrokerMemoryProfile? memoryProfile = default; + ProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("advanced"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + advanced = AdvancedSettings.DeserializeAdvancedSettings(property.Value, options); + continue; + } + if (property.NameEquals("cardinality"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + cardinality = Cardinality.DeserializeCardinality(property.Value, options); + continue; + } + if (property.NameEquals("diagnostics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diagnostics = BrokerDiagnostics.DeserializeBrokerDiagnostics(property.Value, options); + continue; + } + if (property.NameEquals("diskBackedMessageBuffer"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diskBackedMessageBuffer = DiskBackedMessageBuffer.DeserializeDiskBackedMessageBuffer(property.Value, options); + continue; + } + if (property.NameEquals("generateResourceLimits"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + generateResourceLimits = GenerateResourceLimits.DeserializeGenerateResourceLimits(property.Value, options); + continue; + } + if (property.NameEquals("memoryProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + memoryProfile = new BrokerMemoryProfile(property.Value.GetString()); + 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 BrokerProperties( + advanced, + cardinality, + diagnostics, + diskBackedMessageBuffer, + generateResourceLimits, + memoryProfile, + 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); + default: + throw new FormatException($"The model {nameof(BrokerProperties)} does not support writing '{options.Format}' format."); + } + } + + BrokerProperties 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); + return DeserializeBrokerProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProperties.cs new file mode 100644 index 000000000000..0c87125f7b86 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProperties.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Broker Resource properties. + public partial class BrokerProperties + { + /// + /// 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 BrokerProperties() + { + } + + /// Initializes a new instance of . + /// Advanced settings of Broker. + /// The cardinality details of the broker. + /// Spec defines the desired identities of Broker diagnostics settings. + /// Settings of Disk Backed Message Buffer. + /// This setting controls whether Kubernetes CPU resource limits are requested. Increasing the number of replicas or workers proportionally increases the amount of CPU resources requested. If this setting is enabled and there are insufficient CPU resources, an error will be emitted. + /// Memory profile of Broker. + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal BrokerProperties(AdvancedSettings advanced, Cardinality cardinality, BrokerDiagnostics diagnostics, DiskBackedMessageBuffer diskBackedMessageBuffer, GenerateResourceLimits generateResourceLimits, BrokerMemoryProfile? memoryProfile, ProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + Advanced = advanced; + Cardinality = cardinality; + Diagnostics = diagnostics; + DiskBackedMessageBuffer = diskBackedMessageBuffer; + GenerateResourceLimits = generateResourceLimits; + MemoryProfile = memoryProfile; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Advanced settings of Broker. + public AdvancedSettings Advanced { get; set; } + /// The cardinality details of the broker. + public Cardinality Cardinality { get; set; } + /// Spec defines the desired identities of Broker diagnostics settings. + public BrokerDiagnostics Diagnostics { get; set; } + /// Settings of Disk Backed Message Buffer. + public DiskBackedMessageBuffer DiskBackedMessageBuffer { get; set; } + /// This setting controls whether Kubernetes CPU resource limits are requested. Increasing the number of replicas or workers proportionally increases the amount of CPU resources requested. If this setting is enabled and there are insufficient CPU resources, an error will be emitted. + internal GenerateResourceLimits GenerateResourceLimits { get; set; } + /// The toggle to enable/disable cpu resource limits. + public OperationalMode? GenerateResourceLimitsCpu + { + get => GenerateResourceLimits is null ? default : GenerateResourceLimits.Cpu; + set + { + if (GenerateResourceLimits is null) + GenerateResourceLimits = new GenerateResourceLimits(); + GenerateResourceLimits.Cpu = value; + } + } + + /// Memory profile of Broker. + public BrokerMemoryProfile? MemoryProfile { get; set; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProtocolType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProtocolType.cs new file mode 100644 index 000000000000..c713d5fdd5fc --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerProtocolType.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.IoTOperations.Models +{ + /// Broker Protocol types. + public readonly partial struct BrokerProtocolType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public BrokerProtocolType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string MqttValue = "Mqtt"; + private const string WebSocketsValue = "WebSockets"; + + /// protocol broker. + public static BrokerProtocolType Mqtt { get; } = new BrokerProtocolType(MqttValue); + /// protocol websocket. + public static BrokerProtocolType WebSockets { get; } = new BrokerProtocolType(WebSocketsValue); + /// Determines if two values are the same. + public static bool operator ==(BrokerProtocolType left, BrokerProtocolType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(BrokerProtocolType left, BrokerProtocolType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator BrokerProtocolType(string value) => new BrokerProtocolType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is BrokerProtocolType other && Equals(other); + /// + public bool Equals(BrokerProtocolType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceDefinitionMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceDefinitionMethod.cs new file mode 100644 index 000000000000..1d4382d19b07 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceDefinitionMethod.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.IoTOperations.Models +{ + /// BrokerResourceDefinitionMethods methods allowed. + public readonly partial struct BrokerResourceDefinitionMethod : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public BrokerResourceDefinitionMethod(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ConnectValue = "Connect"; + private const string PublishValue = "Publish"; + private const string SubscribeValue = "Subscribe"; + + /// Allowed Connecting to Broker. + public static BrokerResourceDefinitionMethod Connect { get; } = new BrokerResourceDefinitionMethod(ConnectValue); + /// Allowed Publishing to Broker. + public static BrokerResourceDefinitionMethod Publish { get; } = new BrokerResourceDefinitionMethod(PublishValue); + /// Allowed Subscribing to Broker. + public static BrokerResourceDefinitionMethod Subscribe { get; } = new BrokerResourceDefinitionMethod(SubscribeValue); + /// Determines if two values are the same. + public static bool operator ==(BrokerResourceDefinitionMethod left, BrokerResourceDefinitionMethod right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(BrokerResourceDefinitionMethod left, BrokerResourceDefinitionMethod right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator BrokerResourceDefinitionMethod(string value) => new BrokerResourceDefinitionMethod(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is BrokerResourceDefinitionMethod other && Equals(other); + /// + public bool Equals(BrokerResourceDefinitionMethod 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceListResult.Serialization.cs new file mode 100644 index 000000000000..03bafe560b64 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceListResult.Serialization.cs @@ -0,0 +1,144 @@ +// 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.IoTOperations.Models +{ + internal partial class BrokerResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerResourceListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerResourceListResult 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(BrokerResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerResourceListResult(document.RootElement, options); + } + + internal static BrokerResourceListResult DeserializeBrokerResourceListResult(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(BrokerResourceData.DeserializeBrokerResourceData(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 BrokerResourceListResult(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); + default: + throw new FormatException($"The model {nameof(BrokerResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + BrokerResourceListResult 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); + return DeserializeBrokerResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceListResult.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceListResult.cs new file mode 100644 index 000000000000..5ca0e501f447 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceListResult.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.IoTOperations.Models +{ + /// The response of a BrokerResource list operation. + internal partial class BrokerResourceListResult + { + /// + /// 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 BrokerResource items on this page. + /// is null. + internal BrokerResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The BrokerResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal BrokerResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerResourceListResult() + { + } + + /// The BrokerResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceRule.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceRule.Serialization.cs new file mode 100644 index 000000000000..a8df826671b1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceRule.Serialization.cs @@ -0,0 +1,169 @@ +// 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.IoTOperations.Models +{ + public partial class BrokerResourceRule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerResourceRule)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method.ToString()); + if (Optional.IsCollectionDefined(ClientIds)) + { + writer.WritePropertyName("clientIds"u8); + writer.WriteStartArray(); + foreach (var item in ClientIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Topics)) + { + writer.WritePropertyName("topics"u8); + writer.WriteStartArray(); + foreach (var item in Topics) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BrokerResourceRule 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(BrokerResourceRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerResourceRule(document.RootElement, options); + } + + internal static BrokerResourceRule DeserializeBrokerResourceRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrokerResourceDefinitionMethod method = default; + IList clientIds = default; + IList topics = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("method"u8)) + { + method = new BrokerResourceDefinitionMethod(property.Value.GetString()); + continue; + } + if (property.NameEquals("clientIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + clientIds = array; + continue; + } + if (property.NameEquals("topics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + topics = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerResourceRule(method, clientIds ?? new ChangeTrackingList(), topics ?? 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); + default: + throw new FormatException($"The model {nameof(BrokerResourceRule)} does not support writing '{options.Format}' format."); + } + } + + BrokerResourceRule 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); + return DeserializeBrokerResourceRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerResourceRule)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceRule.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceRule.cs new file mode 100644 index 000000000000..a288fbf48e58 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/BrokerResourceRule.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.IoTOperations.Models +{ + /// Broker Resource Rule properties. This defines the objects that represent the actions or topics, such as - method.Connect, method.Publish, etc. + public partial class BrokerResourceRule + { + /// + /// 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 . + /// Give access for a Broker method (i.e., Connect, Subscribe, or Publish). + public BrokerResourceRule(BrokerResourceDefinitionMethod method) + { + Method = method; + ClientIds = new ChangeTrackingList(); + Topics = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Give access for a Broker method (i.e., Connect, Subscribe, or Publish). + /// A list of client IDs that match the clients. The client IDs are case-sensitive and must match the client IDs provided by the clients during connection. This subfield may be set if the method is Connect. + /// A list of topics or topic patterns that match the topics that the clients can publish or subscribe to. This subfield is required if the method is Publish or Subscribe. + /// Keeps track of any properties unknown to the library. + internal BrokerResourceRule(BrokerResourceDefinitionMethod method, IList clientIds, IList topics, IDictionary serializedAdditionalRawData) + { + Method = method; + ClientIds = clientIds; + Topics = topics; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerResourceRule() + { + } + + /// Give access for a Broker method (i.e., Connect, Subscribe, or Publish). + public BrokerResourceDefinitionMethod Method { get; set; } + /// A list of client IDs that match the clients. The client IDs are case-sensitive and must match the client IDs provided by the clients during connection. This subfield may be set if the method is Connect. + public IList ClientIds { get; } + /// A list of topics or topic patterns that match the topics that the clients can publish or subscribe to. This subfield is required if the method is Publish or Subscribe. + public IList Topics { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Cardinality.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Cardinality.Serialization.cs new file mode 100644 index 000000000000..7c830b0c9da4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Cardinality.Serialization.cs @@ -0,0 +1,127 @@ +// 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.IoTOperations.Models +{ + public partial class Cardinality : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Cardinality)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("backendChain"u8); + writer.WriteObjectValue(BackendChain, options); + writer.WritePropertyName("frontend"u8); + writer.WriteObjectValue(Frontend, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Cardinality 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(Cardinality)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCardinality(document.RootElement, options); + } + + internal static Cardinality DeserializeCardinality(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BackendChain backendChain = default; + Frontend frontend = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("backendChain"u8)) + { + backendChain = BackendChain.DeserializeBackendChain(property.Value, options); + continue; + } + if (property.NameEquals("frontend"u8)) + { + frontend = Frontend.DeserializeFrontend(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Cardinality(backendChain, frontend, 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); + default: + throw new FormatException($"The model {nameof(Cardinality)} does not support writing '{options.Format}' format."); + } + } + + Cardinality 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); + return DeserializeCardinality(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Cardinality)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Cardinality.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Cardinality.cs new file mode 100644 index 000000000000..7e2d3b673870 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Cardinality.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.IoTOperations.Models +{ + /// Cardinality properties. + public partial class Cardinality + { + /// + /// 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 backend broker desired properties. + /// The frontend desired properties. + /// or is null. + public Cardinality(BackendChain backendChain, Frontend frontend) + { + Argument.AssertNotNull(backendChain, nameof(backendChain)); + Argument.AssertNotNull(frontend, nameof(frontend)); + + BackendChain = backendChain; + Frontend = frontend; + } + + /// Initializes a new instance of . + /// The backend broker desired properties. + /// The frontend desired properties. + /// Keeps track of any properties unknown to the library. + internal Cardinality(BackendChain backendChain, Frontend frontend, IDictionary serializedAdditionalRawData) + { + BackendChain = backendChain; + Frontend = frontend; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Cardinality() + { + } + + /// The backend broker desired properties. + public BackendChain BackendChain { get; set; } + /// The frontend desired properties. + public Frontend Frontend { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertOptions.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertOptions.Serialization.cs new file mode 100644 index 000000000000..9eb2fe6e0dd2 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertOptions.Serialization.cs @@ -0,0 +1,135 @@ +// 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.IoTOperations.Models +{ + public partial class CertManagerCertOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertManagerCertOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("duration"u8); + writer.WriteStringValue(Duration); + writer.WritePropertyName("renewBefore"u8); + writer.WriteStringValue(RenewBefore); + writer.WritePropertyName("privateKey"u8); + writer.WriteObjectValue(PrivateKey, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CertManagerCertOptions 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(CertManagerCertOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCertManagerCertOptions(document.RootElement, options); + } + + internal static CertManagerCertOptions DeserializeCertManagerCertOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string duration = default; + string renewBefore = default; + CertManagerPrivateKey privateKey = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("duration"u8)) + { + duration = property.Value.GetString(); + continue; + } + if (property.NameEquals("renewBefore"u8)) + { + renewBefore = property.Value.GetString(); + continue; + } + if (property.NameEquals("privateKey"u8)) + { + privateKey = CertManagerPrivateKey.DeserializeCertManagerPrivateKey(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CertManagerCertOptions(duration, renewBefore, privateKey, 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); + default: + throw new FormatException($"The model {nameof(CertManagerCertOptions)} does not support writing '{options.Format}' format."); + } + } + + CertManagerCertOptions 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); + return DeserializeCertManagerCertOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CertManagerCertOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertOptions.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertOptions.cs new file mode 100644 index 000000000000..67a42b027dfb --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertOptions.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Cert Manager Cert properties. + public partial class CertManagerCertOptions + { + /// + /// 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 . + /// Lifetime of certificate. Must be specified using a Go time.Duration format (h|m|s). E.g. 240h for 240 hours and 45m for 45 minutes. + /// When to begin renewing certificate. Must be specified using a Go time.Duration format (h|m|s). E.g. 240h for 240 hours and 45m for 45 minutes. + /// Configuration of certificate private key. + /// , or is null. + public CertManagerCertOptions(string duration, string renewBefore, CertManagerPrivateKey privateKey) + { + Argument.AssertNotNull(duration, nameof(duration)); + Argument.AssertNotNull(renewBefore, nameof(renewBefore)); + Argument.AssertNotNull(privateKey, nameof(privateKey)); + + Duration = duration; + RenewBefore = renewBefore; + PrivateKey = privateKey; + } + + /// Initializes a new instance of . + /// Lifetime of certificate. Must be specified using a Go time.Duration format (h|m|s). E.g. 240h for 240 hours and 45m for 45 minutes. + /// When to begin renewing certificate. Must be specified using a Go time.Duration format (h|m|s). E.g. 240h for 240 hours and 45m for 45 minutes. + /// Configuration of certificate private key. + /// Keeps track of any properties unknown to the library. + internal CertManagerCertOptions(string duration, string renewBefore, CertManagerPrivateKey privateKey, IDictionary serializedAdditionalRawData) + { + Duration = duration; + RenewBefore = renewBefore; + PrivateKey = privateKey; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CertManagerCertOptions() + { + } + + /// Lifetime of certificate. Must be specified using a Go time.Duration format (h|m|s). E.g. 240h for 240 hours and 45m for 45 minutes. + public string Duration { get; set; } + /// When to begin renewing certificate. Must be specified using a Go time.Duration format (h|m|s). E.g. 240h for 240 hours and 45m for 45 minutes. + public string RenewBefore { get; set; } + /// Configuration of certificate private key. + public CertManagerPrivateKey PrivateKey { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertificateSpec.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertificateSpec.Serialization.cs new file mode 100644 index 000000000000..62dc19d9741b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertificateSpec.Serialization.cs @@ -0,0 +1,189 @@ +// 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.IoTOperations.Models +{ + public partial class CertManagerCertificateSpec : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertManagerCertificateSpec)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Duration)) + { + writer.WritePropertyName("duration"u8); + writer.WriteStringValue(Duration); + } + if (Optional.IsDefined(SecretName)) + { + writer.WritePropertyName("secretName"u8); + writer.WriteStringValue(SecretName); + } + if (Optional.IsDefined(RenewBefore)) + { + writer.WritePropertyName("renewBefore"u8); + writer.WriteStringValue(RenewBefore); + } + writer.WritePropertyName("issuerRef"u8); + writer.WriteObjectValue(IssuerRef, options); + if (Optional.IsDefined(PrivateKey)) + { + writer.WritePropertyName("privateKey"u8); + writer.WriteObjectValue(PrivateKey, options); + } + if (Optional.IsDefined(San)) + { + writer.WritePropertyName("san"u8); + writer.WriteObjectValue(San, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CertManagerCertificateSpec 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(CertManagerCertificateSpec)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCertManagerCertificateSpec(document.RootElement, options); + } + + internal static CertManagerCertificateSpec DeserializeCertManagerCertificateSpec(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string duration = default; + string secretName = default; + string renewBefore = default; + CertManagerIssuerRef issuerRef = default; + CertManagerPrivateKey privateKey = default; + SanForCert san = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("duration"u8)) + { + duration = property.Value.GetString(); + continue; + } + if (property.NameEquals("secretName"u8)) + { + secretName = property.Value.GetString(); + continue; + } + if (property.NameEquals("renewBefore"u8)) + { + renewBefore = property.Value.GetString(); + continue; + } + if (property.NameEquals("issuerRef"u8)) + { + issuerRef = CertManagerIssuerRef.DeserializeCertManagerIssuerRef(property.Value, options); + continue; + } + if (property.NameEquals("privateKey"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateKey = CertManagerPrivateKey.DeserializeCertManagerPrivateKey(property.Value, options); + continue; + } + if (property.NameEquals("san"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + san = SanForCert.DeserializeSanForCert(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CertManagerCertificateSpec( + duration, + secretName, + renewBefore, + issuerRef, + privateKey, + san, + 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); + default: + throw new FormatException($"The model {nameof(CertManagerCertificateSpec)} does not support writing '{options.Format}' format."); + } + } + + CertManagerCertificateSpec 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); + return DeserializeCertManagerCertificateSpec(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CertManagerCertificateSpec)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertificateSpec.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertificateSpec.cs new file mode 100644 index 000000000000..dde57dbe48c7 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerCertificateSpec.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Automatic TLS server certificate management with cert-manager. + public partial class CertManagerCertificateSpec + { + /// + /// 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 . + /// cert-manager issuerRef. + /// is null. + public CertManagerCertificateSpec(CertManagerIssuerRef issuerRef) + { + Argument.AssertNotNull(issuerRef, nameof(issuerRef)); + + IssuerRef = issuerRef; + } + + /// Initializes a new instance of . + /// Lifetime of certificate. Must be specified using a Go time.Duration format (h|m|s). E.g. 240h for 240 hours and 45m for 45 minutes. + /// Secret for storing server certificate. Any existing data will be overwritten. This is a reference to the secret through an identifying name, not the secret itself. + /// When to begin renewing certificate. Must be specified using a Go time.Duration format (h|m|s). E.g. 240h for 240 hours and 45m for 45 minutes. + /// cert-manager issuerRef. + /// Type of certificate private key. + /// Additional Subject Alternative Names (SANs) to include in the certificate. + /// Keeps track of any properties unknown to the library. + internal CertManagerCertificateSpec(string duration, string secretName, string renewBefore, CertManagerIssuerRef issuerRef, CertManagerPrivateKey privateKey, SanForCert san, IDictionary serializedAdditionalRawData) + { + Duration = duration; + SecretName = secretName; + RenewBefore = renewBefore; + IssuerRef = issuerRef; + PrivateKey = privateKey; + San = san; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CertManagerCertificateSpec() + { + } + + /// Lifetime of certificate. Must be specified using a Go time.Duration format (h|m|s). E.g. 240h for 240 hours and 45m for 45 minutes. + public string Duration { get; set; } + /// Secret for storing server certificate. Any existing data will be overwritten. This is a reference to the secret through an identifying name, not the secret itself. + public string SecretName { get; set; } + /// When to begin renewing certificate. Must be specified using a Go time.Duration format (h|m|s). E.g. 240h for 240 hours and 45m for 45 minutes. + public string RenewBefore { get; set; } + /// cert-manager issuerRef. + public CertManagerIssuerRef IssuerRef { get; set; } + /// Type of certificate private key. + public CertManagerPrivateKey PrivateKey { get; set; } + /// Additional Subject Alternative Names (SANs) to include in the certificate. + public SanForCert San { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerKind.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerKind.cs new file mode 100644 index 000000000000..a07da34a7488 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerKind.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.IoTOperations.Models +{ + /// CertManagerIssuerKind properties. + public readonly partial struct CertManagerIssuerKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CertManagerIssuerKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string IssuerValue = "Issuer"; + private const string ClusterIssuerValue = "ClusterIssuer"; + + /// Issuer kind. + public static CertManagerIssuerKind Issuer { get; } = new CertManagerIssuerKind(IssuerValue); + /// ClusterIssuer kind. + public static CertManagerIssuerKind ClusterIssuer { get; } = new CertManagerIssuerKind(ClusterIssuerValue); + /// Determines if two values are the same. + public static bool operator ==(CertManagerIssuerKind left, CertManagerIssuerKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CertManagerIssuerKind left, CertManagerIssuerKind right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CertManagerIssuerKind(string value) => new CertManagerIssuerKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CertManagerIssuerKind other && Equals(other); + /// + public bool Equals(CertManagerIssuerKind 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerRef.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerRef.Serialization.cs new file mode 100644 index 000000000000..d46fbc4f4644 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerRef.Serialization.cs @@ -0,0 +1,135 @@ +// 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.IoTOperations.Models +{ + public partial class CertManagerIssuerRef : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertManagerIssuerRef)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("group"u8); + writer.WriteStringValue(Group); + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CertManagerIssuerRef 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(CertManagerIssuerRef)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCertManagerIssuerRef(document.RootElement, options); + } + + internal static CertManagerIssuerRef DeserializeCertManagerIssuerRef(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string group = default; + CertManagerIssuerKind kind = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("group"u8)) + { + group = property.Value.GetString(); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = new CertManagerIssuerKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CertManagerIssuerRef(group, kind, name, 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); + default: + throw new FormatException($"The model {nameof(CertManagerIssuerRef)} does not support writing '{options.Format}' format."); + } + } + + CertManagerIssuerRef 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); + return DeserializeCertManagerIssuerRef(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CertManagerIssuerRef)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerRef.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerRef.cs new file mode 100644 index 000000000000..1a05a25db0ff --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerIssuerRef.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Cert-Manager issuerRef properties. + public partial class CertManagerIssuerRef + { + /// + /// 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 . + /// group of issuer. + /// kind of issuer (Issuer or ClusterIssuer). + /// name of issuer. + /// or is null. + public CertManagerIssuerRef(string group, CertManagerIssuerKind kind, string name) + { + Argument.AssertNotNull(group, nameof(group)); + Argument.AssertNotNull(name, nameof(name)); + + Group = group; + Kind = kind; + Name = name; + } + + /// Initializes a new instance of . + /// group of issuer. + /// kind of issuer (Issuer or ClusterIssuer). + /// name of issuer. + /// Keeps track of any properties unknown to the library. + internal CertManagerIssuerRef(string group, CertManagerIssuerKind kind, string name, IDictionary serializedAdditionalRawData) + { + Group = group; + Kind = kind; + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CertManagerIssuerRef() + { + } + + /// group of issuer. + public string Group { get; set; } + /// kind of issuer (Issuer or ClusterIssuer). + public CertManagerIssuerKind Kind { get; set; } + /// name of issuer. + public string Name { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerPrivateKey.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerPrivateKey.Serialization.cs new file mode 100644 index 000000000000..bf26ba71fc10 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerPrivateKey.Serialization.cs @@ -0,0 +1,127 @@ +// 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.IoTOperations.Models +{ + public partial class CertManagerPrivateKey : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertManagerPrivateKey)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("algorithm"u8); + writer.WriteStringValue(Algorithm.ToString()); + writer.WritePropertyName("rotationPolicy"u8); + writer.WriteStringValue(RotationPolicy.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CertManagerPrivateKey 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(CertManagerPrivateKey)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCertManagerPrivateKey(document.RootElement, options); + } + + internal static CertManagerPrivateKey DeserializeCertManagerPrivateKey(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PrivateKeyAlgorithm algorithm = default; + PrivateKeyRotationPolicy rotationPolicy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("algorithm"u8)) + { + algorithm = new PrivateKeyAlgorithm(property.Value.GetString()); + continue; + } + if (property.NameEquals("rotationPolicy"u8)) + { + rotationPolicy = new PrivateKeyRotationPolicy(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CertManagerPrivateKey(algorithm, rotationPolicy, 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); + default: + throw new FormatException($"The model {nameof(CertManagerPrivateKey)} does not support writing '{options.Format}' format."); + } + } + + CertManagerPrivateKey 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); + return DeserializeCertManagerPrivateKey(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CertManagerPrivateKey)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerPrivateKey.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerPrivateKey.cs new file mode 100644 index 000000000000..35eec05009f0 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CertManagerPrivateKey.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.IoTOperations.Models +{ + /// Cert Manager private key properties. + public partial class CertManagerPrivateKey + { + /// + /// 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 . + /// algorithm for private key. + /// cert-manager private key rotationPolicy. + public CertManagerPrivateKey(PrivateKeyAlgorithm algorithm, PrivateKeyRotationPolicy rotationPolicy) + { + Algorithm = algorithm; + RotationPolicy = rotationPolicy; + } + + /// Initializes a new instance of . + /// algorithm for private key. + /// cert-manager private key rotationPolicy. + /// Keeps track of any properties unknown to the library. + internal CertManagerPrivateKey(PrivateKeyAlgorithm algorithm, PrivateKeyRotationPolicy rotationPolicy, IDictionary serializedAdditionalRawData) + { + Algorithm = algorithm; + RotationPolicy = rotationPolicy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CertManagerPrivateKey() + { + } + + /// algorithm for private key. + public PrivateKeyAlgorithm Algorithm { get; set; } + /// cert-manager private key rotationPolicy. + public PrivateKeyRotationPolicy RotationPolicy { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ClientConfig.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ClientConfig.Serialization.cs new file mode 100644 index 000000000000..3260fc68bf8c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ClientConfig.Serialization.cs @@ -0,0 +1,208 @@ +// 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.IoTOperations.Models +{ + public partial class ClientConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ClientConfig)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(MaxSessionExpirySeconds)) + { + writer.WritePropertyName("maxSessionExpirySeconds"u8); + writer.WriteNumberValue(MaxSessionExpirySeconds.Value); + } + if (Optional.IsDefined(MaxMessageExpirySeconds)) + { + writer.WritePropertyName("maxMessageExpirySeconds"u8); + writer.WriteNumberValue(MaxMessageExpirySeconds.Value); + } + if (Optional.IsDefined(MaxPacketSizeBytes)) + { + writer.WritePropertyName("maxPacketSizeBytes"u8); + writer.WriteNumberValue(MaxPacketSizeBytes.Value); + } + if (Optional.IsDefined(SubscriberQueueLimit)) + { + writer.WritePropertyName("subscriberQueueLimit"u8); + writer.WriteObjectValue(SubscriberQueueLimit, options); + } + if (Optional.IsDefined(MaxReceiveMaximum)) + { + writer.WritePropertyName("maxReceiveMaximum"u8); + writer.WriteNumberValue(MaxReceiveMaximum.Value); + } + if (Optional.IsDefined(MaxKeepAliveSeconds)) + { + writer.WritePropertyName("maxKeepAliveSeconds"u8); + writer.WriteNumberValue(MaxKeepAliveSeconds.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ClientConfig 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(ClientConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeClientConfig(document.RootElement, options); + } + + internal static ClientConfig DeserializeClientConfig(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? maxSessionExpirySeconds = default; + int? maxMessageExpirySeconds = default; + int? maxPacketSizeBytes = default; + SubscriberQueueLimit subscriberQueueLimit = default; + int? maxReceiveMaximum = default; + int? maxKeepAliveSeconds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("maxSessionExpirySeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxSessionExpirySeconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("maxMessageExpirySeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxMessageExpirySeconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("maxPacketSizeBytes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxPacketSizeBytes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("subscriberQueueLimit"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + subscriberQueueLimit = SubscriberQueueLimit.DeserializeSubscriberQueueLimit(property.Value, options); + continue; + } + if (property.NameEquals("maxReceiveMaximum"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxReceiveMaximum = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("maxKeepAliveSeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxKeepAliveSeconds = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ClientConfig( + maxSessionExpirySeconds, + maxMessageExpirySeconds, + maxPacketSizeBytes, + subscriberQueueLimit, + maxReceiveMaximum, + maxKeepAliveSeconds, + 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); + default: + throw new FormatException($"The model {nameof(ClientConfig)} does not support writing '{options.Format}' format."); + } + } + + ClientConfig 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); + return DeserializeClientConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ClientConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ClientConfig.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ClientConfig.cs new file mode 100644 index 000000000000..ebfcf5bbd08d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ClientConfig.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.IoTOperations.Models +{ + /// The settings of Client Config. + public partial class ClientConfig + { + /// + /// 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 ClientConfig() + { + } + + /// Initializes a new instance of . + /// Upper bound of Session Expiry Interval, in seconds. + /// Upper bound of Message Expiry Interval, in seconds. + /// Max message size for a packet in Bytes. + /// The limit on the number of queued messages for a subscriber. + /// Upper bound of Receive Maximum that a client can request in the CONNECT packet. + /// Upper bound of a client's Keep Alive, in seconds. + /// Keeps track of any properties unknown to the library. + internal ClientConfig(int? maxSessionExpirySeconds, int? maxMessageExpirySeconds, int? maxPacketSizeBytes, SubscriberQueueLimit subscriberQueueLimit, int? maxReceiveMaximum, int? maxKeepAliveSeconds, IDictionary serializedAdditionalRawData) + { + MaxSessionExpirySeconds = maxSessionExpirySeconds; + MaxMessageExpirySeconds = maxMessageExpirySeconds; + MaxPacketSizeBytes = maxPacketSizeBytes; + SubscriberQueueLimit = subscriberQueueLimit; + MaxReceiveMaximum = maxReceiveMaximum; + MaxKeepAliveSeconds = maxKeepAliveSeconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Upper bound of Session Expiry Interval, in seconds. + public int? MaxSessionExpirySeconds { get; set; } + /// Upper bound of Message Expiry Interval, in seconds. + public int? MaxMessageExpirySeconds { get; set; } + /// Max message size for a packet in Bytes. + public int? MaxPacketSizeBytes { get; set; } + /// The limit on the number of queued messages for a subscriber. + public SubscriberQueueLimit SubscriberQueueLimit { get; set; } + /// Upper bound of Receive Maximum that a client can request in the CONNECT packet. + public int? MaxReceiveMaximum { get; set; } + /// Upper bound of a client's Keep Alive, in seconds. + public int? MaxKeepAliveSeconds { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CloudEventAttributeType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CloudEventAttributeType.cs new file mode 100644 index 000000000000..9187546111d5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/CloudEventAttributeType.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.IoTOperations.Models +{ + /// How to map events to the cloud. + public readonly partial struct CloudEventAttributeType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CloudEventAttributeType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PropagateValue = "Propagate"; + private const string CreateOrRemapValue = "CreateOrRemap"; + + /// Propagate type. + public static CloudEventAttributeType Propagate { get; } = new CloudEventAttributeType(PropagateValue); + /// CreateOrRemap type. + public static CloudEventAttributeType CreateOrRemap { get; } = new CloudEventAttributeType(CreateOrRemapValue); + /// Determines if two values are the same. + public static bool operator ==(CloudEventAttributeType left, CloudEventAttributeType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CloudEventAttributeType left, CloudEventAttributeType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CloudEventAttributeType(string value) => new CloudEventAttributeType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CloudEventAttributeType other && Equals(other); + /// + public bool Equals(CloudEventAttributeType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Components.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Components.Serialization.cs new file mode 100644 index 000000000000..ef3df0f96d1a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Components.Serialization.cs @@ -0,0 +1,192 @@ +// 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.IoTOperations.Models +{ + public partial class Components : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Components)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Adr)) + { + writer.WritePropertyName("adr"u8); + writer.WriteObjectValue(Adr, options); + } + if (Optional.IsDefined(Akri)) + { + writer.WritePropertyName("akri"u8); + writer.WriteObjectValue(Akri, options); + } + if (Optional.IsDefined(Connectors)) + { + writer.WritePropertyName("connectors"u8); + writer.WriteObjectValue(Connectors, options); + } + if (Optional.IsDefined(Dataflows)) + { + writer.WritePropertyName("dataflows"u8); + writer.WriteObjectValue(Dataflows, options); + } + if (Optional.IsDefined(SchemaRegistry)) + { + writer.WritePropertyName("schemaRegistry"u8); + writer.WriteObjectValue(SchemaRegistry, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Components 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(Components)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeComponents(document.RootElement, options); + } + + internal static Components DeserializeComponents(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AdrProperties adr = default; + AkriInstanceProperties akri = default; + ConnectorInstanceProperties connectors = default; + DataflowInstanceProperties dataflows = default; + SchemaRegistryInstanceProperties schemaRegistry = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("adr"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + adr = AdrProperties.DeserializeAdrProperties(property.Value, options); + continue; + } + if (property.NameEquals("akri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + akri = AkriInstanceProperties.DeserializeAkriInstanceProperties(property.Value, options); + continue; + } + if (property.NameEquals("connectors"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + connectors = ConnectorInstanceProperties.DeserializeConnectorInstanceProperties(property.Value, options); + continue; + } + if (property.NameEquals("dataflows"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataflows = DataflowInstanceProperties.DeserializeDataflowInstanceProperties(property.Value, options); + continue; + } + if (property.NameEquals("schemaRegistry"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + schemaRegistry = SchemaRegistryInstanceProperties.DeserializeSchemaRegistryInstanceProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Components( + adr, + akri, + connectors, + dataflows, + schemaRegistry, + 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); + default: + throw new FormatException($"The model {nameof(Components)} does not support writing '{options.Format}' format."); + } + } + + Components 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); + return DeserializeComponents(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Components)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Components.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Components.cs new file mode 100644 index 000000000000..88948b78078d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Components.cs @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// The configuration for components of the AIO Instance. + public partial class Components + { + /// + /// 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 Components() + { + } + + /// Initializes a new instance of . + /// The properties of the ADR instance. + /// The properties of the AKRI instance. + /// The properties of the connectors instance. + /// The properties of the dataflows instance. + /// The properties of the device provisioning instance. + /// Keeps track of any properties unknown to the library. + internal Components(AdrProperties adr, AkriInstanceProperties akri, ConnectorInstanceProperties connectors, DataflowInstanceProperties dataflows, SchemaRegistryInstanceProperties schemaRegistry, IDictionary serializedAdditionalRawData) + { + Adr = adr; + Akri = akri; + Connectors = connectors; + Dataflows = dataflows; + SchemaRegistry = schemaRegistry; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The properties of the ADR instance. + internal AdrProperties Adr { get; set; } + /// This determines if the ADR service is enabled. + public OperationalMode? AdrState + { + get => Adr is null ? default(OperationalMode?) : Adr.State; + set + { + Adr = value.HasValue ? new AdrProperties(value.Value) : null; + } + } + + /// The properties of the AKRI instance. + internal AkriInstanceProperties Akri { get; set; } + /// This determines if the AKRI service is enabled. + public OperationalMode? AkriState + { + get => Akri is null ? default(OperationalMode?) : Akri.State; + set + { + Akri = value.HasValue ? new AkriInstanceProperties(value.Value) : null; + } + } + + /// The properties of the connectors instance. + internal ConnectorInstanceProperties Connectors { get; set; } + /// This determines if the Connector service is enabled. + public OperationalMode? ConnectorsState + { + get => Connectors is null ? default(OperationalMode?) : Connectors.State; + set + { + Connectors = value.HasValue ? new ConnectorInstanceProperties(value.Value) : null; + } + } + + /// The properties of the dataflows instance. + internal DataflowInstanceProperties Dataflows { get; set; } + /// This determines if the Dataflow service is enabled. + public OperationalMode? DataflowsState + { + get => Dataflows is null ? default(OperationalMode?) : Dataflows.State; + set + { + Dataflows = value.HasValue ? new DataflowInstanceProperties(value.Value) : null; + } + } + + /// The properties of the device provisioning instance. + internal SchemaRegistryInstanceProperties SchemaRegistry { get; set; } + /// This determines if the Schema Registry service is enabled. + public OperationalMode? SchemaRegistryState + { + get => SchemaRegistry is null ? default(OperationalMode?) : SchemaRegistry.State; + set + { + SchemaRegistry = value.HasValue ? new SchemaRegistryInstanceProperties(value.Value) : null; + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ConnectorInstanceProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ConnectorInstanceProperties.Serialization.cs new file mode 100644 index 000000000000..6d4b8b69b0d0 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ConnectorInstanceProperties.Serialization.cs @@ -0,0 +1,119 @@ +// 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.IoTOperations.Models +{ + internal partial class ConnectorInstanceProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectorInstanceProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ConnectorInstanceProperties 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(ConnectorInstanceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectorInstanceProperties(document.RootElement, options); + } + + internal static ConnectorInstanceProperties DeserializeConnectorInstanceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode state = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("state"u8)) + { + state = new OperationalMode(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectorInstanceProperties(state, 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); + default: + throw new FormatException($"The model {nameof(ConnectorInstanceProperties)} does not support writing '{options.Format}' format."); + } + } + + ConnectorInstanceProperties 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); + return DeserializeConnectorInstanceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectorInstanceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ConnectorInstanceProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ConnectorInstanceProperties.cs new file mode 100644 index 000000000000..dd30a18d06a7 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ConnectorInstanceProperties.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.IoTOperations.Models +{ + /// The properties of a Connector instance. + internal partial class ConnectorInstanceProperties + { + /// + /// 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 . + /// This determines if the Connector service is enabled. + public ConnectorInstanceProperties(OperationalMode state) + { + State = state; + } + + /// Initializes a new instance of . + /// This determines if the Connector service is enabled. + /// Keeps track of any properties unknown to the library. + internal ConnectorInstanceProperties(OperationalMode state, IDictionary serializedAdditionalRawData) + { + State = state; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ConnectorInstanceProperties() + { + } + + /// This determines if the Connector service is enabled. + public OperationalMode State { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataExplorerAuthMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataExplorerAuthMethod.cs new file mode 100644 index 000000000000..093645c8470a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataExplorerAuthMethod.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.IoTOperations.Models +{ + /// DataflowEndpoint Data Explorer Authentication Method properties. + public readonly partial struct DataExplorerAuthMethod : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataExplorerAuthMethod(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SystemAssignedManagedIdentityValue = "SystemAssignedManagedIdentity"; + private const string UserAssignedManagedIdentityValue = "UserAssignedManagedIdentity"; + + /// SystemAssignedManagedIdentity type. + public static DataExplorerAuthMethod SystemAssignedManagedIdentity { get; } = new DataExplorerAuthMethod(SystemAssignedManagedIdentityValue); + /// UserAssignedManagedIdentity type. + public static DataExplorerAuthMethod UserAssignedManagedIdentity { get; } = new DataExplorerAuthMethod(UserAssignedManagedIdentityValue); + /// Determines if two values are the same. + public static bool operator ==(DataExplorerAuthMethod left, DataExplorerAuthMethod right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataExplorerAuthMethod left, DataExplorerAuthMethod right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DataExplorerAuthMethod(string value) => new DataExplorerAuthMethod(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataExplorerAuthMethod other && Equals(other); + /// + public bool Equals(DataExplorerAuthMethod 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataLakeStorageAuthMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataLakeStorageAuthMethod.cs new file mode 100644 index 000000000000..b4e466761eba --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataLakeStorageAuthMethod.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.IoTOperations.Models +{ + /// DataflowEndpoint Data Lake Storage Authentication Method properties. + public readonly partial struct DataLakeStorageAuthMethod : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataLakeStorageAuthMethod(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SystemAssignedManagedIdentityValue = "SystemAssignedManagedIdentity"; + private const string UserAssignedManagedIdentityValue = "UserAssignedManagedIdentity"; + private const string AccessTokenValue = "AccessToken"; + + /// SystemAssignedManagedIdentity type. + public static DataLakeStorageAuthMethod SystemAssignedManagedIdentity { get; } = new DataLakeStorageAuthMethod(SystemAssignedManagedIdentityValue); + /// UserAssignedManagedIdentity type. + public static DataLakeStorageAuthMethod UserAssignedManagedIdentity { get; } = new DataLakeStorageAuthMethod(UserAssignedManagedIdentityValue); + /// AccessToken Option. + public static DataLakeStorageAuthMethod AccessToken { get; } = new DataLakeStorageAuthMethod(AccessTokenValue); + /// Determines if two values are the same. + public static bool operator ==(DataLakeStorageAuthMethod left, DataLakeStorageAuthMethod right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataLakeStorageAuthMethod left, DataLakeStorageAuthMethod right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DataLakeStorageAuthMethod(string value) => new DataLakeStorageAuthMethod(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataLakeStorageAuthMethod other && Equals(other); + /// + public bool Equals(DataLakeStorageAuthMethod 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationDataset.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationDataset.Serialization.cs new file mode 100644 index 000000000000..6957b038693f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationDataset.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.IoTOperations.Models +{ + public partial class DataflowBuiltInTransformationDataset : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationDataset)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(SchemaRef)) + { + writer.WritePropertyName("schemaRef"u8); + writer.WriteStringValue(SchemaRef); + } + writer.WritePropertyName("inputs"u8); + writer.WriteStartArray(); + foreach (var item in Inputs) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(Expression)) + { + writer.WritePropertyName("expression"u8); + writer.WriteStringValue(Expression); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowBuiltInTransformationDataset 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(DataflowBuiltInTransformationDataset)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowBuiltInTransformationDataset(document.RootElement, options); + } + + internal static DataflowBuiltInTransformationDataset DeserializeDataflowBuiltInTransformationDataset(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string key = default; + string description = default; + string schemaRef = default; + IList inputs = default; + string expression = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("key"u8)) + { + key = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("schemaRef"u8)) + { + schemaRef = property.Value.GetString(); + continue; + } + if (property.NameEquals("inputs"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + inputs = array; + continue; + } + if (property.NameEquals("expression"u8)) + { + expression = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowBuiltInTransformationDataset( + key, + description, + schemaRef, + inputs, + expression, + 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); + default: + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationDataset)} does not support writing '{options.Format}' format."); + } + } + + DataflowBuiltInTransformationDataset 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); + return DeserializeDataflowBuiltInTransformationDataset(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationDataset)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationDataset.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationDataset.cs new file mode 100644 index 000000000000..0270fee0286a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationDataset.cs @@ -0,0 +1,95 @@ +// 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.IoTOperations.Models +{ + /// Dataflow BuiltIn Transformation dataset properties. + public partial class DataflowBuiltInTransformationDataset + { + /// + /// 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 key of the dataset. + /// List of fields for enriching from the Broker State Store. + /// or is null. + public DataflowBuiltInTransformationDataset(string key, IEnumerable inputs) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(inputs, nameof(inputs)); + + Key = key; + Inputs = inputs.ToList(); + } + + /// Initializes a new instance of . + /// The key of the dataset. + /// A user provided optional description of the dataset. + /// The reference to the schema that describes the dataset. Allowed: JSON Schema/draft-7. + /// List of fields for enriching from the Broker State Store. + /// Condition to enrich data from Broker State Store. Example: $1 < 0 || $1 > $2 (Assuming inputs section $1 and $2 are provided). + /// Keeps track of any properties unknown to the library. + internal DataflowBuiltInTransformationDataset(string key, string description, string schemaRef, IList inputs, string expression, IDictionary serializedAdditionalRawData) + { + Key = key; + Description = description; + SchemaRef = schemaRef; + Inputs = inputs; + Expression = expression; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowBuiltInTransformationDataset() + { + } + + /// The key of the dataset. + public string Key { get; set; } + /// A user provided optional description of the dataset. + public string Description { get; set; } + /// The reference to the schema that describes the dataset. Allowed: JSON Schema/draft-7. + public string SchemaRef { get; set; } + /// List of fields for enriching from the Broker State Store. + public IList Inputs { get; } + /// Condition to enrich data from Broker State Store. Example: $1 < 0 || $1 > $2 (Assuming inputs section $1 and $2 are provided). + public string Expression { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationFilter.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationFilter.Serialization.cs new file mode 100644 index 000000000000..b0f5c011f18b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationFilter.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.IoTOperations.Models +{ + public partial class DataflowBuiltInTransformationFilter : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationFilter)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("inputs"u8); + writer.WriteStartArray(); + foreach (var item in Inputs) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("expression"u8); + writer.WriteStringValue(Expression); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowBuiltInTransformationFilter 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(DataflowBuiltInTransformationFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowBuiltInTransformationFilter(document.RootElement, options); + } + + internal static DataflowBuiltInTransformationFilter DeserializeDataflowBuiltInTransformationFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + FilterType? type = default; + string description = default; + IList inputs = default; + string expression = 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 FilterType(property.Value.GetString()); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("inputs"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + inputs = array; + continue; + } + if (property.NameEquals("expression"u8)) + { + expression = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowBuiltInTransformationFilter(type, description, inputs, expression, 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); + default: + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationFilter)} does not support writing '{options.Format}' format."); + } + } + + DataflowBuiltInTransformationFilter 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); + return DeserializeDataflowBuiltInTransformationFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationFilter)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationFilter.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationFilter.cs new file mode 100644 index 000000000000..c95447d44c52 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationFilter.cs @@ -0,0 +1,91 @@ +// 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.IoTOperations.Models +{ + /// Dataflow BuiltIn Transformation filter properties. + public partial class DataflowBuiltInTransformationFilter + { + /// + /// 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 . + /// List of fields for filtering in JSON path expression. + /// Condition to filter data. Can reference input fields with {n} where n is the index of the input field starting from 1. Example: $1 < 0 || $1 > $2 (Assuming inputs section $1 and $2 are provided). + /// or is null. + public DataflowBuiltInTransformationFilter(IEnumerable inputs, string expression) + { + Argument.AssertNotNull(inputs, nameof(inputs)); + Argument.AssertNotNull(expression, nameof(expression)); + + Inputs = inputs.ToList(); + Expression = expression; + } + + /// Initializes a new instance of . + /// The type of dataflow operation. + /// A user provided optional description of the filter. + /// List of fields for filtering in JSON path expression. + /// Condition to filter data. Can reference input fields with {n} where n is the index of the input field starting from 1. Example: $1 < 0 || $1 > $2 (Assuming inputs section $1 and $2 are provided). + /// Keeps track of any properties unknown to the library. + internal DataflowBuiltInTransformationFilter(FilterType? type, string description, IList inputs, string expression, IDictionary serializedAdditionalRawData) + { + Type = type; + Description = description; + Inputs = inputs; + Expression = expression; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowBuiltInTransformationFilter() + { + } + + /// The type of dataflow operation. + public FilterType? Type { get; set; } + /// A user provided optional description of the filter. + public string Description { get; set; } + /// List of fields for filtering in JSON path expression. + public IList Inputs { get; } + /// Condition to filter data. Can reference input fields with {n} where n is the index of the input field starting from 1. Example: $1 < 0 || $1 > $2 (Assuming inputs section $1 and $2 are provided). + public string Expression { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationMap.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationMap.Serialization.cs new file mode 100644 index 000000000000..7bfb0fa343ca --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationMap.Serialization.cs @@ -0,0 +1,180 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowBuiltInTransformationMap : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationMap)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("inputs"u8); + writer.WriteStartArray(); + foreach (var item in Inputs) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(Expression)) + { + writer.WritePropertyName("expression"u8); + writer.WriteStringValue(Expression); + } + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowBuiltInTransformationMap 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(DataflowBuiltInTransformationMap)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowBuiltInTransformationMap(document.RootElement, options); + } + + internal static DataflowBuiltInTransformationMap DeserializeDataflowBuiltInTransformationMap(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowMappingType? type = default; + string description = default; + IList inputs = default; + string expression = default; + string output = 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 DataflowMappingType(property.Value.GetString()); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("inputs"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + inputs = array; + continue; + } + if (property.NameEquals("expression"u8)) + { + expression = property.Value.GetString(); + continue; + } + if (property.NameEquals("output"u8)) + { + output = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowBuiltInTransformationMap( + type, + description, + inputs, + expression, + output, + 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); + default: + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationMap)} does not support writing '{options.Format}' format."); + } + } + + DataflowBuiltInTransformationMap 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); + return DeserializeDataflowBuiltInTransformationMap(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationMap)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationMap.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationMap.cs new file mode 100644 index 000000000000..b8af2195825c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationMap.cs @@ -0,0 +1,95 @@ +// 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.IoTOperations.Models +{ + /// Dataflow BuiltIn Transformation map properties. + public partial class DataflowBuiltInTransformationMap + { + /// + /// 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 . + /// List of fields for mapping in JSON path expression. + /// Where and how the input fields to be organized in the output record. + /// or is null. + public DataflowBuiltInTransformationMap(IEnumerable inputs, string output) + { + Argument.AssertNotNull(inputs, nameof(inputs)); + Argument.AssertNotNull(output, nameof(output)); + + Inputs = inputs.ToList(); + Output = output; + } + + /// Initializes a new instance of . + /// Type of transformation. + /// A user provided optional description of the mapping function. + /// List of fields for mapping in JSON path expression. + /// Modify the inputs field(s) to the final output field. Example: $1 * 2.2 (Assuming inputs section $1 is provided). + /// Where and how the input fields to be organized in the output record. + /// Keeps track of any properties unknown to the library. + internal DataflowBuiltInTransformationMap(DataflowMappingType? type, string description, IList inputs, string expression, string output, IDictionary serializedAdditionalRawData) + { + Type = type; + Description = description; + Inputs = inputs; + Expression = expression; + Output = output; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowBuiltInTransformationMap() + { + } + + /// Type of transformation. + public DataflowMappingType? Type { get; set; } + /// A user provided optional description of the mapping function. + public string Description { get; set; } + /// List of fields for mapping in JSON path expression. + public IList Inputs { get; } + /// Modify the inputs field(s) to the final output field. Example: $1 * 2.2 (Assuming inputs section $1 is provided). + public string Expression { get; set; } + /// Where and how the input fields to be organized in the output record. + public string Output { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationSettings.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationSettings.Serialization.cs new file mode 100644 index 000000000000..792152f469ed --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationSettings.Serialization.cs @@ -0,0 +1,218 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowBuiltInTransformationSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(SerializationFormat)) + { + writer.WritePropertyName("serializationFormat"u8); + writer.WriteStringValue(SerializationFormat.Value.ToString()); + } + if (Optional.IsDefined(SchemaRef)) + { + writer.WritePropertyName("schemaRef"u8); + writer.WriteStringValue(SchemaRef); + } + if (Optional.IsCollectionDefined(Datasets)) + { + writer.WritePropertyName("datasets"u8); + writer.WriteStartArray(); + foreach (var item in Datasets) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Filter)) + { + writer.WritePropertyName("filter"u8); + writer.WriteStartArray(); + foreach (var item in Filter) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Map)) + { + writer.WritePropertyName("map"u8); + writer.WriteStartArray(); + foreach (var item in Map) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowBuiltInTransformationSettings 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(DataflowBuiltInTransformationSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowBuiltInTransformationSettings(document.RootElement, options); + } + + internal static DataflowBuiltInTransformationSettings DeserializeDataflowBuiltInTransformationSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TransformationSerializationFormat? serializationFormat = default; + string schemaRef = default; + IList datasets = default; + IList filter = default; + IList map = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("serializationFormat"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + serializationFormat = new TransformationSerializationFormat(property.Value.GetString()); + continue; + } + if (property.NameEquals("schemaRef"u8)) + { + schemaRef = property.Value.GetString(); + continue; + } + if (property.NameEquals("datasets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DataflowBuiltInTransformationDataset.DeserializeDataflowBuiltInTransformationDataset(item, options)); + } + datasets = array; + continue; + } + if (property.NameEquals("filter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DataflowBuiltInTransformationFilter.DeserializeDataflowBuiltInTransformationFilter(item, options)); + } + filter = array; + continue; + } + if (property.NameEquals("map"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DataflowBuiltInTransformationMap.DeserializeDataflowBuiltInTransformationMap(item, options)); + } + map = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowBuiltInTransformationSettings( + serializationFormat, + schemaRef, + datasets ?? new ChangeTrackingList(), + filter ?? new ChangeTrackingList(), + map ?? 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); + default: + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationSettings)} does not support writing '{options.Format}' format."); + } + } + + DataflowBuiltInTransformationSettings 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); + return DeserializeDataflowBuiltInTransformationSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationSettings.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationSettings.cs new file mode 100644 index 000000000000..a97cbd5a1ea8 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowBuiltInTransformationSettings.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Dataflow BuiltIn Transformation properties. + public partial class DataflowBuiltInTransformationSettings + { + /// + /// 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 DataflowBuiltInTransformationSettings() + { + Datasets = new ChangeTrackingList(); + Filter = new ChangeTrackingList(); + Map = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Serialization format. Optional; defaults to JSON. Allowed value JSON Schema/draft-7, Parquet. Default: Json. + /// Reference to the schema that describes the output of the transformation. + /// Enrich data from Broker State Store. Dataset references a key in Broker State Store. + /// Filters input record or datapoints based on condition. + /// Maps input to output message. + /// Keeps track of any properties unknown to the library. + internal DataflowBuiltInTransformationSettings(TransformationSerializationFormat? serializationFormat, string schemaRef, IList datasets, IList filter, IList map, IDictionary serializedAdditionalRawData) + { + SerializationFormat = serializationFormat; + SchemaRef = schemaRef; + Datasets = datasets; + Filter = filter; + Map = map; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Serialization format. Optional; defaults to JSON. Allowed value JSON Schema/draft-7, Parquet. Default: Json. + public TransformationSerializationFormat? SerializationFormat { get; set; } + /// Reference to the schema that describes the output of the transformation. + public string SchemaRef { get; set; } + /// Enrich data from Broker State Store. Dataset references a key in Broker State Store. + public IList Datasets { get; } + /// Filters input record or datapoints based on condition. + public IList Filter { get; } + /// Maps input to output message. + public IList Map { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowDestinationOperationSettings.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowDestinationOperationSettings.Serialization.cs new file mode 100644 index 000000000000..7637f2b471cb --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowDestinationOperationSettings.Serialization.cs @@ -0,0 +1,127 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowDestinationOperationSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowDestinationOperationSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("endpointRef"u8); + writer.WriteStringValue(EndpointRef); + writer.WritePropertyName("dataDestination"u8); + writer.WriteStringValue(DataDestination); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowDestinationOperationSettings 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(DataflowDestinationOperationSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowDestinationOperationSettings(document.RootElement, options); + } + + internal static DataflowDestinationOperationSettings DeserializeDataflowDestinationOperationSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string endpointRef = default; + string dataDestination = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("endpointRef"u8)) + { + endpointRef = property.Value.GetString(); + continue; + } + if (property.NameEquals("dataDestination"u8)) + { + dataDestination = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowDestinationOperationSettings(endpointRef, dataDestination, 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); + default: + throw new FormatException($"The model {nameof(DataflowDestinationOperationSettings)} does not support writing '{options.Format}' format."); + } + } + + DataflowDestinationOperationSettings 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); + return DeserializeDataflowDestinationOperationSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowDestinationOperationSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowDestinationOperationSettings.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowDestinationOperationSettings.cs new file mode 100644 index 000000000000..288b6a1c4c26 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowDestinationOperationSettings.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.IoTOperations.Models +{ + /// Dataflow Destination Operation properties. + public partial class DataflowDestinationOperationSettings + { + /// + /// 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 . + /// Reference to the Endpoint CR. Can be of Broker, Kafka, Fabric, ADLS, ADX type. + /// Destination location, can be a topic or table name. Supports dynamic values with $topic, $systemProperties, $userProperties, $payload, $context, and $subscription. + /// or is null. + public DataflowDestinationOperationSettings(string endpointRef, string dataDestination) + { + Argument.AssertNotNull(endpointRef, nameof(endpointRef)); + Argument.AssertNotNull(dataDestination, nameof(dataDestination)); + + EndpointRef = endpointRef; + DataDestination = dataDestination; + } + + /// Initializes a new instance of . + /// Reference to the Endpoint CR. Can be of Broker, Kafka, Fabric, ADLS, ADX type. + /// Destination location, can be a topic or table name. Supports dynamic values with $topic, $systemProperties, $userProperties, $payload, $context, and $subscription. + /// Keeps track of any properties unknown to the library. + internal DataflowDestinationOperationSettings(string endpointRef, string dataDestination, IDictionary serializedAdditionalRawData) + { + EndpointRef = endpointRef; + DataDestination = dataDestination; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowDestinationOperationSettings() + { + } + + /// Reference to the Endpoint CR. Can be of Broker, Kafka, Fabric, ADLS, ADX type. + public string EndpointRef { get; set; } + /// Destination location, can be a topic or table name. Supports dynamic values with $topic, $systemProperties, $userProperties, $payload, $context, and $subscription. + public string DataDestination { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationAccessToken.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationAccessToken.Serialization.cs new file mode 100644 index 000000000000..b18165b9bbee --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationAccessToken.Serialization.cs @@ -0,0 +1,119 @@ +// 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.IoTOperations.Models +{ + internal partial class DataflowEndpointAuthenticationAccessToken : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationAccessToken)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("secretRef"u8); + writer.WriteStringValue(SecretRef); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointAuthenticationAccessToken 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(DataflowEndpointAuthenticationAccessToken)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointAuthenticationAccessToken(document.RootElement, options); + } + + internal static DataflowEndpointAuthenticationAccessToken DeserializeDataflowEndpointAuthenticationAccessToken(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string secretRef = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("secretRef"u8)) + { + secretRef = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointAuthenticationAccessToken(secretRef, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationAccessToken)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointAuthenticationAccessToken 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); + return DeserializeDataflowEndpointAuthenticationAccessToken(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationAccessToken)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationAccessToken.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationAccessToken.cs new file mode 100644 index 000000000000..69bea2335018 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationAccessToken.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.IoTOperations.Models +{ + /// DataflowEndpoint Authentication Access Token properties. + internal partial class DataflowEndpointAuthenticationAccessToken + { + /// + /// 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 . + /// Token secret name. + /// is null. + public DataflowEndpointAuthenticationAccessToken(string secretRef) + { + Argument.AssertNotNull(secretRef, nameof(secretRef)); + + SecretRef = secretRef; + } + + /// Initializes a new instance of . + /// Token secret name. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointAuthenticationAccessToken(string secretRef, IDictionary serializedAdditionalRawData) + { + SecretRef = secretRef; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointAuthenticationAccessToken() + { + } + + /// Token secret name. + public string SecretRef { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSasl.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSasl.Serialization.cs new file mode 100644 index 000000000000..9176b182f02a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSasl.Serialization.cs @@ -0,0 +1,127 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointAuthenticationSasl : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationSasl)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("saslType"u8); + writer.WriteStringValue(SaslType.ToString()); + writer.WritePropertyName("secretRef"u8); + writer.WriteStringValue(SecretRef); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointAuthenticationSasl 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(DataflowEndpointAuthenticationSasl)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointAuthenticationSasl(document.RootElement, options); + } + + internal static DataflowEndpointAuthenticationSasl DeserializeDataflowEndpointAuthenticationSasl(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowEndpointAuthenticationSaslType saslType = default; + string secretRef = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("saslType"u8)) + { + saslType = new DataflowEndpointAuthenticationSaslType(property.Value.GetString()); + continue; + } + if (property.NameEquals("secretRef"u8)) + { + secretRef = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointAuthenticationSasl(saslType, secretRef, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationSasl)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointAuthenticationSasl 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); + return DeserializeDataflowEndpointAuthenticationSasl(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationSasl)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSasl.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSasl.cs new file mode 100644 index 000000000000..8fd546f5c26c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSasl.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.IoTOperations.Models +{ + /// DataflowEndpoint Authentication Sasl properties. + public partial class DataflowEndpointAuthenticationSasl + { + /// + /// 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 . + /// Type of SASL authentication. Can be PLAIN, SCRAM-SHA-256, or SCRAM-SHA-512. + /// Token secret name. + /// is null. + public DataflowEndpointAuthenticationSasl(DataflowEndpointAuthenticationSaslType saslType, string secretRef) + { + Argument.AssertNotNull(secretRef, nameof(secretRef)); + + SaslType = saslType; + SecretRef = secretRef; + } + + /// Initializes a new instance of . + /// Type of SASL authentication. Can be PLAIN, SCRAM-SHA-256, or SCRAM-SHA-512. + /// Token secret name. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointAuthenticationSasl(DataflowEndpointAuthenticationSaslType saslType, string secretRef, IDictionary serializedAdditionalRawData) + { + SaslType = saslType; + SecretRef = secretRef; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointAuthenticationSasl() + { + } + + /// Type of SASL authentication. Can be PLAIN, SCRAM-SHA-256, or SCRAM-SHA-512. + public DataflowEndpointAuthenticationSaslType SaslType { get; set; } + /// Token secret name. + public string SecretRef { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSaslType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSaslType.cs new file mode 100644 index 000000000000..b1b02e064993 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSaslType.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.IoTOperations.Models +{ + /// DataflowEndpoint Authentication Sasl Type properties. + public readonly partial struct DataflowEndpointAuthenticationSaslType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataflowEndpointAuthenticationSaslType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PlainValue = "Plain"; + private const string ScramSha256Value = "ScramSha256"; + private const string ScramSha512Value = "ScramSha512"; + + /// PLAIN Type. + public static DataflowEndpointAuthenticationSaslType Plain { get; } = new DataflowEndpointAuthenticationSaslType(PlainValue); + /// SCRAM_SHA_256 Type. + public static DataflowEndpointAuthenticationSaslType ScramSha256 { get; } = new DataflowEndpointAuthenticationSaslType(ScramSha256Value); + /// SCRAM_SHA_512 Type. + public static DataflowEndpointAuthenticationSaslType ScramSha512 { get; } = new DataflowEndpointAuthenticationSaslType(ScramSha512Value); + /// Determines if two values are the same. + public static bool operator ==(DataflowEndpointAuthenticationSaslType left, DataflowEndpointAuthenticationSaslType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataflowEndpointAuthenticationSaslType left, DataflowEndpointAuthenticationSaslType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DataflowEndpointAuthenticationSaslType(string value) => new DataflowEndpointAuthenticationSaslType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataflowEndpointAuthenticationSaslType other && Equals(other); + /// + public bool Equals(DataflowEndpointAuthenticationSaslType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationServiceAccountToken.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationServiceAccountToken.Serialization.cs new file mode 100644 index 000000000000..35ddc4defd4d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationServiceAccountToken.Serialization.cs @@ -0,0 +1,119 @@ +// 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.IoTOperations.Models +{ + internal partial class DataflowEndpointAuthenticationServiceAccountToken : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationServiceAccountToken)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("audience"u8); + writer.WriteStringValue(Audience); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointAuthenticationServiceAccountToken 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(DataflowEndpointAuthenticationServiceAccountToken)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointAuthenticationServiceAccountToken(document.RootElement, options); + } + + internal static DataflowEndpointAuthenticationServiceAccountToken DeserializeDataflowEndpointAuthenticationServiceAccountToken(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string audience = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("audience"u8)) + { + audience = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointAuthenticationServiceAccountToken(audience, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationServiceAccountToken)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointAuthenticationServiceAccountToken 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); + return DeserializeDataflowEndpointAuthenticationServiceAccountToken(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationServiceAccountToken)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationServiceAccountToken.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationServiceAccountToken.cs new file mode 100644 index 000000000000..38bee6a4d38f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationServiceAccountToken.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.IoTOperations.Models +{ + /// Service Account Token for BrokerAuthentication. + internal partial class DataflowEndpointAuthenticationServiceAccountToken + { + /// + /// 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 . + /// Audience of the service account. Optional, defaults to the broker internal service account audience. + /// is null. + public DataflowEndpointAuthenticationServiceAccountToken(string audience) + { + Argument.AssertNotNull(audience, nameof(audience)); + + Audience = audience; + } + + /// Initializes a new instance of . + /// Audience of the service account. Optional, defaults to the broker internal service account audience. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointAuthenticationServiceAccountToken(string audience, IDictionary serializedAdditionalRawData) + { + Audience = audience; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointAuthenticationServiceAccountToken() + { + } + + /// Audience of the service account. Optional, defaults to the broker internal service account audience. + public string Audience { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSystemAssignedManagedIdentity.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSystemAssignedManagedIdentity.Serialization.cs new file mode 100644 index 000000000000..758a8abc6733 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSystemAssignedManagedIdentity.Serialization.cs @@ -0,0 +1,122 @@ +// 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.IoTOperations.Models +{ + internal partial class DataflowEndpointAuthenticationSystemAssignedManagedIdentity : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationSystemAssignedManagedIdentity)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Audience)) + { + writer.WritePropertyName("audience"u8); + writer.WriteStringValue(Audience); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointAuthenticationSystemAssignedManagedIdentity 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(DataflowEndpointAuthenticationSystemAssignedManagedIdentity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointAuthenticationSystemAssignedManagedIdentity(document.RootElement, options); + } + + internal static DataflowEndpointAuthenticationSystemAssignedManagedIdentity DeserializeDataflowEndpointAuthenticationSystemAssignedManagedIdentity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string audience = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("audience"u8)) + { + audience = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointAuthenticationSystemAssignedManagedIdentity(audience, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationSystemAssignedManagedIdentity)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointAuthenticationSystemAssignedManagedIdentity 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); + return DeserializeDataflowEndpointAuthenticationSystemAssignedManagedIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationSystemAssignedManagedIdentity)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSystemAssignedManagedIdentity.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSystemAssignedManagedIdentity.cs new file mode 100644 index 000000000000..3cc95969dc1c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationSystemAssignedManagedIdentity.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.IoTOperations.Models +{ + /// DataflowEndpoint Authentication SystemAssignedManagedIdentity properties. + internal partial class DataflowEndpointAuthenticationSystemAssignedManagedIdentity + { + /// + /// 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 DataflowEndpointAuthenticationSystemAssignedManagedIdentity() + { + } + + /// Initializes a new instance of . + /// Audience of the service to authenticate against. Optional; defaults to the audience for Service host configuration. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointAuthenticationSystemAssignedManagedIdentity(string audience, IDictionary serializedAdditionalRawData) + { + Audience = audience; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Audience of the service to authenticate against. Optional; defaults to the audience for Service host configuration. + public string Audience { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationUserAssignedManagedIdentity.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationUserAssignedManagedIdentity.Serialization.cs new file mode 100644 index 000000000000..661c38e45391 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationUserAssignedManagedIdentity.Serialization.cs @@ -0,0 +1,138 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointAuthenticationUserAssignedManagedIdentity : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationUserAssignedManagedIdentity)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("clientId"u8); + writer.WriteStringValue(ClientId); + if (Optional.IsDefined(Scope)) + { + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + } + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointAuthenticationUserAssignedManagedIdentity 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(DataflowEndpointAuthenticationUserAssignedManagedIdentity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointAuthenticationUserAssignedManagedIdentity(document.RootElement, options); + } + + internal static DataflowEndpointAuthenticationUserAssignedManagedIdentity DeserializeDataflowEndpointAuthenticationUserAssignedManagedIdentity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string clientId = default; + string scope = default; + string tenantId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("clientId"u8)) + { + clientId = property.Value.GetString(); + continue; + } + if (property.NameEquals("scope"u8)) + { + scope = property.Value.GetString(); + continue; + } + if (property.NameEquals("tenantId"u8)) + { + tenantId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointAuthenticationUserAssignedManagedIdentity(clientId, scope, tenantId, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationUserAssignedManagedIdentity)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointAuthenticationUserAssignedManagedIdentity 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); + return DeserializeDataflowEndpointAuthenticationUserAssignedManagedIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationUserAssignedManagedIdentity)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationUserAssignedManagedIdentity.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationUserAssignedManagedIdentity.cs new file mode 100644 index 000000000000..b7f15357a13c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationUserAssignedManagedIdentity.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// DataflowEndpoint Authentication UserAssignedManagedIdentity properties. + public partial class DataflowEndpointAuthenticationUserAssignedManagedIdentity + { + /// + /// 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 . + /// Client ID for the user-assigned managed identity. + /// Tenant ID. + /// or is null. + public DataflowEndpointAuthenticationUserAssignedManagedIdentity(string clientId, string tenantId) + { + Argument.AssertNotNull(clientId, nameof(clientId)); + Argument.AssertNotNull(tenantId, nameof(tenantId)); + + ClientId = clientId; + TenantId = tenantId; + } + + /// Initializes a new instance of . + /// Client ID for the user-assigned managed identity. + /// Resource identifier (application ID URI) of the resource, affixed with the .default suffix. + /// Tenant ID. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointAuthenticationUserAssignedManagedIdentity(string clientId, string scope, string tenantId, IDictionary serializedAdditionalRawData) + { + ClientId = clientId; + Scope = scope; + TenantId = tenantId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointAuthenticationUserAssignedManagedIdentity() + { + } + + /// Client ID for the user-assigned managed identity. + public string ClientId { get; set; } + /// Resource identifier (application ID URI) of the resource, affixed with the .default suffix. + public string Scope { get; set; } + /// Tenant ID. + public string TenantId { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationX509.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationX509.Serialization.cs new file mode 100644 index 000000000000..123378e68aff --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationX509.Serialization.cs @@ -0,0 +1,119 @@ +// 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.IoTOperations.Models +{ + internal partial class DataflowEndpointAuthenticationX509 : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationX509)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("secretRef"u8); + writer.WriteStringValue(SecretRef); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointAuthenticationX509 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(DataflowEndpointAuthenticationX509)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointAuthenticationX509(document.RootElement, options); + } + + internal static DataflowEndpointAuthenticationX509 DeserializeDataflowEndpointAuthenticationX509(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string secretRef = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("secretRef"u8)) + { + secretRef = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointAuthenticationX509(secretRef, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationX509)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointAuthenticationX509 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); + return DeserializeDataflowEndpointAuthenticationX509(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationX509)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationX509.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationX509.cs new file mode 100644 index 000000000000..f63afc4b2e8b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointAuthenticationX509.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.IoTOperations.Models +{ + /// DataflowEndpoint Authentication X509 properties. + internal partial class DataflowEndpointAuthenticationX509 + { + /// + /// 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 . + /// Secret reference of the X.509 certificate. + /// is null. + public DataflowEndpointAuthenticationX509(string secretRef) + { + Argument.AssertNotNull(secretRef, nameof(secretRef)); + + SecretRef = secretRef; + } + + /// Initializes a new instance of . + /// Secret reference of the X.509 certificate. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointAuthenticationX509(string secretRef, IDictionary serializedAdditionalRawData) + { + SecretRef = secretRef; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointAuthenticationX509() + { + } + + /// Secret reference of the X.509 certificate. + public string SecretRef { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorer.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorer.Serialization.cs new file mode 100644 index 000000000000..e675beb7b2d9 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorer.Serialization.cs @@ -0,0 +1,150 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointDataExplorer : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointDataExplorer)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("authentication"u8); + writer.WriteObjectValue(Authentication, options); + writer.WritePropertyName("database"u8); + writer.WriteStringValue(Database); + writer.WritePropertyName("host"u8); + writer.WriteStringValue(Host); + if (Optional.IsDefined(Batching)) + { + writer.WritePropertyName("batching"u8); + writer.WriteObjectValue(Batching, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointDataExplorer 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(DataflowEndpointDataExplorer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointDataExplorer(document.RootElement, options); + } + + internal static DataflowEndpointDataExplorer DeserializeDataflowEndpointDataExplorer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowEndpointDataExplorerAuthentication authentication = default; + string database = default; + string host = default; + BatchingConfiguration batching = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("authentication"u8)) + { + authentication = DataflowEndpointDataExplorerAuthentication.DeserializeDataflowEndpointDataExplorerAuthentication(property.Value, options); + continue; + } + if (property.NameEquals("database"u8)) + { + database = property.Value.GetString(); + continue; + } + if (property.NameEquals("host"u8)) + { + host = property.Value.GetString(); + continue; + } + if (property.NameEquals("batching"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + batching = BatchingConfiguration.DeserializeBatchingConfiguration(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointDataExplorer(authentication, database, host, batching, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointDataExplorer)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointDataExplorer 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); + return DeserializeDataflowEndpointDataExplorer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointDataExplorer)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorer.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorer.cs new file mode 100644 index 000000000000..4157303e6339 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorer.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.IoTOperations.Models +{ + /// Azure Data Explorer endpoint properties. + public partial class DataflowEndpointDataExplorer + { + /// + /// 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 . + /// Authentication configuration. NOTE - only authentication property is allowed per entry. + /// Database name. + /// Host of the Azure Data Explorer in the form of <cluster>.<region>.kusto.windows.net . + /// , or is null. + public DataflowEndpointDataExplorer(DataflowEndpointDataExplorerAuthentication authentication, string database, string host) + { + Argument.AssertNotNull(authentication, nameof(authentication)); + Argument.AssertNotNull(database, nameof(database)); + Argument.AssertNotNull(host, nameof(host)); + + Authentication = authentication; + Database = database; + Host = host; + } + + /// Initializes a new instance of . + /// Authentication configuration. NOTE - only authentication property is allowed per entry. + /// Database name. + /// Host of the Azure Data Explorer in the form of <cluster>.<region>.kusto.windows.net . + /// Azure Data Explorer endpoint batching configuration. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointDataExplorer(DataflowEndpointDataExplorerAuthentication authentication, string database, string host, BatchingConfiguration batching, IDictionary serializedAdditionalRawData) + { + Authentication = authentication; + Database = database; + Host = host; + Batching = batching; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointDataExplorer() + { + } + + /// Authentication configuration. NOTE - only authentication property is allowed per entry. + public DataflowEndpointDataExplorerAuthentication Authentication { get; set; } + /// Database name. + public string Database { get; set; } + /// Host of the Azure Data Explorer in the form of <cluster>.<region>.kusto.windows.net . + public string Host { get; set; } + /// Azure Data Explorer endpoint batching configuration. + public BatchingConfiguration Batching { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorerAuthentication.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorerAuthentication.Serialization.cs new file mode 100644 index 000000000000..fa0a2687d204 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorerAuthentication.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.IoTOperations.Models +{ + public partial class DataflowEndpointDataExplorerAuthentication : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointDataExplorerAuthentication)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method.ToString()); + if (Optional.IsDefined(SystemAssignedManagedIdentitySettings)) + { + writer.WritePropertyName("systemAssignedManagedIdentitySettings"u8); + writer.WriteObjectValue(SystemAssignedManagedIdentitySettings, options); + } + if (Optional.IsDefined(UserAssignedManagedIdentitySettings)) + { + writer.WritePropertyName("userAssignedManagedIdentitySettings"u8); + writer.WriteObjectValue(UserAssignedManagedIdentitySettings, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointDataExplorerAuthentication 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(DataflowEndpointDataExplorerAuthentication)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointDataExplorerAuthentication(document.RootElement, options); + } + + internal static DataflowEndpointDataExplorerAuthentication DeserializeDataflowEndpointDataExplorerAuthentication(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataExplorerAuthMethod method = default; + DataflowEndpointAuthenticationSystemAssignedManagedIdentity systemAssignedManagedIdentitySettings = default; + DataflowEndpointAuthenticationUserAssignedManagedIdentity userAssignedManagedIdentitySettings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("method"u8)) + { + method = new DataExplorerAuthMethod(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemAssignedManagedIdentitySettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemAssignedManagedIdentitySettings = DataflowEndpointAuthenticationSystemAssignedManagedIdentity.DeserializeDataflowEndpointAuthenticationSystemAssignedManagedIdentity(property.Value, options); + continue; + } + if (property.NameEquals("userAssignedManagedIdentitySettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userAssignedManagedIdentitySettings = DataflowEndpointAuthenticationUserAssignedManagedIdentity.DeserializeDataflowEndpointAuthenticationUserAssignedManagedIdentity(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointDataExplorerAuthentication(method, systemAssignedManagedIdentitySettings, userAssignedManagedIdentitySettings, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointDataExplorerAuthentication)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointDataExplorerAuthentication 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); + return DeserializeDataflowEndpointDataExplorerAuthentication(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointDataExplorerAuthentication)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorerAuthentication.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorerAuthentication.cs new file mode 100644 index 000000000000..f3689bcf3d01 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataExplorerAuthentication.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Azure Data Explorer Authentication properties. NOTE - only authentication property is allowed per entry. + public partial class DataflowEndpointDataExplorerAuthentication + { + /// + /// 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 . + /// Mode of Authentication. + public DataflowEndpointDataExplorerAuthentication(DataExplorerAuthMethod method) + { + Method = method; + } + + /// Initializes a new instance of . + /// Mode of Authentication. + /// System-assigned managed identity authentication. + /// User-assigned managed identity authentication. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointDataExplorerAuthentication(DataExplorerAuthMethod method, DataflowEndpointAuthenticationSystemAssignedManagedIdentity systemAssignedManagedIdentitySettings, DataflowEndpointAuthenticationUserAssignedManagedIdentity userAssignedManagedIdentitySettings, IDictionary serializedAdditionalRawData) + { + Method = method; + SystemAssignedManagedIdentitySettings = systemAssignedManagedIdentitySettings; + UserAssignedManagedIdentitySettings = userAssignedManagedIdentitySettings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointDataExplorerAuthentication() + { + } + + /// Mode of Authentication. + public DataExplorerAuthMethod Method { get; set; } + /// System-assigned managed identity authentication. + internal DataflowEndpointAuthenticationSystemAssignedManagedIdentity SystemAssignedManagedIdentitySettings { get; set; } + /// Audience of the service to authenticate against. Optional; defaults to the audience for Service host configuration. + public string SystemAssignedManagedIdentityAudience + { + get => SystemAssignedManagedIdentitySettings is null ? default : SystemAssignedManagedIdentitySettings.Audience; + set + { + if (SystemAssignedManagedIdentitySettings is null) + SystemAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationSystemAssignedManagedIdentity(); + SystemAssignedManagedIdentitySettings.Audience = value; + } + } + + /// User-assigned managed identity authentication. + public DataflowEndpointAuthenticationUserAssignedManagedIdentity UserAssignedManagedIdentitySettings { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorage.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorage.Serialization.cs new file mode 100644 index 000000000000..e1b8c6d4cc75 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorage.Serialization.cs @@ -0,0 +1,142 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointDataLakeStorage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointDataLakeStorage)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("authentication"u8); + writer.WriteObjectValue(Authentication, options); + writer.WritePropertyName("host"u8); + writer.WriteStringValue(Host); + if (Optional.IsDefined(Batching)) + { + writer.WritePropertyName("batching"u8); + writer.WriteObjectValue(Batching, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointDataLakeStorage 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(DataflowEndpointDataLakeStorage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointDataLakeStorage(document.RootElement, options); + } + + internal static DataflowEndpointDataLakeStorage DeserializeDataflowEndpointDataLakeStorage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowEndpointDataLakeStorageAuthentication authentication = default; + string host = default; + BatchingConfiguration batching = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("authentication"u8)) + { + authentication = DataflowEndpointDataLakeStorageAuthentication.DeserializeDataflowEndpointDataLakeStorageAuthentication(property.Value, options); + continue; + } + if (property.NameEquals("host"u8)) + { + host = property.Value.GetString(); + continue; + } + if (property.NameEquals("batching"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + batching = BatchingConfiguration.DeserializeBatchingConfiguration(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointDataLakeStorage(authentication, host, batching, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointDataLakeStorage)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointDataLakeStorage 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); + return DeserializeDataflowEndpointDataLakeStorage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointDataLakeStorage)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorage.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorage.cs new file mode 100644 index 000000000000..fd9b7983bc2a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorage.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Azure Data Lake endpoint properties. + public partial class DataflowEndpointDataLakeStorage + { + /// + /// 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 . + /// Authentication configuration. NOTE - only authentication property is allowed per entry. + /// Host of the Azure Data Lake in the form of <account>.blob.core.windows.net . + /// or is null. + public DataflowEndpointDataLakeStorage(DataflowEndpointDataLakeStorageAuthentication authentication, string host) + { + Argument.AssertNotNull(authentication, nameof(authentication)); + Argument.AssertNotNull(host, nameof(host)); + + Authentication = authentication; + Host = host; + } + + /// Initializes a new instance of . + /// Authentication configuration. NOTE - only authentication property is allowed per entry. + /// Host of the Azure Data Lake in the form of <account>.blob.core.windows.net . + /// Azure Data Lake endpoint batching configuration. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointDataLakeStorage(DataflowEndpointDataLakeStorageAuthentication authentication, string host, BatchingConfiguration batching, IDictionary serializedAdditionalRawData) + { + Authentication = authentication; + Host = host; + Batching = batching; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointDataLakeStorage() + { + } + + /// Authentication configuration. NOTE - only authentication property is allowed per entry. + public DataflowEndpointDataLakeStorageAuthentication Authentication { get; set; } + /// Host of the Azure Data Lake in the form of <account>.blob.core.windows.net . + public string Host { get; set; } + /// Azure Data Lake endpoint batching configuration. + public BatchingConfiguration Batching { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorageAuthentication.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorageAuthentication.Serialization.cs new file mode 100644 index 000000000000..d0c2409dc8ba --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorageAuthentication.Serialization.cs @@ -0,0 +1,164 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointDataLakeStorageAuthentication : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointDataLakeStorageAuthentication)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method.ToString()); + if (Optional.IsDefined(AccessTokenSettings)) + { + writer.WritePropertyName("accessTokenSettings"u8); + writer.WriteObjectValue(AccessTokenSettings, options); + } + if (Optional.IsDefined(SystemAssignedManagedIdentitySettings)) + { + writer.WritePropertyName("systemAssignedManagedIdentitySettings"u8); + writer.WriteObjectValue(SystemAssignedManagedIdentitySettings, options); + } + if (Optional.IsDefined(UserAssignedManagedIdentitySettings)) + { + writer.WritePropertyName("userAssignedManagedIdentitySettings"u8); + writer.WriteObjectValue(UserAssignedManagedIdentitySettings, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointDataLakeStorageAuthentication 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(DataflowEndpointDataLakeStorageAuthentication)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointDataLakeStorageAuthentication(document.RootElement, options); + } + + internal static DataflowEndpointDataLakeStorageAuthentication DeserializeDataflowEndpointDataLakeStorageAuthentication(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataLakeStorageAuthMethod method = default; + DataflowEndpointAuthenticationAccessToken accessTokenSettings = default; + DataflowEndpointAuthenticationSystemAssignedManagedIdentity systemAssignedManagedIdentitySettings = default; + DataflowEndpointAuthenticationUserAssignedManagedIdentity userAssignedManagedIdentitySettings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("method"u8)) + { + method = new DataLakeStorageAuthMethod(property.Value.GetString()); + continue; + } + if (property.NameEquals("accessTokenSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + accessTokenSettings = DataflowEndpointAuthenticationAccessToken.DeserializeDataflowEndpointAuthenticationAccessToken(property.Value, options); + continue; + } + if (property.NameEquals("systemAssignedManagedIdentitySettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemAssignedManagedIdentitySettings = DataflowEndpointAuthenticationSystemAssignedManagedIdentity.DeserializeDataflowEndpointAuthenticationSystemAssignedManagedIdentity(property.Value, options); + continue; + } + if (property.NameEquals("userAssignedManagedIdentitySettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userAssignedManagedIdentitySettings = DataflowEndpointAuthenticationUserAssignedManagedIdentity.DeserializeDataflowEndpointAuthenticationUserAssignedManagedIdentity(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointDataLakeStorageAuthentication(method, accessTokenSettings, systemAssignedManagedIdentitySettings, userAssignedManagedIdentitySettings, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointDataLakeStorageAuthentication)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointDataLakeStorageAuthentication 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); + return DeserializeDataflowEndpointDataLakeStorageAuthentication(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointDataLakeStorageAuthentication)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorageAuthentication.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorageAuthentication.cs new file mode 100644 index 000000000000..71c0da722356 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointDataLakeStorageAuthentication.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.IoTOperations.Models +{ + /// Azure Data Lake endpoint Authentication properties. NOTE Enum - Only one method is supported for one entry. + public partial class DataflowEndpointDataLakeStorageAuthentication + { + /// + /// 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 . + /// Mode of Authentication. + public DataflowEndpointDataLakeStorageAuthentication(DataLakeStorageAuthMethod method) + { + Method = method; + } + + /// Initializes a new instance of . + /// Mode of Authentication. + /// SAS token authentication. + /// System-assigned managed identity authentication. + /// User-assigned managed identity authentication. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointDataLakeStorageAuthentication(DataLakeStorageAuthMethod method, DataflowEndpointAuthenticationAccessToken accessTokenSettings, DataflowEndpointAuthenticationSystemAssignedManagedIdentity systemAssignedManagedIdentitySettings, DataflowEndpointAuthenticationUserAssignedManagedIdentity userAssignedManagedIdentitySettings, IDictionary serializedAdditionalRawData) + { + Method = method; + AccessTokenSettings = accessTokenSettings; + SystemAssignedManagedIdentitySettings = systemAssignedManagedIdentitySettings; + UserAssignedManagedIdentitySettings = userAssignedManagedIdentitySettings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointDataLakeStorageAuthentication() + { + } + + /// Mode of Authentication. + public DataLakeStorageAuthMethod Method { get; set; } + /// SAS token authentication. + internal DataflowEndpointAuthenticationAccessToken AccessTokenSettings { get; set; } + /// Token secret name. + public string AccessTokenSecretRef + { + get => AccessTokenSettings is null ? default : AccessTokenSettings.SecretRef; + set => AccessTokenSettings = new DataflowEndpointAuthenticationAccessToken(value); + } + + /// System-assigned managed identity authentication. + internal DataflowEndpointAuthenticationSystemAssignedManagedIdentity SystemAssignedManagedIdentitySettings { get; set; } + /// Audience of the service to authenticate against. Optional; defaults to the audience for Service host configuration. + public string SystemAssignedManagedIdentityAudience + { + get => SystemAssignedManagedIdentitySettings is null ? default : SystemAssignedManagedIdentitySettings.Audience; + set + { + if (SystemAssignedManagedIdentitySettings is null) + SystemAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationSystemAssignedManagedIdentity(); + SystemAssignedManagedIdentitySettings.Audience = value; + } + } + + /// User-assigned managed identity authentication. + public DataflowEndpointAuthenticationUserAssignedManagedIdentity UserAssignedManagedIdentitySettings { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLake.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLake.Serialization.cs new file mode 100644 index 000000000000..988364e0a121 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLake.Serialization.cs @@ -0,0 +1,164 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointFabricOneLake : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLake)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("authentication"u8); + writer.WriteObjectValue(Authentication, options); + writer.WritePropertyName("names"u8); + writer.WriteObjectValue(Names, options); + writer.WritePropertyName("oneLakePathType"u8); + writer.WriteStringValue(OneLakePathType.ToString()); + writer.WritePropertyName("host"u8); + writer.WriteStringValue(Host); + if (Optional.IsDefined(Batching)) + { + writer.WritePropertyName("batching"u8); + writer.WriteObjectValue(Batching, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointFabricOneLake 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(DataflowEndpointFabricOneLake)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointFabricOneLake(document.RootElement, options); + } + + internal static DataflowEndpointFabricOneLake DeserializeDataflowEndpointFabricOneLake(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowEndpointFabricOneLakeAuthentication authentication = default; + DataflowEndpointFabricOneLakeNames names = default; + DataflowEndpointFabricPathType oneLakePathType = default; + string host = default; + BatchingConfiguration batching = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("authentication"u8)) + { + authentication = DataflowEndpointFabricOneLakeAuthentication.DeserializeDataflowEndpointFabricOneLakeAuthentication(property.Value, options); + continue; + } + if (property.NameEquals("names"u8)) + { + names = DataflowEndpointFabricOneLakeNames.DeserializeDataflowEndpointFabricOneLakeNames(property.Value, options); + continue; + } + if (property.NameEquals("oneLakePathType"u8)) + { + oneLakePathType = new DataflowEndpointFabricPathType(property.Value.GetString()); + continue; + } + if (property.NameEquals("host"u8)) + { + host = property.Value.GetString(); + continue; + } + if (property.NameEquals("batching"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + batching = BatchingConfiguration.DeserializeBatchingConfiguration(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointFabricOneLake( + authentication, + names, + oneLakePathType, + host, + batching, + 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLake)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointFabricOneLake 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); + return DeserializeDataflowEndpointFabricOneLake(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLake)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLake.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLake.cs new file mode 100644 index 000000000000..04a6ecce7459 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLake.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Microsoft Fabric endpoint properties. + public partial class DataflowEndpointFabricOneLake + { + /// + /// 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 . + /// Authentication configuration. NOTE - only one authentication property is allowed per entry. + /// Names of the workspace and lakehouse. + /// Type of location of the data in the workspace. Can be either tables or files. + /// Host of the Microsoft Fabric in the form of https://<host>.fabric.microsoft.com. + /// , or is null. + public DataflowEndpointFabricOneLake(DataflowEndpointFabricOneLakeAuthentication authentication, DataflowEndpointFabricOneLakeNames names, DataflowEndpointFabricPathType oneLakePathType, string host) + { + Argument.AssertNotNull(authentication, nameof(authentication)); + Argument.AssertNotNull(names, nameof(names)); + Argument.AssertNotNull(host, nameof(host)); + + Authentication = authentication; + Names = names; + OneLakePathType = oneLakePathType; + Host = host; + } + + /// Initializes a new instance of . + /// Authentication configuration. NOTE - only one authentication property is allowed per entry. + /// Names of the workspace and lakehouse. + /// Type of location of the data in the workspace. Can be either tables or files. + /// Host of the Microsoft Fabric in the form of https://<host>.fabric.microsoft.com. + /// Batching configuration. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointFabricOneLake(DataflowEndpointFabricOneLakeAuthentication authentication, DataflowEndpointFabricOneLakeNames names, DataflowEndpointFabricPathType oneLakePathType, string host, BatchingConfiguration batching, IDictionary serializedAdditionalRawData) + { + Authentication = authentication; + Names = names; + OneLakePathType = oneLakePathType; + Host = host; + Batching = batching; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointFabricOneLake() + { + } + + /// Authentication configuration. NOTE - only one authentication property is allowed per entry. + public DataflowEndpointFabricOneLakeAuthentication Authentication { get; set; } + /// Names of the workspace and lakehouse. + public DataflowEndpointFabricOneLakeNames Names { get; set; } + /// Type of location of the data in the workspace. Can be either tables or files. + public DataflowEndpointFabricPathType OneLakePathType { get; set; } + /// Host of the Microsoft Fabric in the form of https://<host>.fabric.microsoft.com. + public string Host { get; set; } + /// Batching configuration. + public BatchingConfiguration Batching { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeAuthentication.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeAuthentication.Serialization.cs new file mode 100644 index 000000000000..6ab7e425c78b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeAuthentication.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.IoTOperations.Models +{ + public partial class DataflowEndpointFabricOneLakeAuthentication : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLakeAuthentication)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method.ToString()); + if (Optional.IsDefined(SystemAssignedManagedIdentitySettings)) + { + writer.WritePropertyName("systemAssignedManagedIdentitySettings"u8); + writer.WriteObjectValue(SystemAssignedManagedIdentitySettings, options); + } + if (Optional.IsDefined(UserAssignedManagedIdentitySettings)) + { + writer.WritePropertyName("userAssignedManagedIdentitySettings"u8); + writer.WriteObjectValue(UserAssignedManagedIdentitySettings, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointFabricOneLakeAuthentication 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(DataflowEndpointFabricOneLakeAuthentication)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointFabricOneLakeAuthentication(document.RootElement, options); + } + + internal static DataflowEndpointFabricOneLakeAuthentication DeserializeDataflowEndpointFabricOneLakeAuthentication(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + FabricOneLakeAuthMethod method = default; + DataflowEndpointAuthenticationSystemAssignedManagedIdentity systemAssignedManagedIdentitySettings = default; + DataflowEndpointAuthenticationUserAssignedManagedIdentity userAssignedManagedIdentitySettings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("method"u8)) + { + method = new FabricOneLakeAuthMethod(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemAssignedManagedIdentitySettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemAssignedManagedIdentitySettings = DataflowEndpointAuthenticationSystemAssignedManagedIdentity.DeserializeDataflowEndpointAuthenticationSystemAssignedManagedIdentity(property.Value, options); + continue; + } + if (property.NameEquals("userAssignedManagedIdentitySettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userAssignedManagedIdentitySettings = DataflowEndpointAuthenticationUserAssignedManagedIdentity.DeserializeDataflowEndpointAuthenticationUserAssignedManagedIdentity(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointFabricOneLakeAuthentication(method, systemAssignedManagedIdentitySettings, userAssignedManagedIdentitySettings, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLakeAuthentication)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointFabricOneLakeAuthentication 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); + return DeserializeDataflowEndpointFabricOneLakeAuthentication(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLakeAuthentication)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeAuthentication.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeAuthentication.cs new file mode 100644 index 000000000000..b6c8e597d3cf --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeAuthentication.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Microsoft Fabric endpoint. Authentication properties. NOTE - Only one method is supported for one entry. + public partial class DataflowEndpointFabricOneLakeAuthentication + { + /// + /// 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 . + /// Mode of Authentication. + public DataflowEndpointFabricOneLakeAuthentication(FabricOneLakeAuthMethod method) + { + Method = method; + } + + /// Initializes a new instance of . + /// Mode of Authentication. + /// System-assigned managed identity authentication. + /// User-assigned managed identity authentication. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointFabricOneLakeAuthentication(FabricOneLakeAuthMethod method, DataflowEndpointAuthenticationSystemAssignedManagedIdentity systemAssignedManagedIdentitySettings, DataflowEndpointAuthenticationUserAssignedManagedIdentity userAssignedManagedIdentitySettings, IDictionary serializedAdditionalRawData) + { + Method = method; + SystemAssignedManagedIdentitySettings = systemAssignedManagedIdentitySettings; + UserAssignedManagedIdentitySettings = userAssignedManagedIdentitySettings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointFabricOneLakeAuthentication() + { + } + + /// Mode of Authentication. + public FabricOneLakeAuthMethod Method { get; set; } + /// System-assigned managed identity authentication. + internal DataflowEndpointAuthenticationSystemAssignedManagedIdentity SystemAssignedManagedIdentitySettings { get; set; } + /// Audience of the service to authenticate against. Optional; defaults to the audience for Service host configuration. + public string SystemAssignedManagedIdentityAudience + { + get => SystemAssignedManagedIdentitySettings is null ? default : SystemAssignedManagedIdentitySettings.Audience; + set + { + if (SystemAssignedManagedIdentitySettings is null) + SystemAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationSystemAssignedManagedIdentity(); + SystemAssignedManagedIdentitySettings.Audience = value; + } + } + + /// User-assigned managed identity authentication. + public DataflowEndpointAuthenticationUserAssignedManagedIdentity UserAssignedManagedIdentitySettings { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeNames.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeNames.Serialization.cs new file mode 100644 index 000000000000..1d38762f6b73 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeNames.Serialization.cs @@ -0,0 +1,127 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointFabricOneLakeNames : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLakeNames)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("lakehouseName"u8); + writer.WriteStringValue(LakehouseName); + writer.WritePropertyName("workspaceName"u8); + writer.WriteStringValue(WorkspaceName); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointFabricOneLakeNames 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(DataflowEndpointFabricOneLakeNames)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointFabricOneLakeNames(document.RootElement, options); + } + + internal static DataflowEndpointFabricOneLakeNames DeserializeDataflowEndpointFabricOneLakeNames(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string lakehouseName = default; + string workspaceName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("lakehouseName"u8)) + { + lakehouseName = property.Value.GetString(); + continue; + } + if (property.NameEquals("workspaceName"u8)) + { + workspaceName = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointFabricOneLakeNames(lakehouseName, workspaceName, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLakeNames)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointFabricOneLakeNames 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); + return DeserializeDataflowEndpointFabricOneLakeNames(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLakeNames)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeNames.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeNames.cs new file mode 100644 index 000000000000..a7fd35866c65 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricOneLakeNames.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.IoTOperations.Models +{ + /// Microsoft Fabric endpoint Names properties. + public partial class DataflowEndpointFabricOneLakeNames + { + /// + /// 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 . + /// Lakehouse name. + /// Workspace name. + /// or is null. + public DataflowEndpointFabricOneLakeNames(string lakehouseName, string workspaceName) + { + Argument.AssertNotNull(lakehouseName, nameof(lakehouseName)); + Argument.AssertNotNull(workspaceName, nameof(workspaceName)); + + LakehouseName = lakehouseName; + WorkspaceName = workspaceName; + } + + /// Initializes a new instance of . + /// Lakehouse name. + /// Workspace name. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointFabricOneLakeNames(string lakehouseName, string workspaceName, IDictionary serializedAdditionalRawData) + { + LakehouseName = lakehouseName; + WorkspaceName = workspaceName; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointFabricOneLakeNames() + { + } + + /// Lakehouse name. + public string LakehouseName { get; set; } + /// Workspace name. + public string WorkspaceName { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricPathType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricPathType.cs new file mode 100644 index 000000000000..107775a83f0f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointFabricPathType.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.IoTOperations.Models +{ + /// DataflowEndpoint Fabric Path Type properties. + public readonly partial struct DataflowEndpointFabricPathType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataflowEndpointFabricPathType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FilesValue = "Files"; + private const string TablesValue = "Tables"; + + /// FILES Type. + public static DataflowEndpointFabricPathType Files { get; } = new DataflowEndpointFabricPathType(FilesValue); + /// TABLES Type. + public static DataflowEndpointFabricPathType Tables { get; } = new DataflowEndpointFabricPathType(TablesValue); + /// Determines if two values are the same. + public static bool operator ==(DataflowEndpointFabricPathType left, DataflowEndpointFabricPathType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataflowEndpointFabricPathType left, DataflowEndpointFabricPathType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DataflowEndpointFabricPathType(string value) => new DataflowEndpointFabricPathType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataflowEndpointFabricPathType other && Equals(other); + /// + public bool Equals(DataflowEndpointFabricPathType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafka.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafka.Serialization.cs new file mode 100644 index 000000000000..5bef619e2f84 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafka.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.IoTOperations.Models +{ + public partial class DataflowEndpointKafka : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointKafka)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("authentication"u8); + writer.WriteObjectValue(Authentication, options); + if (Optional.IsDefined(ConsumerGroupId)) + { + writer.WritePropertyName("consumerGroupId"u8); + writer.WriteStringValue(ConsumerGroupId); + } + writer.WritePropertyName("host"u8); + writer.WriteStringValue(Host); + if (Optional.IsDefined(Batching)) + { + writer.WritePropertyName("batching"u8); + writer.WriteObjectValue(Batching, options); + } + if (Optional.IsDefined(CopyMqttProperties)) + { + writer.WritePropertyName("copyMqttProperties"u8); + writer.WriteStringValue(CopyMqttProperties.Value.ToString()); + } + if (Optional.IsDefined(Compression)) + { + writer.WritePropertyName("compression"u8); + writer.WriteStringValue(Compression.Value.ToString()); + } + if (Optional.IsDefined(KafkaAcks)) + { + writer.WritePropertyName("kafkaAcks"u8); + writer.WriteStringValue(KafkaAcks.Value.ToString()); + } + if (Optional.IsDefined(PartitionStrategy)) + { + writer.WritePropertyName("partitionStrategy"u8); + writer.WriteStringValue(PartitionStrategy.Value.ToString()); + } + if (Optional.IsDefined(Tls)) + { + writer.WritePropertyName("tls"u8); + writer.WriteObjectValue(Tls, options); + } + if (Optional.IsDefined(CloudEventAttributes)) + { + writer.WritePropertyName("cloudEventAttributes"u8); + writer.WriteStringValue(CloudEventAttributes.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointKafka 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(DataflowEndpointKafka)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointKafka(document.RootElement, options); + } + + internal static DataflowEndpointKafka DeserializeDataflowEndpointKafka(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowEndpointKafkaAuthentication authentication = default; + string consumerGroupId = default; + string host = default; + DataflowEndpointKafkaBatching batching = default; + OperationalMode? copyMqttProperties = default; + DataflowEndpointKafkaCompression? compression = default; + DataflowEndpointKafkaAck? kafkaAcks = default; + DataflowEndpointKafkaPartitionStrategy? partitionStrategy = default; + TlsProperties tls = default; + CloudEventAttributeType? cloudEventAttributes = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("authentication"u8)) + { + authentication = DataflowEndpointKafkaAuthentication.DeserializeDataflowEndpointKafkaAuthentication(property.Value, options); + continue; + } + if (property.NameEquals("consumerGroupId"u8)) + { + consumerGroupId = property.Value.GetString(); + continue; + } + if (property.NameEquals("host"u8)) + { + host = property.Value.GetString(); + continue; + } + if (property.NameEquals("batching"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + batching = DataflowEndpointKafkaBatching.DeserializeDataflowEndpointKafkaBatching(property.Value, options); + continue; + } + if (property.NameEquals("copyMqttProperties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + copyMqttProperties = new OperationalMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("compression"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + compression = new DataflowEndpointKafkaCompression(property.Value.GetString()); + continue; + } + if (property.NameEquals("kafkaAcks"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kafkaAcks = new DataflowEndpointKafkaAck(property.Value.GetString()); + continue; + } + if (property.NameEquals("partitionStrategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + partitionStrategy = new DataflowEndpointKafkaPartitionStrategy(property.Value.GetString()); + continue; + } + if (property.NameEquals("tls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + tls = TlsProperties.DeserializeTlsProperties(property.Value, options); + continue; + } + if (property.NameEquals("cloudEventAttributes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + cloudEventAttributes = new CloudEventAttributeType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointKafka( + authentication, + consumerGroupId, + host, + batching, + copyMqttProperties, + compression, + kafkaAcks, + partitionStrategy, + tls, + cloudEventAttributes, + 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointKafka)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointKafka 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); + return DeserializeDataflowEndpointKafka(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointKafka)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafka.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafka.cs new file mode 100644 index 000000000000..9fccbcb32cad --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafka.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.IoTOperations.Models +{ + /// Kafka endpoint properties. + public partial class DataflowEndpointKafka + { + /// + /// 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 . + /// Authentication configuration. NOTE - only authentication property is allowed per entry. + /// Kafka endpoint host. + /// or is null. + public DataflowEndpointKafka(DataflowEndpointKafkaAuthentication authentication, string host) + { + Argument.AssertNotNull(authentication, nameof(authentication)); + Argument.AssertNotNull(host, nameof(host)); + + Authentication = authentication; + Host = host; + } + + /// Initializes a new instance of . + /// Authentication configuration. NOTE - only authentication property is allowed per entry. + /// Consumer group ID. + /// Kafka endpoint host. + /// Batching configuration. + /// Copy Broker properties. No effect if the endpoint is used as a source or if the dataflow doesn't have an Broker source. + /// Compression. Can be none, gzip, lz4, or snappy. No effect if the endpoint is used as a source. + /// Kafka acks. Can be all, one, or zero. No effect if the endpoint is used as a source. + /// Partition handling strategy. Can be default or static. No effect if the endpoint is used as a source. + /// TLS configuration. + /// Cloud event mapping config. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointKafka(DataflowEndpointKafkaAuthentication authentication, string consumerGroupId, string host, DataflowEndpointKafkaBatching batching, OperationalMode? copyMqttProperties, DataflowEndpointKafkaCompression? compression, DataflowEndpointKafkaAck? kafkaAcks, DataflowEndpointKafkaPartitionStrategy? partitionStrategy, TlsProperties tls, CloudEventAttributeType? cloudEventAttributes, IDictionary serializedAdditionalRawData) + { + Authentication = authentication; + ConsumerGroupId = consumerGroupId; + Host = host; + Batching = batching; + CopyMqttProperties = copyMqttProperties; + Compression = compression; + KafkaAcks = kafkaAcks; + PartitionStrategy = partitionStrategy; + Tls = tls; + CloudEventAttributes = cloudEventAttributes; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointKafka() + { + } + + /// Authentication configuration. NOTE - only authentication property is allowed per entry. + public DataflowEndpointKafkaAuthentication Authentication { get; set; } + /// Consumer group ID. + public string ConsumerGroupId { get; set; } + /// Kafka endpoint host. + public string Host { get; set; } + /// Batching configuration. + public DataflowEndpointKafkaBatching Batching { get; set; } + /// Copy Broker properties. No effect if the endpoint is used as a source or if the dataflow doesn't have an Broker source. + public OperationalMode? CopyMqttProperties { get; set; } + /// Compression. Can be none, gzip, lz4, or snappy. No effect if the endpoint is used as a source. + public DataflowEndpointKafkaCompression? Compression { get; set; } + /// Kafka acks. Can be all, one, or zero. No effect if the endpoint is used as a source. + public DataflowEndpointKafkaAck? KafkaAcks { get; set; } + /// Partition handling strategy. Can be default or static. No effect if the endpoint is used as a source. + public DataflowEndpointKafkaPartitionStrategy? PartitionStrategy { get; set; } + /// TLS configuration. + public TlsProperties Tls { get; set; } + /// Cloud event mapping config. + public CloudEventAttributeType? CloudEventAttributes { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAck.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAck.cs new file mode 100644 index 000000000000..b0d735f468cf --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAck.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.IoTOperations.Models +{ + /// DataflowEndpoint Kafka Acks properties. + public readonly partial struct DataflowEndpointKafkaAck : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataflowEndpointKafkaAck(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ZeroValue = "Zero"; + private const string OneValue = "One"; + private const string AllValue = "All"; + + /// ZERO Option. + public static DataflowEndpointKafkaAck Zero { get; } = new DataflowEndpointKafkaAck(ZeroValue); + /// ONE Option. + public static DataflowEndpointKafkaAck One { get; } = new DataflowEndpointKafkaAck(OneValue); + /// ALL Option. + public static DataflowEndpointKafkaAck All { get; } = new DataflowEndpointKafkaAck(AllValue); + /// Determines if two values are the same. + public static bool operator ==(DataflowEndpointKafkaAck left, DataflowEndpointKafkaAck right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataflowEndpointKafkaAck left, DataflowEndpointKafkaAck right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DataflowEndpointKafkaAck(string value) => new DataflowEndpointKafkaAck(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataflowEndpointKafkaAck other && Equals(other); + /// + public bool Equals(DataflowEndpointKafkaAck 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAuthentication.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAuthentication.Serialization.cs new file mode 100644 index 000000000000..b15db6aba103 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAuthentication.Serialization.cs @@ -0,0 +1,185 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointKafkaAuthentication : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointKafkaAuthentication)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method.ToString()); + if (Optional.IsDefined(SystemAssignedManagedIdentitySettings)) + { + writer.WritePropertyName("systemAssignedManagedIdentitySettings"u8); + writer.WriteObjectValue(SystemAssignedManagedIdentitySettings, options); + } + if (Optional.IsDefined(UserAssignedManagedIdentitySettings)) + { + writer.WritePropertyName("userAssignedManagedIdentitySettings"u8); + writer.WriteObjectValue(UserAssignedManagedIdentitySettings, options); + } + if (Optional.IsDefined(SaslSettings)) + { + writer.WritePropertyName("saslSettings"u8); + writer.WriteObjectValue(SaslSettings, options); + } + if (Optional.IsDefined(X509CertificateSettings)) + { + writer.WritePropertyName("x509CertificateSettings"u8); + writer.WriteObjectValue(X509CertificateSettings, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointKafkaAuthentication 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(DataflowEndpointKafkaAuthentication)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointKafkaAuthentication(document.RootElement, options); + } + + internal static DataflowEndpointKafkaAuthentication DeserializeDataflowEndpointKafkaAuthentication(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + KafkaAuthMethod method = default; + DataflowEndpointAuthenticationSystemAssignedManagedIdentity systemAssignedManagedIdentitySettings = default; + DataflowEndpointAuthenticationUserAssignedManagedIdentity userAssignedManagedIdentitySettings = default; + DataflowEndpointAuthenticationSasl saslSettings = default; + DataflowEndpointAuthenticationX509 x509CertificateSettings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("method"u8)) + { + method = new KafkaAuthMethod(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemAssignedManagedIdentitySettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemAssignedManagedIdentitySettings = DataflowEndpointAuthenticationSystemAssignedManagedIdentity.DeserializeDataflowEndpointAuthenticationSystemAssignedManagedIdentity(property.Value, options); + continue; + } + if (property.NameEquals("userAssignedManagedIdentitySettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userAssignedManagedIdentitySettings = DataflowEndpointAuthenticationUserAssignedManagedIdentity.DeserializeDataflowEndpointAuthenticationUserAssignedManagedIdentity(property.Value, options); + continue; + } + if (property.NameEquals("saslSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + saslSettings = DataflowEndpointAuthenticationSasl.DeserializeDataflowEndpointAuthenticationSasl(property.Value, options); + continue; + } + if (property.NameEquals("x509CertificateSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + x509CertificateSettings = DataflowEndpointAuthenticationX509.DeserializeDataflowEndpointAuthenticationX509(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointKafkaAuthentication( + method, + systemAssignedManagedIdentitySettings, + userAssignedManagedIdentitySettings, + saslSettings, + x509CertificateSettings, + 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointKafkaAuthentication)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointKafkaAuthentication 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); + return DeserializeDataflowEndpointKafkaAuthentication(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointKafkaAuthentication)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAuthentication.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAuthentication.cs new file mode 100644 index 000000000000..98b439a3d812 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaAuthentication.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Kafka endpoint Authentication properties. NOTE - only authentication property is allowed per entry. + public partial class DataflowEndpointKafkaAuthentication + { + /// + /// 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 . + /// Mode of Authentication. + public DataflowEndpointKafkaAuthentication(KafkaAuthMethod method) + { + Method = method; + } + + /// Initializes a new instance of . + /// Mode of Authentication. + /// System-assigned managed identity authentication. + /// User-assigned managed identity authentication. + /// SASL authentication. + /// X.509 certificate authentication. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointKafkaAuthentication(KafkaAuthMethod method, DataflowEndpointAuthenticationSystemAssignedManagedIdentity systemAssignedManagedIdentitySettings, DataflowEndpointAuthenticationUserAssignedManagedIdentity userAssignedManagedIdentitySettings, DataflowEndpointAuthenticationSasl saslSettings, DataflowEndpointAuthenticationX509 x509CertificateSettings, IDictionary serializedAdditionalRawData) + { + Method = method; + SystemAssignedManagedIdentitySettings = systemAssignedManagedIdentitySettings; + UserAssignedManagedIdentitySettings = userAssignedManagedIdentitySettings; + SaslSettings = saslSettings; + X509CertificateSettings = x509CertificateSettings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointKafkaAuthentication() + { + } + + /// Mode of Authentication. + public KafkaAuthMethod Method { get; set; } + /// System-assigned managed identity authentication. + internal DataflowEndpointAuthenticationSystemAssignedManagedIdentity SystemAssignedManagedIdentitySettings { get; set; } + /// Audience of the service to authenticate against. Optional; defaults to the audience for Service host configuration. + public string SystemAssignedManagedIdentityAudience + { + get => SystemAssignedManagedIdentitySettings is null ? default : SystemAssignedManagedIdentitySettings.Audience; + set + { + if (SystemAssignedManagedIdentitySettings is null) + SystemAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationSystemAssignedManagedIdentity(); + SystemAssignedManagedIdentitySettings.Audience = value; + } + } + + /// User-assigned managed identity authentication. + public DataflowEndpointAuthenticationUserAssignedManagedIdentity UserAssignedManagedIdentitySettings { get; set; } + /// SASL authentication. + public DataflowEndpointAuthenticationSasl SaslSettings { get; set; } + /// X.509 certificate authentication. + internal DataflowEndpointAuthenticationX509 X509CertificateSettings { get; set; } + /// Secret reference of the X.509 certificate. + public string X509CertificateSecretRef + { + get => X509CertificateSettings is null ? default : X509CertificateSettings.SecretRef; + set => X509CertificateSettings = new DataflowEndpointAuthenticationX509(value); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaBatching.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaBatching.Serialization.cs new file mode 100644 index 000000000000..fc6a800c8bc4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaBatching.Serialization.cs @@ -0,0 +1,171 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointKafkaBatching : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointKafkaBatching)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + if (Optional.IsDefined(LatencyMs)) + { + writer.WritePropertyName("latencyMs"u8); + writer.WriteNumberValue(LatencyMs.Value); + } + if (Optional.IsDefined(MaxBytes)) + { + writer.WritePropertyName("maxBytes"u8); + writer.WriteNumberValue(MaxBytes.Value); + } + if (Optional.IsDefined(MaxMessages)) + { + writer.WritePropertyName("maxMessages"u8); + writer.WriteNumberValue(MaxMessages.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointKafkaBatching 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(DataflowEndpointKafkaBatching)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointKafkaBatching(document.RootElement, options); + } + + internal static DataflowEndpointKafkaBatching DeserializeDataflowEndpointKafkaBatching(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode? mode = default; + int? latencyMs = default; + int? maxBytes = default; + int? maxMessages = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("mode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mode = new OperationalMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("latencyMs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + latencyMs = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("maxBytes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxBytes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("maxMessages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxMessages = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointKafkaBatching(mode, latencyMs, maxBytes, maxMessages, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointKafkaBatching)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointKafkaBatching 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); + return DeserializeDataflowEndpointKafkaBatching(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointKafkaBatching)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaBatching.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaBatching.cs new file mode 100644 index 000000000000..93d9b36ddf35 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaBatching.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.IoTOperations.Models +{ + /// Kafka endpoint Batching properties. + public partial class DataflowEndpointKafkaBatching + { + /// + /// 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 DataflowEndpointKafkaBatching() + { + } + + /// Initializes a new instance of . + /// Mode for batching. + /// Batching latency in milliseconds. + /// Maximum number of bytes in a batch. + /// Maximum number of messages in a batch. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointKafkaBatching(OperationalMode? mode, int? latencyMs, int? maxBytes, int? maxMessages, IDictionary serializedAdditionalRawData) + { + Mode = mode; + LatencyMs = latencyMs; + MaxBytes = maxBytes; + MaxMessages = maxMessages; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Mode for batching. + public OperationalMode? Mode { get; set; } + /// Batching latency in milliseconds. + public int? LatencyMs { get; set; } + /// Maximum number of bytes in a batch. + public int? MaxBytes { get; set; } + /// Maximum number of messages in a batch. + public int? MaxMessages { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaCompression.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaCompression.cs new file mode 100644 index 000000000000..47a8fa362bdd --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaCompression.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.IoTOperations.Models +{ + /// Kafka endpoint Compression properties. + public readonly partial struct DataflowEndpointKafkaCompression : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataflowEndpointKafkaCompression(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string GzipValue = "Gzip"; + private const string SnappyValue = "Snappy"; + private const string Lz4Value = "Lz4"; + + /// NONE Option. + public static DataflowEndpointKafkaCompression None { get; } = new DataflowEndpointKafkaCompression(NoneValue); + /// Gzip Option. + public static DataflowEndpointKafkaCompression Gzip { get; } = new DataflowEndpointKafkaCompression(GzipValue); + /// SNAPPY Option. + public static DataflowEndpointKafkaCompression Snappy { get; } = new DataflowEndpointKafkaCompression(SnappyValue); + /// LZ4 Option. + public static DataflowEndpointKafkaCompression Lz4 { get; } = new DataflowEndpointKafkaCompression(Lz4Value); + /// Determines if two values are the same. + public static bool operator ==(DataflowEndpointKafkaCompression left, DataflowEndpointKafkaCompression right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataflowEndpointKafkaCompression left, DataflowEndpointKafkaCompression right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DataflowEndpointKafkaCompression(string value) => new DataflowEndpointKafkaCompression(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataflowEndpointKafkaCompression other && Equals(other); + /// + public bool Equals(DataflowEndpointKafkaCompression 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaPartitionStrategy.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaPartitionStrategy.cs new file mode 100644 index 000000000000..96049d577f58 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointKafkaPartitionStrategy.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.IoTOperations.Models +{ + /// DataflowEndpoint Kafka Partition Strategy properties. + public readonly partial struct DataflowEndpointKafkaPartitionStrategy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataflowEndpointKafkaPartitionStrategy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DefaultValue = "Default"; + private const string StaticValue = "Static"; + private const string TopicValue = "Topic"; + private const string PropertyValue = "Property"; + + /// Default: Assigns messages to random partitions, using a round-robin algorithm. + public static DataflowEndpointKafkaPartitionStrategy Default { get; } = new DataflowEndpointKafkaPartitionStrategy(DefaultValue); + /// Static: Assigns messages to a fixed partition number that's derived from the instance ID of the dataflow. + public static DataflowEndpointKafkaPartitionStrategy Static { get; } = new DataflowEndpointKafkaPartitionStrategy(StaticValue); + /// TOPIC Option. + public static DataflowEndpointKafkaPartitionStrategy Topic { get; } = new DataflowEndpointKafkaPartitionStrategy(TopicValue); + /// PROPERTY Option. + public static DataflowEndpointKafkaPartitionStrategy Property { get; } = new DataflowEndpointKafkaPartitionStrategy(PropertyValue); + /// Determines if two values are the same. + public static bool operator ==(DataflowEndpointKafkaPartitionStrategy left, DataflowEndpointKafkaPartitionStrategy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataflowEndpointKafkaPartitionStrategy left, DataflowEndpointKafkaPartitionStrategy right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DataflowEndpointKafkaPartitionStrategy(string value) => new DataflowEndpointKafkaPartitionStrategy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataflowEndpointKafkaPartitionStrategy other && Equals(other); + /// + public bool Equals(DataflowEndpointKafkaPartitionStrategy 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointLocalStorage.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointLocalStorage.Serialization.cs new file mode 100644 index 000000000000..c857d3fd0794 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointLocalStorage.Serialization.cs @@ -0,0 +1,119 @@ +// 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.IoTOperations.Models +{ + internal partial class DataflowEndpointLocalStorage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointLocalStorage)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("persistentVolumeClaimRef"u8); + writer.WriteStringValue(PersistentVolumeClaimRef); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointLocalStorage 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(DataflowEndpointLocalStorage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointLocalStorage(document.RootElement, options); + } + + internal static DataflowEndpointLocalStorage DeserializeDataflowEndpointLocalStorage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string persistentVolumeClaimRef = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("persistentVolumeClaimRef"u8)) + { + persistentVolumeClaimRef = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointLocalStorage(persistentVolumeClaimRef, 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointLocalStorage)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointLocalStorage 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); + return DeserializeDataflowEndpointLocalStorage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointLocalStorage)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointLocalStorage.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointLocalStorage.cs new file mode 100644 index 000000000000..934bc9a780c0 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointLocalStorage.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.IoTOperations.Models +{ + /// Local persistent volume endpoint properties. + internal partial class DataflowEndpointLocalStorage + { + /// + /// 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 . + /// Persistent volume claim name. + /// is null. + public DataflowEndpointLocalStorage(string persistentVolumeClaimRef) + { + Argument.AssertNotNull(persistentVolumeClaimRef, nameof(persistentVolumeClaimRef)); + + PersistentVolumeClaimRef = persistentVolumeClaimRef; + } + + /// Initializes a new instance of . + /// Persistent volume claim name. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointLocalStorage(string persistentVolumeClaimRef, IDictionary serializedAdditionalRawData) + { + PersistentVolumeClaimRef = persistentVolumeClaimRef; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointLocalStorage() + { + } + + /// Persistent volume claim name. + public string PersistentVolumeClaimRef { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqtt.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqtt.Serialization.cs new file mode 100644 index 000000000000..5f324f1291cf --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqtt.Serialization.cs @@ -0,0 +1,273 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointMqtt : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointMqtt)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("authentication"u8); + writer.WriteObjectValue(Authentication, options); + if (Optional.IsDefined(ClientIdPrefix)) + { + writer.WritePropertyName("clientIdPrefix"u8); + writer.WriteStringValue(ClientIdPrefix); + } + if (Optional.IsDefined(Host)) + { + writer.WritePropertyName("host"u8); + writer.WriteStringValue(Host); + } + if (Optional.IsDefined(Protocol)) + { + writer.WritePropertyName("protocol"u8); + writer.WriteStringValue(Protocol.Value.ToString()); + } + if (Optional.IsDefined(KeepAliveSeconds)) + { + writer.WritePropertyName("keepAliveSeconds"u8); + writer.WriteNumberValue(KeepAliveSeconds.Value); + } + if (Optional.IsDefined(Retain)) + { + writer.WritePropertyName("retain"u8); + writer.WriteStringValue(Retain.Value.ToString()); + } + if (Optional.IsDefined(MaxInflightMessages)) + { + writer.WritePropertyName("maxInflightMessages"u8); + writer.WriteNumberValue(MaxInflightMessages.Value); + } + if (Optional.IsDefined(Qos)) + { + writer.WritePropertyName("qos"u8); + writer.WriteNumberValue(Qos.Value); + } + if (Optional.IsDefined(SessionExpirySeconds)) + { + writer.WritePropertyName("sessionExpirySeconds"u8); + writer.WriteNumberValue(SessionExpirySeconds.Value); + } + if (Optional.IsDefined(Tls)) + { + writer.WritePropertyName("tls"u8); + writer.WriteObjectValue(Tls, options); + } + if (Optional.IsDefined(CloudEventAttributes)) + { + writer.WritePropertyName("cloudEventAttributes"u8); + writer.WriteStringValue(CloudEventAttributes.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointMqtt 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(DataflowEndpointMqtt)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointMqtt(document.RootElement, options); + } + + internal static DataflowEndpointMqtt DeserializeDataflowEndpointMqtt(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowEndpointMqttAuthentication authentication = default; + string clientIdPrefix = default; + string host = default; + BrokerProtocolType? protocol = default; + int? keepAliveSeconds = default; + MqttRetainType? retain = default; + int? maxInflightMessages = default; + int? qos = default; + int? sessionExpirySeconds = default; + TlsProperties tls = default; + CloudEventAttributeType? cloudEventAttributes = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("authentication"u8)) + { + authentication = DataflowEndpointMqttAuthentication.DeserializeDataflowEndpointMqttAuthentication(property.Value, options); + continue; + } + if (property.NameEquals("clientIdPrefix"u8)) + { + clientIdPrefix = property.Value.GetString(); + continue; + } + if (property.NameEquals("host"u8)) + { + host = property.Value.GetString(); + continue; + } + if (property.NameEquals("protocol"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + protocol = new BrokerProtocolType(property.Value.GetString()); + continue; + } + if (property.NameEquals("keepAliveSeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keepAliveSeconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("retain"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + retain = new MqttRetainType(property.Value.GetString()); + continue; + } + if (property.NameEquals("maxInflightMessages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxInflightMessages = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("qos"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + qos = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("sessionExpirySeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sessionExpirySeconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("tls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + tls = TlsProperties.DeserializeTlsProperties(property.Value, options); + continue; + } + if (property.NameEquals("cloudEventAttributes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + cloudEventAttributes = new CloudEventAttributeType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointMqtt( + authentication, + clientIdPrefix, + host, + protocol, + keepAliveSeconds, + retain, + maxInflightMessages, + qos, + sessionExpirySeconds, + tls, + cloudEventAttributes, + 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointMqtt)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointMqtt 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); + return DeserializeDataflowEndpointMqtt(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointMqtt)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqtt.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqtt.cs new file mode 100644 index 000000000000..de92f2951188 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqtt.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Broker endpoint properties. + public partial class DataflowEndpointMqtt + { + /// + /// 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 . + /// authentication properties. DEFAULT: kubernetes.audience=aio-mq-internal. NOTE - Enum field only property is allowed. + /// is null. + public DataflowEndpointMqtt(DataflowEndpointMqttAuthentication authentication) + { + Argument.AssertNotNull(authentication, nameof(authentication)); + + Authentication = authentication; + } + + /// Initializes a new instance of . + /// authentication properties. DEFAULT: kubernetes.audience=aio-mq-internal. NOTE - Enum field only property is allowed. + /// Client ID prefix. Client ID generated by the dataflow is <prefix>-TBD. Optional; no prefix if omitted. + /// Host of the Broker in the form of <hostname>:<port>. Optional; connects to Broker if omitted. + /// Enable or disable websockets. + /// Broker KeepAlive for connection in seconds. + /// Whether or not to keep the retain setting. + /// The max number of messages to keep in flight. For subscribe, this is the receive maximum. For publish, this is the maximum number of messages to send before waiting for an ack. + /// Qos for Broker connection. + /// Session expiry in seconds. + /// TLS configuration. + /// Cloud event mapping config. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointMqtt(DataflowEndpointMqttAuthentication authentication, string clientIdPrefix, string host, BrokerProtocolType? protocol, int? keepAliveSeconds, MqttRetainType? retain, int? maxInflightMessages, int? qos, int? sessionExpirySeconds, TlsProperties tls, CloudEventAttributeType? cloudEventAttributes, IDictionary serializedAdditionalRawData) + { + Authentication = authentication; + ClientIdPrefix = clientIdPrefix; + Host = host; + Protocol = protocol; + KeepAliveSeconds = keepAliveSeconds; + Retain = retain; + MaxInflightMessages = maxInflightMessages; + Qos = qos; + SessionExpirySeconds = sessionExpirySeconds; + Tls = tls; + CloudEventAttributes = cloudEventAttributes; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointMqtt() + { + } + + /// authentication properties. DEFAULT: kubernetes.audience=aio-mq-internal. NOTE - Enum field only property is allowed. + public DataflowEndpointMqttAuthentication Authentication { get; set; } + /// Client ID prefix. Client ID generated by the dataflow is <prefix>-TBD. Optional; no prefix if omitted. + public string ClientIdPrefix { get; set; } + /// Host of the Broker in the form of <hostname>:<port>. Optional; connects to Broker if omitted. + public string Host { get; set; } + /// Enable or disable websockets. + public BrokerProtocolType? Protocol { get; set; } + /// Broker KeepAlive for connection in seconds. + public int? KeepAliveSeconds { get; set; } + /// Whether or not to keep the retain setting. + public MqttRetainType? Retain { get; set; } + /// The max number of messages to keep in flight. For subscribe, this is the receive maximum. For publish, this is the maximum number of messages to send before waiting for an ack. + public int? MaxInflightMessages { get; set; } + /// Qos for Broker connection. + public int? Qos { get; set; } + /// Session expiry in seconds. + public int? SessionExpirySeconds { get; set; } + /// TLS configuration. + public TlsProperties Tls { get; set; } + /// Cloud event mapping config. + public CloudEventAttributeType? CloudEventAttributes { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqttAuthentication.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqttAuthentication.Serialization.cs new file mode 100644 index 000000000000..3e57168431b5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqttAuthentication.Serialization.cs @@ -0,0 +1,185 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointMqttAuthentication : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointMqttAuthentication)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method.ToString()); + if (Optional.IsDefined(SystemAssignedManagedIdentitySettings)) + { + writer.WritePropertyName("systemAssignedManagedIdentitySettings"u8); + writer.WriteObjectValue(SystemAssignedManagedIdentitySettings, options); + } + if (Optional.IsDefined(UserAssignedManagedIdentitySettings)) + { + writer.WritePropertyName("userAssignedManagedIdentitySettings"u8); + writer.WriteObjectValue(UserAssignedManagedIdentitySettings, options); + } + if (Optional.IsDefined(ServiceAccountTokenSettings)) + { + writer.WritePropertyName("serviceAccountTokenSettings"u8); + writer.WriteObjectValue(ServiceAccountTokenSettings, options); + } + if (Optional.IsDefined(X509CertificateSettings)) + { + writer.WritePropertyName("x509CertificateSettings"u8); + writer.WriteObjectValue(X509CertificateSettings, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointMqttAuthentication 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(DataflowEndpointMqttAuthentication)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointMqttAuthentication(document.RootElement, options); + } + + internal static DataflowEndpointMqttAuthentication DeserializeDataflowEndpointMqttAuthentication(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MqttAuthMethod method = default; + DataflowEndpointAuthenticationSystemAssignedManagedIdentity systemAssignedManagedIdentitySettings = default; + DataflowEndpointAuthenticationUserAssignedManagedIdentity userAssignedManagedIdentitySettings = default; + DataflowEndpointAuthenticationServiceAccountToken serviceAccountTokenSettings = default; + DataflowEndpointAuthenticationX509 x509CertificateSettings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("method"u8)) + { + method = new MqttAuthMethod(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemAssignedManagedIdentitySettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemAssignedManagedIdentitySettings = DataflowEndpointAuthenticationSystemAssignedManagedIdentity.DeserializeDataflowEndpointAuthenticationSystemAssignedManagedIdentity(property.Value, options); + continue; + } + if (property.NameEquals("userAssignedManagedIdentitySettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userAssignedManagedIdentitySettings = DataflowEndpointAuthenticationUserAssignedManagedIdentity.DeserializeDataflowEndpointAuthenticationUserAssignedManagedIdentity(property.Value, options); + continue; + } + if (property.NameEquals("serviceAccountTokenSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + serviceAccountTokenSettings = DataflowEndpointAuthenticationServiceAccountToken.DeserializeDataflowEndpointAuthenticationServiceAccountToken(property.Value, options); + continue; + } + if (property.NameEquals("x509CertificateSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + x509CertificateSettings = DataflowEndpointAuthenticationX509.DeserializeDataflowEndpointAuthenticationX509(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowEndpointMqttAuthentication( + method, + systemAssignedManagedIdentitySettings, + userAssignedManagedIdentitySettings, + serviceAccountTokenSettings, + x509CertificateSettings, + 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointMqttAuthentication)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointMqttAuthentication 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); + return DeserializeDataflowEndpointMqttAuthentication(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointMqttAuthentication)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqttAuthentication.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqttAuthentication.cs new file mode 100644 index 000000000000..995133d81d46 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointMqttAuthentication.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Mqtt endpoint Authentication properties. NOTE - only authentication property is allowed per entry. + public partial class DataflowEndpointMqttAuthentication + { + /// + /// 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 . + /// Mode of Authentication. + public DataflowEndpointMqttAuthentication(MqttAuthMethod method) + { + Method = method; + } + + /// Initializes a new instance of . + /// Mode of Authentication. + /// System-assigned managed identity authentication. + /// User-assigned managed identity authentication. + /// Kubernetes service account token authentication. Default audience if not set is aio-mq-internal. + /// X.509 certificate authentication. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointMqttAuthentication(MqttAuthMethod method, DataflowEndpointAuthenticationSystemAssignedManagedIdentity systemAssignedManagedIdentitySettings, DataflowEndpointAuthenticationUserAssignedManagedIdentity userAssignedManagedIdentitySettings, DataflowEndpointAuthenticationServiceAccountToken serviceAccountTokenSettings, DataflowEndpointAuthenticationX509 x509CertificateSettings, IDictionary serializedAdditionalRawData) + { + Method = method; + SystemAssignedManagedIdentitySettings = systemAssignedManagedIdentitySettings; + UserAssignedManagedIdentitySettings = userAssignedManagedIdentitySettings; + ServiceAccountTokenSettings = serviceAccountTokenSettings; + X509CertificateSettings = x509CertificateSettings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointMqttAuthentication() + { + } + + /// Mode of Authentication. + public MqttAuthMethod Method { get; set; } + /// System-assigned managed identity authentication. + internal DataflowEndpointAuthenticationSystemAssignedManagedIdentity SystemAssignedManagedIdentitySettings { get; set; } + /// Audience of the service to authenticate against. Optional; defaults to the audience for Service host configuration. + public string SystemAssignedManagedIdentityAudience + { + get => SystemAssignedManagedIdentitySettings is null ? default : SystemAssignedManagedIdentitySettings.Audience; + set + { + if (SystemAssignedManagedIdentitySettings is null) + SystemAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationSystemAssignedManagedIdentity(); + SystemAssignedManagedIdentitySettings.Audience = value; + } + } + + /// User-assigned managed identity authentication. + public DataflowEndpointAuthenticationUserAssignedManagedIdentity UserAssignedManagedIdentitySettings { get; set; } + /// Kubernetes service account token authentication. Default audience if not set is aio-mq-internal. + internal DataflowEndpointAuthenticationServiceAccountToken ServiceAccountTokenSettings { get; set; } + /// Audience of the service account. Optional, defaults to the broker internal service account audience. + public string ServiceAccountTokenAudience + { + get => ServiceAccountTokenSettings is null ? default : ServiceAccountTokenSettings.Audience; + set => ServiceAccountTokenSettings = new DataflowEndpointAuthenticationServiceAccountToken(value); + } + + /// X.509 certificate authentication. + internal DataflowEndpointAuthenticationX509 X509CertificateSettings { get; set; } + /// Secret reference of the X.509 certificate. + public string X509CertificateSecretRef + { + get => X509CertificateSettings is null ? default : X509CertificateSettings.SecretRef; + set => X509CertificateSettings = new DataflowEndpointAuthenticationX509(value); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointProperties.Serialization.cs new file mode 100644 index 000000000000..52cfe4a36a66 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointProperties.Serialization.cs @@ -0,0 +1,233 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowEndpointProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("endpointType"u8); + writer.WriteStringValue(EndpointType.ToString()); + if (Optional.IsDefined(DataExplorerSettings)) + { + writer.WritePropertyName("dataExplorerSettings"u8); + writer.WriteObjectValue(DataExplorerSettings, options); + } + if (Optional.IsDefined(DataLakeStorageSettings)) + { + writer.WritePropertyName("dataLakeStorageSettings"u8); + writer.WriteObjectValue(DataLakeStorageSettings, options); + } + if (Optional.IsDefined(FabricOneLakeSettings)) + { + writer.WritePropertyName("fabricOneLakeSettings"u8); + writer.WriteObjectValue(FabricOneLakeSettings, options); + } + if (Optional.IsDefined(KafkaSettings)) + { + writer.WritePropertyName("kafkaSettings"u8); + writer.WriteObjectValue(KafkaSettings, options); + } + if (Optional.IsDefined(LocalStorageSettings)) + { + writer.WritePropertyName("localStorageSettings"u8); + writer.WriteObjectValue(LocalStorageSettings, options); + } + if (Optional.IsDefined(MqttSettings)) + { + writer.WritePropertyName("mqttSettings"u8); + writer.WriteObjectValue(MqttSettings, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointProperties 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(DataflowEndpointProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointProperties(document.RootElement, options); + } + + internal static DataflowEndpointProperties DeserializeDataflowEndpointProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EndpointType endpointType = default; + DataflowEndpointDataExplorer dataExplorerSettings = default; + DataflowEndpointDataLakeStorage dataLakeStorageSettings = default; + DataflowEndpointFabricOneLake fabricOneLakeSettings = default; + DataflowEndpointKafka kafkaSettings = default; + DataflowEndpointLocalStorage localStorageSettings = default; + DataflowEndpointMqtt mqttSettings = default; + ProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("endpointType"u8)) + { + endpointType = new EndpointType(property.Value.GetString()); + continue; + } + if (property.NameEquals("dataExplorerSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataExplorerSettings = DataflowEndpointDataExplorer.DeserializeDataflowEndpointDataExplorer(property.Value, options); + continue; + } + if (property.NameEquals("dataLakeStorageSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataLakeStorageSettings = DataflowEndpointDataLakeStorage.DeserializeDataflowEndpointDataLakeStorage(property.Value, options); + continue; + } + if (property.NameEquals("fabricOneLakeSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fabricOneLakeSettings = DataflowEndpointFabricOneLake.DeserializeDataflowEndpointFabricOneLake(property.Value, options); + continue; + } + if (property.NameEquals("kafkaSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kafkaSettings = DataflowEndpointKafka.DeserializeDataflowEndpointKafka(property.Value, options); + continue; + } + if (property.NameEquals("localStorageSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + localStorageSettings = DataflowEndpointLocalStorage.DeserializeDataflowEndpointLocalStorage(property.Value, options); + continue; + } + if (property.NameEquals("mqttSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mqttSettings = DataflowEndpointMqtt.DeserializeDataflowEndpointMqtt(property.Value, options); + 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 DataflowEndpointProperties( + endpointType, + dataExplorerSettings, + dataLakeStorageSettings, + fabricOneLakeSettings, + kafkaSettings, + localStorageSettings, + mqttSettings, + 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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointProperties)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointProperties 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); + return DeserializeDataflowEndpointProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointProperties.cs new file mode 100644 index 000000000000..fc165c1a45f0 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointProperties.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// DataflowEndpoint Resource properties. NOTE - Only one type of endpoint is supported for one Resource. + public partial class DataflowEndpointProperties + { + /// + /// 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 . + /// Endpoint Type. + public DataflowEndpointProperties(EndpointType endpointType) + { + EndpointType = endpointType; + } + + /// Initializes a new instance of . + /// Endpoint Type. + /// Azure Data Explorer endpoint. + /// Azure Data Lake endpoint. + /// Microsoft Fabric endpoint. + /// Kafka endpoint. + /// Local persistent volume endpoint. + /// Broker endpoint. + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointProperties(EndpointType endpointType, DataflowEndpointDataExplorer dataExplorerSettings, DataflowEndpointDataLakeStorage dataLakeStorageSettings, DataflowEndpointFabricOneLake fabricOneLakeSettings, DataflowEndpointKafka kafkaSettings, DataflowEndpointLocalStorage localStorageSettings, DataflowEndpointMqtt mqttSettings, ProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + EndpointType = endpointType; + DataExplorerSettings = dataExplorerSettings; + DataLakeStorageSettings = dataLakeStorageSettings; + FabricOneLakeSettings = fabricOneLakeSettings; + KafkaSettings = kafkaSettings; + LocalStorageSettings = localStorageSettings; + MqttSettings = mqttSettings; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointProperties() + { + } + + /// Endpoint Type. + public EndpointType EndpointType { get; set; } + /// Azure Data Explorer endpoint. + public DataflowEndpointDataExplorer DataExplorerSettings { get; set; } + /// Azure Data Lake endpoint. + public DataflowEndpointDataLakeStorage DataLakeStorageSettings { get; set; } + /// Microsoft Fabric endpoint. + public DataflowEndpointFabricOneLake FabricOneLakeSettings { get; set; } + /// Kafka endpoint. + public DataflowEndpointKafka KafkaSettings { get; set; } + /// Local persistent volume endpoint. + internal DataflowEndpointLocalStorage LocalStorageSettings { get; set; } + /// Persistent volume claim name. + public string LocalStoragePersistentVolumeClaimRef + { + get => LocalStorageSettings is null ? default : LocalStorageSettings.PersistentVolumeClaimRef; + set => LocalStorageSettings = new DataflowEndpointLocalStorage(value); + } + + /// Broker endpoint. + public DataflowEndpointMqtt MqttSettings { get; set; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointResourceListResult.Serialization.cs new file mode 100644 index 000000000000..e73e3dceab5e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointResourceListResult.Serialization.cs @@ -0,0 +1,144 @@ +// 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.IoTOperations.Models +{ + internal partial class DataflowEndpointResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointResourceListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowEndpointResourceListResult 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(DataflowEndpointResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowEndpointResourceListResult(document.RootElement, options); + } + + internal static DataflowEndpointResourceListResult DeserializeDataflowEndpointResourceListResult(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(DataflowEndpointResourceData.DeserializeDataflowEndpointResourceData(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 DataflowEndpointResourceListResult(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); + default: + throw new FormatException($"The model {nameof(DataflowEndpointResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + DataflowEndpointResourceListResult 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); + return DeserializeDataflowEndpointResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowEndpointResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointResourceListResult.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointResourceListResult.cs new file mode 100644 index 000000000000..0fb3ab689f95 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowEndpointResourceListResult.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.IoTOperations.Models +{ + /// The response of a DataflowEndpointResource list operation. + internal partial class DataflowEndpointResourceListResult + { + /// + /// 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 DataflowEndpointResource items on this page. + /// is null. + internal DataflowEndpointResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The DataflowEndpointResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal DataflowEndpointResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowEndpointResourceListResult() + { + } + + /// The DataflowEndpointResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowInstanceProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowInstanceProperties.Serialization.cs new file mode 100644 index 000000000000..4666bfc7fca4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowInstanceProperties.Serialization.cs @@ -0,0 +1,119 @@ +// 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.IoTOperations.Models +{ + internal partial class DataflowInstanceProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowInstanceProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowInstanceProperties 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(DataflowInstanceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowInstanceProperties(document.RootElement, options); + } + + internal static DataflowInstanceProperties DeserializeDataflowInstanceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode state = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("state"u8)) + { + state = new OperationalMode(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowInstanceProperties(state, 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); + default: + throw new FormatException($"The model {nameof(DataflowInstanceProperties)} does not support writing '{options.Format}' format."); + } + } + + DataflowInstanceProperties 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); + return DeserializeDataflowInstanceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowInstanceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowInstanceProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowInstanceProperties.cs new file mode 100644 index 000000000000..e3d492d4cafc --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowInstanceProperties.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.IoTOperations.Models +{ + /// The properties of an Dataflow instance. + internal partial class DataflowInstanceProperties + { + /// + /// 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 . + /// This determines if the Dataflow service is enabled. + public DataflowInstanceProperties(OperationalMode state) + { + State = state; + } + + /// Initializes a new instance of . + /// This determines if the Dataflow service is enabled. + /// Keeps track of any properties unknown to the library. + internal DataflowInstanceProperties(OperationalMode state, IDictionary serializedAdditionalRawData) + { + State = state; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowInstanceProperties() + { + } + + /// This determines if the Dataflow service is enabled. + public OperationalMode State { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowMappingType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowMappingType.cs new file mode 100644 index 000000000000..ac3c40e3b295 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowMappingType.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.IoTOperations.Models +{ + /// Dataflow type mapping properties. + public readonly partial struct DataflowMappingType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataflowMappingType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NewPropertiesValue = "NewProperties"; + private const string RenameValue = "Rename"; + private const string ComputeValue = "Compute"; + private const string PassThroughValue = "PassThrough"; + private const string BuiltInFunctionValue = "BuiltInFunction"; + + /// New Properties type. + public static DataflowMappingType NewProperties { get; } = new DataflowMappingType(NewPropertiesValue); + /// Rename type. + public static DataflowMappingType Rename { get; } = new DataflowMappingType(RenameValue); + /// Compute type. + public static DataflowMappingType Compute { get; } = new DataflowMappingType(ComputeValue); + /// Pass-through type. + public static DataflowMappingType PassThrough { get; } = new DataflowMappingType(PassThroughValue); + /// Built in function type. + public static DataflowMappingType BuiltInFunction { get; } = new DataflowMappingType(BuiltInFunctionValue); + /// Determines if two values are the same. + public static bool operator ==(DataflowMappingType left, DataflowMappingType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataflowMappingType left, DataflowMappingType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DataflowMappingType(string value) => new DataflowMappingType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataflowMappingType other && Equals(other); + /// + public bool Equals(DataflowMappingType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowOperation.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowOperation.Serialization.cs new file mode 100644 index 000000000000..b68bb6b0d2b1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowOperation.Serialization.cs @@ -0,0 +1,181 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowOperation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowOperation)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("operationType"u8); + writer.WriteStringValue(OperationType.ToString()); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(SourceSettings)) + { + writer.WritePropertyName("sourceSettings"u8); + writer.WriteObjectValue(SourceSettings, options); + } + if (Optional.IsDefined(BuiltInTransformationSettings)) + { + writer.WritePropertyName("builtInTransformationSettings"u8); + writer.WriteObjectValue(BuiltInTransformationSettings, options); + } + if (Optional.IsDefined(DestinationSettings)) + { + writer.WritePropertyName("destinationSettings"u8); + writer.WriteObjectValue(DestinationSettings, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowOperation 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(DataflowOperation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowOperation(document.RootElement, options); + } + + internal static DataflowOperation DeserializeDataflowOperation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationType operationType = default; + string name = default; + DataflowSourceOperationSettings sourceSettings = default; + DataflowBuiltInTransformationSettings builtInTransformationSettings = default; + DataflowDestinationOperationSettings destinationSettings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operationType"u8)) + { + operationType = new OperationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("sourceSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceSettings = DataflowSourceOperationSettings.DeserializeDataflowSourceOperationSettings(property.Value, options); + continue; + } + if (property.NameEquals("builtInTransformationSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + builtInTransformationSettings = DataflowBuiltInTransformationSettings.DeserializeDataflowBuiltInTransformationSettings(property.Value, options); + continue; + } + if (property.NameEquals("destinationSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + destinationSettings = DataflowDestinationOperationSettings.DeserializeDataflowDestinationOperationSettings(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowOperation( + operationType, + name, + sourceSettings, + builtInTransformationSettings, + destinationSettings, + 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); + default: + throw new FormatException($"The model {nameof(DataflowOperation)} does not support writing '{options.Format}' format."); + } + } + + DataflowOperation 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); + return DeserializeDataflowOperation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowOperation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowOperation.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowOperation.cs new file mode 100644 index 000000000000..264c7687e600 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowOperation.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Dataflow Operation properties. NOTE - One only method is allowed to be used for one entry. + public partial class DataflowOperation + { + /// + /// 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 . + /// Type of operation. + public DataflowOperation(OperationType operationType) + { + OperationType = operationType; + } + + /// Initializes a new instance of . + /// Type of operation. + /// Optional user provided name of the transformation. + /// Source configuration. + /// Built In Transformation configuration. + /// Destination configuration. + /// Keeps track of any properties unknown to the library. + internal DataflowOperation(OperationType operationType, string name, DataflowSourceOperationSettings sourceSettings, DataflowBuiltInTransformationSettings builtInTransformationSettings, DataflowDestinationOperationSettings destinationSettings, IDictionary serializedAdditionalRawData) + { + OperationType = operationType; + Name = name; + SourceSettings = sourceSettings; + BuiltInTransformationSettings = builtInTransformationSettings; + DestinationSettings = destinationSettings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowOperation() + { + } + + /// Type of operation. + public OperationType OperationType { get; set; } + /// Optional user provided name of the transformation. + public string Name { get; set; } + /// Source configuration. + public DataflowSourceOperationSettings SourceSettings { get; set; } + /// Built In Transformation configuration. + public DataflowBuiltInTransformationSettings BuiltInTransformationSettings { get; set; } + /// Destination configuration. + public DataflowDestinationOperationSettings DestinationSettings { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileProperties.Serialization.cs new file mode 100644 index 000000000000..89a2ba3ae23e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileProperties.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.Json; +using Azure.Core; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + public partial class DataflowProfileProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowProfileProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Diagnostics)) + { + writer.WritePropertyName("diagnostics"u8); + writer.WriteObjectValue(Diagnostics, options); + } + if (Optional.IsDefined(InstanceCount)) + { + writer.WritePropertyName("instanceCount"u8); + writer.WriteNumberValue(InstanceCount.Value); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowProfileProperties 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(DataflowProfileProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowProfileProperties(document.RootElement, options); + } + + internal static DataflowProfileProperties DeserializeDataflowProfileProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProfileDiagnostics diagnostics = default; + int? instanceCount = default; + ProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("diagnostics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diagnostics = ProfileDiagnostics.DeserializeProfileDiagnostics(property.Value, options); + continue; + } + if (property.NameEquals("instanceCount"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + instanceCount = property.Value.GetInt32(); + 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 DataflowProfileProperties(diagnostics, instanceCount, 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); + default: + throw new FormatException($"The model {nameof(DataflowProfileProperties)} does not support writing '{options.Format}' format."); + } + } + + DataflowProfileProperties 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); + return DeserializeDataflowProfileProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowProfileProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileProperties.cs new file mode 100644 index 000000000000..4105673e0279 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileProperties.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// DataflowProfile Resource properties. + public partial class DataflowProfileProperties + { + /// + /// 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 DataflowProfileProperties() + { + } + + /// Initializes a new instance of . + /// Spec defines the desired identities of NBC diagnostics settings. + /// To manually scale the dataflow profile, specify the maximum number of instances you want to run. + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal DataflowProfileProperties(ProfileDiagnostics diagnostics, int? instanceCount, ProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + Diagnostics = diagnostics; + InstanceCount = instanceCount; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Spec defines the desired identities of NBC diagnostics settings. + public ProfileDiagnostics Diagnostics { get; set; } + /// To manually scale the dataflow profile, specify the maximum number of instances you want to run. + public int? InstanceCount { get; set; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileResourceListResult.Serialization.cs new file mode 100644 index 000000000000..583373e3f1d5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileResourceListResult.Serialization.cs @@ -0,0 +1,144 @@ +// 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.IoTOperations.Models +{ + internal partial class DataflowProfileResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowProfileResourceListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowProfileResourceListResult 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(DataflowProfileResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowProfileResourceListResult(document.RootElement, options); + } + + internal static DataflowProfileResourceListResult DeserializeDataflowProfileResourceListResult(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(DataflowProfileResourceData.DeserializeDataflowProfileResourceData(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 DataflowProfileResourceListResult(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); + default: + throw new FormatException($"The model {nameof(DataflowProfileResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + DataflowProfileResourceListResult 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); + return DeserializeDataflowProfileResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowProfileResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileResourceListResult.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileResourceListResult.cs new file mode 100644 index 000000000000..73acf9e2870e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProfileResourceListResult.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.IoTOperations.Models +{ + /// The response of a DataflowProfileResource list operation. + internal partial class DataflowProfileResourceListResult + { + /// + /// 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 DataflowProfileResource items on this page. + /// is null. + internal DataflowProfileResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The DataflowProfileResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal DataflowProfileResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowProfileResourceListResult() + { + } + + /// The DataflowProfileResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProperties.Serialization.cs new file mode 100644 index 000000000000..d910394856c2 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProperties.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.IoTOperations.Models +{ + public partial class DataflowProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + writer.WritePropertyName("operations"u8); + writer.WriteStartArray(); + foreach (var item in Operations) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowProperties 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(DataflowProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowProperties(document.RootElement, options); + } + + internal static DataflowProperties DeserializeDataflowProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode? mode = default; + IList operations = default; + ProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("mode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mode = new OperationalMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("operations"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DataflowOperation.DeserializeDataflowOperation(item, options)); + } + operations = 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 DataflowProperties(mode, operations, 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); + default: + throw new FormatException($"The model {nameof(DataflowProperties)} does not support writing '{options.Format}' format."); + } + } + + DataflowProperties 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); + return DeserializeDataflowProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProperties.cs new file mode 100644 index 000000000000..e5be51824bb9 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowProperties.cs @@ -0,0 +1,84 @@ +// 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.IoTOperations.Models +{ + /// Dataflow Resource properties. + public partial class DataflowProperties + { + /// + /// 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 . + /// List of operations including source and destination references as well as transformation. + /// is null. + public DataflowProperties(IEnumerable operations) + { + Argument.AssertNotNull(operations, nameof(operations)); + + Operations = operations.ToList(); + } + + /// Initializes a new instance of . + /// Mode for Dataflow. Optional; defaults to Enabled. + /// List of operations including source and destination references as well as transformation. + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal DataflowProperties(OperationalMode? mode, IList operations, ProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + Mode = mode; + Operations = operations; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowProperties() + { + } + + /// Mode for Dataflow. Optional; defaults to Enabled. + public OperationalMode? Mode { get; set; } + /// List of operations including source and destination references as well as transformation. + public IList Operations { get; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowResourceListResult.Serialization.cs new file mode 100644 index 000000000000..5ef55a5d7f33 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowResourceListResult.Serialization.cs @@ -0,0 +1,144 @@ +// 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.IoTOperations.Models +{ + internal partial class DataflowResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowResourceListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowResourceListResult 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(DataflowResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowResourceListResult(document.RootElement, options); + } + + internal static DataflowResourceListResult DeserializeDataflowResourceListResult(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(DataflowResourceData.DeserializeDataflowResourceData(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 DataflowResourceListResult(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); + default: + throw new FormatException($"The model {nameof(DataflowResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + DataflowResourceListResult 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); + return DeserializeDataflowResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowResourceListResult.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowResourceListResult.cs new file mode 100644 index 000000000000..6811403a9a59 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowResourceListResult.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.IoTOperations.Models +{ + /// The response of a DataflowResource list operation. + internal partial class DataflowResourceListResult + { + /// + /// 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 DataflowResource items on this page. + /// is null. + internal DataflowResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The DataflowResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal DataflowResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowResourceListResult() + { + } + + /// The DataflowResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowSourceOperationSettings.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowSourceOperationSettings.Serialization.cs new file mode 100644 index 000000000000..e2e0ef50794d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowSourceOperationSettings.Serialization.cs @@ -0,0 +1,180 @@ +// 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.IoTOperations.Models +{ + public partial class DataflowSourceOperationSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowSourceOperationSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("endpointRef"u8); + writer.WriteStringValue(EndpointRef); + if (Optional.IsDefined(AssetRef)) + { + writer.WritePropertyName("assetRef"u8); + writer.WriteStringValue(AssetRef); + } + if (Optional.IsDefined(SerializationFormat)) + { + writer.WritePropertyName("serializationFormat"u8); + writer.WriteStringValue(SerializationFormat.Value.ToString()); + } + if (Optional.IsDefined(SchemaRef)) + { + writer.WritePropertyName("schemaRef"u8); + writer.WriteStringValue(SchemaRef); + } + writer.WritePropertyName("dataSources"u8); + writer.WriteStartArray(); + foreach (var item in DataSources) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DataflowSourceOperationSettings 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(DataflowSourceOperationSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowSourceOperationSettings(document.RootElement, options); + } + + internal static DataflowSourceOperationSettings DeserializeDataflowSourceOperationSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string endpointRef = default; + string assetRef = default; + SourceSerializationFormat? serializationFormat = default; + string schemaRef = default; + IList dataSources = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("endpointRef"u8)) + { + endpointRef = property.Value.GetString(); + continue; + } + if (property.NameEquals("assetRef"u8)) + { + assetRef = property.Value.GetString(); + continue; + } + if (property.NameEquals("serializationFormat"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + serializationFormat = new SourceSerializationFormat(property.Value.GetString()); + continue; + } + if (property.NameEquals("schemaRef"u8)) + { + schemaRef = property.Value.GetString(); + continue; + } + if (property.NameEquals("dataSources"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + dataSources = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DataflowSourceOperationSettings( + endpointRef, + assetRef, + serializationFormat, + schemaRef, + dataSources, + 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); + default: + throw new FormatException($"The model {nameof(DataflowSourceOperationSettings)} does not support writing '{options.Format}' format."); + } + } + + DataflowSourceOperationSettings 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); + return DeserializeDataflowSourceOperationSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowSourceOperationSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowSourceOperationSettings.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowSourceOperationSettings.cs new file mode 100644 index 000000000000..05d37e0e3541 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DataflowSourceOperationSettings.cs @@ -0,0 +1,95 @@ +// 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.IoTOperations.Models +{ + /// Dataflow Source Operation properties. + public partial class DataflowSourceOperationSettings + { + /// + /// 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 . + /// Reference to the Dataflow Endpoint resource. Can only be of Broker and Kafka type. + /// List of source locations. Can be Broker or Kafka topics. Supports wildcards # and +. + /// or is null. + public DataflowSourceOperationSettings(string endpointRef, IEnumerable dataSources) + { + Argument.AssertNotNull(endpointRef, nameof(endpointRef)); + Argument.AssertNotNull(dataSources, nameof(dataSources)); + + EndpointRef = endpointRef; + DataSources = dataSources.ToList(); + } + + /// Initializes a new instance of . + /// Reference to the Dataflow Endpoint resource. Can only be of Broker and Kafka type. + /// Reference to the resource in Azure Device Registry where the data in the endpoint originates from. + /// Content is a JSON Schema. Allowed: JSON Schema/draft-7. + /// Schema CR reference. Data will be deserialized according to the schema, and dropped if it doesn't match. + /// List of source locations. Can be Broker or Kafka topics. Supports wildcards # and +. + /// Keeps track of any properties unknown to the library. + internal DataflowSourceOperationSettings(string endpointRef, string assetRef, SourceSerializationFormat? serializationFormat, string schemaRef, IList dataSources, IDictionary serializedAdditionalRawData) + { + EndpointRef = endpointRef; + AssetRef = assetRef; + SerializationFormat = serializationFormat; + SchemaRef = schemaRef; + DataSources = dataSources; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DataflowSourceOperationSettings() + { + } + + /// Reference to the Dataflow Endpoint resource. Can only be of Broker and Kafka type. + public string EndpointRef { get; set; } + /// Reference to the resource in Azure Device Registry where the data in the endpoint originates from. + public string AssetRef { get; set; } + /// Content is a JSON Schema. Allowed: JSON Schema/draft-7. + public SourceSerializationFormat? SerializationFormat { get; set; } + /// Schema CR reference. Data will be deserialized according to the schema, and dropped if it doesn't match. + public string SchemaRef { get; set; } + /// List of source locations. Can be Broker or Kafka topics. Supports wildcards # and +. + public IList DataSources { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiagnosticsLogs.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiagnosticsLogs.Serialization.cs new file mode 100644 index 000000000000..5e749538eae6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiagnosticsLogs.Serialization.cs @@ -0,0 +1,137 @@ +// 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.IoTOperations.Models +{ + public partial class DiagnosticsLogs : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DiagnosticsLogs)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(OpentelemetryExportConfig)) + { + writer.WritePropertyName("opentelemetryExportConfig"u8); + writer.WriteObjectValue(OpentelemetryExportConfig, options); + } + if (Optional.IsDefined(Level)) + { + writer.WritePropertyName("level"u8); + writer.WriteStringValue(Level); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DiagnosticsLogs 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(DiagnosticsLogs)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDiagnosticsLogs(document.RootElement, options); + } + + internal static DiagnosticsLogs DeserializeDiagnosticsLogs(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenTelemetryLogExportConfig opentelemetryExportConfig = default; + string level = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("opentelemetryExportConfig"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + opentelemetryExportConfig = OpenTelemetryLogExportConfig.DeserializeOpenTelemetryLogExportConfig(property.Value, options); + continue; + } + if (property.NameEquals("level"u8)) + { + level = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DiagnosticsLogs(opentelemetryExportConfig, level, 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); + default: + throw new FormatException($"The model {nameof(DiagnosticsLogs)} does not support writing '{options.Format}' format."); + } + } + + DiagnosticsLogs 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); + return DeserializeDiagnosticsLogs(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DiagnosticsLogs)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiagnosticsLogs.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiagnosticsLogs.cs new file mode 100644 index 000000000000..53ea1935dbca --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiagnosticsLogs.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.IoTOperations.Models +{ + /// Diagnostic Log properties. + public partial class DiagnosticsLogs + { + /// + /// 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 DiagnosticsLogs() + { + } + + /// Initializes a new instance of . + /// The open telemetry export configuration. + /// The log level. Examples - 'debug', 'info', 'warn', 'error', 'trace'. + /// Keeps track of any properties unknown to the library. + internal DiagnosticsLogs(OpenTelemetryLogExportConfig opentelemetryExportConfig, string level, IDictionary serializedAdditionalRawData) + { + OpentelemetryExportConfig = opentelemetryExportConfig; + Level = level; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The open telemetry export configuration. + public OpenTelemetryLogExportConfig OpentelemetryExportConfig { get; set; } + /// The log level. Examples - 'debug', 'info', 'warn', 'error', 'trace'. + public string Level { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiskBackedMessageBuffer.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiskBackedMessageBuffer.Serialization.cs new file mode 100644 index 000000000000..352fd4751732 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiskBackedMessageBuffer.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.IoTOperations.Models +{ + public partial class DiskBackedMessageBuffer : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DiskBackedMessageBuffer)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("maxSize"u8); + writer.WriteStringValue(MaxSize); + if (Optional.IsDefined(EphemeralVolumeClaimSpec)) + { + writer.WritePropertyName("ephemeralVolumeClaimSpec"u8); + writer.WriteObjectValue(EphemeralVolumeClaimSpec, options); + } + if (Optional.IsDefined(PersistentVolumeClaimSpec)) + { + writer.WritePropertyName("persistentVolumeClaimSpec"u8); + writer.WriteObjectValue(PersistentVolumeClaimSpec, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DiskBackedMessageBuffer 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(DiskBackedMessageBuffer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDiskBackedMessageBuffer(document.RootElement, options); + } + + internal static DiskBackedMessageBuffer DeserializeDiskBackedMessageBuffer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string maxSize = default; + VolumeClaimSpec ephemeralVolumeClaimSpec = default; + VolumeClaimSpec persistentVolumeClaimSpec = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("maxSize"u8)) + { + maxSize = property.Value.GetString(); + continue; + } + if (property.NameEquals("ephemeralVolumeClaimSpec"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + ephemeralVolumeClaimSpec = VolumeClaimSpec.DeserializeVolumeClaimSpec(property.Value, options); + continue; + } + if (property.NameEquals("persistentVolumeClaimSpec"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + persistentVolumeClaimSpec = VolumeClaimSpec.DeserializeVolumeClaimSpec(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DiskBackedMessageBuffer(maxSize, ephemeralVolumeClaimSpec, persistentVolumeClaimSpec, 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); + default: + throw new FormatException($"The model {nameof(DiskBackedMessageBuffer)} does not support writing '{options.Format}' format."); + } + } + + DiskBackedMessageBuffer 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); + return DeserializeDiskBackedMessageBuffer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DiskBackedMessageBuffer)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiskBackedMessageBuffer.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiskBackedMessageBuffer.cs new file mode 100644 index 000000000000..4888b54b4fbf --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/DiskBackedMessageBuffer.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// DiskBackedMessageBuffer properties. + public partial class DiskBackedMessageBuffer + { + /// + /// 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 max size of the message buffer on disk. If a PVC template is specified using one of ephemeralVolumeClaimSpec or persistentVolumeClaimSpec, then this size is used as the request and limit sizes of that template. If neither ephemeralVolumeClaimSpec nor persistentVolumeClaimSpec are specified, then an emptyDir volume is mounted with this size as its limit. See <https://kubernetes.io/docs/concepts/storage/volumes/#emptydir> for details. + /// is null. + public DiskBackedMessageBuffer(string maxSize) + { + Argument.AssertNotNull(maxSize, nameof(maxSize)); + + MaxSize = maxSize; + } + + /// Initializes a new instance of . + /// The max size of the message buffer on disk. If a PVC template is specified using one of ephemeralVolumeClaimSpec or persistentVolumeClaimSpec, then this size is used as the request and limit sizes of that template. If neither ephemeralVolumeClaimSpec nor persistentVolumeClaimSpec are specified, then an emptyDir volume is mounted with this size as its limit. See <https://kubernetes.io/docs/concepts/storage/volumes/#emptydir> for details. + /// Use the specified persistent volume claim template to mount a "generic ephemeral volume" for the message buffer. See <https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/#generic-ephemeral-volumes> for details. + /// Use the specified persistent volume claim template to mount a persistent volume for the message buffer. + /// Keeps track of any properties unknown to the library. + internal DiskBackedMessageBuffer(string maxSize, VolumeClaimSpec ephemeralVolumeClaimSpec, VolumeClaimSpec persistentVolumeClaimSpec, IDictionary serializedAdditionalRawData) + { + MaxSize = maxSize; + EphemeralVolumeClaimSpec = ephemeralVolumeClaimSpec; + PersistentVolumeClaimSpec = persistentVolumeClaimSpec; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DiskBackedMessageBuffer() + { + } + + /// The max size of the message buffer on disk. If a PVC template is specified using one of ephemeralVolumeClaimSpec or persistentVolumeClaimSpec, then this size is used as the request and limit sizes of that template. If neither ephemeralVolumeClaimSpec nor persistentVolumeClaimSpec are specified, then an emptyDir volume is mounted with this size as its limit. See <https://kubernetes.io/docs/concepts/storage/volumes/#emptydir> for details. + public string MaxSize { get; set; } + /// Use the specified persistent volume claim template to mount a "generic ephemeral volume" for the message buffer. See <https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/#generic-ephemeral-volumes> for details. + public VolumeClaimSpec EphemeralVolumeClaimSpec { get; set; } + /// Use the specified persistent volume claim template to mount a persistent volume for the message buffer. + public VolumeClaimSpec PersistentVolumeClaimSpec { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/EndpointType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/EndpointType.cs new file mode 100644 index 000000000000..7cdc3a5dee04 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/EndpointType.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.IoTOperations.Models +{ + /// DataflowEndpoint Type properties. + public readonly partial struct EndpointType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public EndpointType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DataExplorerValue = "DataExplorer"; + private const string DataLakeStorageValue = "DataLakeStorage"; + private const string FabricOneLakeValue = "FabricOneLake"; + private const string KafkaValue = "Kafka"; + private const string LocalStorageValue = "LocalStorage"; + private const string MqttValue = "Mqtt"; + + /// Azure Data Explorer Type. + public static EndpointType DataExplorer { get; } = new EndpointType(DataExplorerValue); + /// Azure Data Lake Type. + public static EndpointType DataLakeStorage { get; } = new EndpointType(DataLakeStorageValue); + /// Microsoft Fabric Type. + public static EndpointType FabricOneLake { get; } = new EndpointType(FabricOneLakeValue); + /// Kafka Type. + public static EndpointType Kafka { get; } = new EndpointType(KafkaValue); + /// Local Storage Type. + public static EndpointType LocalStorage { get; } = new EndpointType(LocalStorageValue); + /// Broker Type. + public static EndpointType Mqtt { get; } = new EndpointType(MqttValue); + /// Determines if two values are the same. + public static bool operator ==(EndpointType left, EndpointType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(EndpointType left, EndpointType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator EndpointType(string value) => new EndpointType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EndpointType other && Equals(other); + /// + public bool Equals(EndpointType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocation.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocation.Serialization.cs new file mode 100644 index 000000000000..69a9fe39eed6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocation.Serialization.cs @@ -0,0 +1,127 @@ +// 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.IoTOperations.Models +{ + public partial class ExtendedLocation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExtendedLocation)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ExtendedLocation 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(ExtendedLocation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExtendedLocation(document.RootElement, options); + } + + internal static ExtendedLocation DeserializeExtendedLocation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + ExtendedLocationType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ExtendedLocationType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ExtendedLocation(name, 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); + default: + throw new FormatException($"The model {nameof(ExtendedLocation)} does not support writing '{options.Format}' format."); + } + } + + ExtendedLocation 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); + return DeserializeExtendedLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExtendedLocation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocation.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocation.cs new file mode 100644 index 000000000000..7baef78f7eb6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocation.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.IoTOperations.Models +{ + /// Extended location is an extension of Azure locations. They provide a way to use their Azure ARC enabled Kubernetes clusters as target locations for deploying Azure services instances. + public partial class ExtendedLocation + { + /// + /// 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 name of the extended location. + /// Type of ExtendedLocation. + /// is null. + public ExtendedLocation(string name, ExtendedLocationType type) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + Type = type; + } + + /// Initializes a new instance of . + /// The name of the extended location. + /// Type of ExtendedLocation. + /// Keeps track of any properties unknown to the library. + internal ExtendedLocation(string name, ExtendedLocationType type, IDictionary serializedAdditionalRawData) + { + Name = name; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ExtendedLocation() + { + } + + /// The name of the extended location. + public string Name { get; set; } + /// Type of ExtendedLocation. + public ExtendedLocationType Type { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocationType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocationType.cs new file mode 100644 index 000000000000..c88ed806250f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ExtendedLocationType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// The enum defining type of ExtendedLocation accepted. + public readonly partial struct ExtendedLocationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ExtendedLocationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CustomLocationValue = "CustomLocation"; + + /// CustomLocation type. + public static ExtendedLocationType CustomLocation { get; } = new ExtendedLocationType(CustomLocationValue); + /// Determines if two values are the same. + public static bool operator ==(ExtendedLocationType left, ExtendedLocationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ExtendedLocationType left, ExtendedLocationType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ExtendedLocationType(string value) => new ExtendedLocationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ExtendedLocationType other && Equals(other); + /// + public bool Equals(ExtendedLocationType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/FabricOneLakeAuthMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/FabricOneLakeAuthMethod.cs new file mode 100644 index 000000000000..dc62db8535e4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/FabricOneLakeAuthMethod.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.IoTOperations.Models +{ + /// DataflowEndpoint Fabric One Lake Authentication Method properties. + public readonly partial struct FabricOneLakeAuthMethod : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FabricOneLakeAuthMethod(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SystemAssignedManagedIdentityValue = "SystemAssignedManagedIdentity"; + private const string UserAssignedManagedIdentityValue = "UserAssignedManagedIdentity"; + + /// SystemAssignedManagedIdentity type. + public static FabricOneLakeAuthMethod SystemAssignedManagedIdentity { get; } = new FabricOneLakeAuthMethod(SystemAssignedManagedIdentityValue); + /// UserAssignedManagedIdentity type. + public static FabricOneLakeAuthMethod UserAssignedManagedIdentity { get; } = new FabricOneLakeAuthMethod(UserAssignedManagedIdentityValue); + /// Determines if two values are the same. + public static bool operator ==(FabricOneLakeAuthMethod left, FabricOneLakeAuthMethod right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FabricOneLakeAuthMethod left, FabricOneLakeAuthMethod right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator FabricOneLakeAuthMethod(string value) => new FabricOneLakeAuthMethod(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FabricOneLakeAuthMethod other && Equals(other); + /// + public bool Equals(FabricOneLakeAuthMethod 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/FilterType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/FilterType.cs new file mode 100644 index 000000000000..a1de86ad98ff --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/FilterType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Filter Type properties. + public readonly partial struct FilterType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FilterType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FilterValue = "Filter"; + + /// Filter type. + public static FilterType Filter { get; } = new FilterType(FilterValue); + /// Determines if two values are the same. + public static bool operator ==(FilterType left, FilterType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FilterType left, FilterType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator FilterType(string value) => new FilterType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FilterType other && Equals(other); + /// + public bool Equals(FilterType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Frontend.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Frontend.Serialization.cs new file mode 100644 index 000000000000..8596bab6ed4a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Frontend.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.IoTOperations.Models +{ + public partial class Frontend : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Frontend)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("replicas"u8); + writer.WriteNumberValue(Replicas); + if (Optional.IsDefined(Workers)) + { + writer.WritePropertyName("workers"u8); + writer.WriteNumberValue(Workers.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Frontend 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(Frontend)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFrontend(document.RootElement, options); + } + + internal static Frontend DeserializeFrontend(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int replicas = default; + int? workers = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("replicas"u8)) + { + replicas = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("workers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + workers = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Frontend(replicas, workers, 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); + default: + throw new FormatException($"The model {nameof(Frontend)} does not support writing '{options.Format}' format."); + } + } + + Frontend 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); + return DeserializeFrontend(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Frontend)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Frontend.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Frontend.cs new file mode 100644 index 000000000000..0db1d6c6022f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Frontend.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// The desired properties of the frontend instances of the Broker. + public partial class Frontend + { + /// + /// 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 desired number of frontend instances (pods). + public Frontend(int replicas) + { + Replicas = replicas; + } + + /// Initializes a new instance of . + /// The desired number of frontend instances (pods). + /// Number of logical frontend workers per instance (pod). + /// Keeps track of any properties unknown to the library. + internal Frontend(int replicas, int? workers, IDictionary serializedAdditionalRawData) + { + Replicas = replicas; + Workers = workers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Frontend() + { + } + + /// The desired number of frontend instances (pods). + public int Replicas { get; set; } + /// Number of logical frontend workers per instance (pod). + public int? Workers { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/GenerateResourceLimits.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/GenerateResourceLimits.Serialization.cs new file mode 100644 index 000000000000..6b47fa98146f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/GenerateResourceLimits.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.IoTOperations.Models +{ + internal partial class GenerateResourceLimits : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GenerateResourceLimits)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Cpu)) + { + writer.WritePropertyName("cpu"u8); + writer.WriteStringValue(Cpu.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + GenerateResourceLimits 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(GenerateResourceLimits)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGenerateResourceLimits(document.RootElement, options); + } + + internal static GenerateResourceLimits DeserializeGenerateResourceLimits(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode? cpu = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("cpu"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + cpu = new OperationalMode(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new GenerateResourceLimits(cpu, 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); + default: + throw new FormatException($"The model {nameof(GenerateResourceLimits)} does not support writing '{options.Format}' format."); + } + } + + GenerateResourceLimits 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); + return DeserializeGenerateResourceLimits(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GenerateResourceLimits)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/GenerateResourceLimits.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/GenerateResourceLimits.cs new file mode 100644 index 000000000000..762f13aff91f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/GenerateResourceLimits.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.IoTOperations.Models +{ + /// GenerateResourceLimits properties. + internal partial class GenerateResourceLimits + { + /// + /// 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 GenerateResourceLimits() + { + } + + /// Initializes a new instance of . + /// The toggle to enable/disable cpu resource limits. + /// Keeps track of any properties unknown to the library. + internal GenerateResourceLimits(OperationalMode? cpu, IDictionary serializedAdditionalRawData) + { + Cpu = cpu; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The toggle to enable/disable cpu resource limits. + public OperationalMode? Cpu { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceProperties.Serialization.cs new file mode 100644 index 000000000000..f112c35eb113 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceProperties.Serialization.cs @@ -0,0 +1,177 @@ +// 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.IoTOperations.Models +{ + public partial class InstanceProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InstanceProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Version)) + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + writer.WritePropertyName("schemaRegistryNamespace"u8); + writer.WriteStringValue(SchemaRegistryNamespace); + if (Optional.IsDefined(Components)) + { + writer.WritePropertyName("components"u8); + writer.WriteObjectValue(Components, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InstanceProperties 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(InstanceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInstanceProperties(document.RootElement, options); + } + + internal static InstanceProperties DeserializeInstanceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + ProvisioningState? provisioningState = default; + string version = default; + string schemaRegistryNamespace = default; + Components components = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("description"u8)) + { + description = 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("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("schemaRegistryNamespace"u8)) + { + schemaRegistryNamespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("components"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + components = Components.DeserializeComponents(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InstanceProperties( + description, + provisioningState, + version, + schemaRegistryNamespace, + components, + 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); + default: + throw new FormatException($"The model {nameof(InstanceProperties)} does not support writing '{options.Format}' format."); + } + } + + InstanceProperties 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); + return DeserializeInstanceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InstanceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceProperties.cs new file mode 100644 index 000000000000..c11db2126aa5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceProperties.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// The properties of the Instance resource. + public partial class InstanceProperties + { + /// + /// 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 reference to the Schema Registry for this AIO Instance. + /// is null. + public InstanceProperties(string schemaRegistryNamespace) + { + Argument.AssertNotNull(schemaRegistryNamespace, nameof(schemaRegistryNamespace)); + + SchemaRegistryNamespace = schemaRegistryNamespace; + } + + /// Initializes a new instance of . + /// Detailed description of the Instance. + /// The status of the last operation. + /// The Azure IoT Operations version. + /// The reference to the Schema Registry for this AIO Instance. + /// The configuration for components of the AIO Instance. + /// Keeps track of any properties unknown to the library. + internal InstanceProperties(string description, ProvisioningState? provisioningState, string version, string schemaRegistryNamespace, Components components, IDictionary serializedAdditionalRawData) + { + Description = description; + ProvisioningState = provisioningState; + Version = version; + SchemaRegistryNamespace = schemaRegistryNamespace; + Components = components; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InstanceProperties() + { + } + + /// Detailed description of the Instance. + public string Description { get; set; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + /// The Azure IoT Operations version. + public string Version { get; } + /// The reference to the Schema Registry for this AIO Instance. + public string SchemaRegistryNamespace { get; set; } + /// The configuration for components of the AIO Instance. + public Components Components { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourceListResult.Serialization.cs new file mode 100644 index 000000000000..9e23e4b7647b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourceListResult.Serialization.cs @@ -0,0 +1,144 @@ +// 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.IoTOperations.Models +{ + internal partial class InstanceResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InstanceResourceListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InstanceResourceListResult 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(InstanceResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInstanceResourceListResult(document.RootElement, options); + } + + internal static InstanceResourceListResult DeserializeInstanceResourceListResult(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(InstanceResourceData.DeserializeInstanceResourceData(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 InstanceResourceListResult(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); + default: + throw new FormatException($"The model {nameof(InstanceResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + InstanceResourceListResult 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); + return DeserializeInstanceResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InstanceResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourceListResult.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourceListResult.cs new file mode 100644 index 000000000000..80ca98065f8d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourceListResult.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.IoTOperations.Models +{ + /// The response of a InstanceResource list operation. + internal partial class InstanceResourceListResult + { + /// + /// 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 InstanceResource items on this page. + /// is null. + internal InstanceResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The InstanceResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal InstanceResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InstanceResourceListResult() + { + } + + /// The InstanceResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourcePatch.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourcePatch.Serialization.cs new file mode 100644 index 000000000000..e4611a431a6b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourcePatch.Serialization.cs @@ -0,0 +1,155 @@ +// 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; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + public partial class InstanceResourcePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InstanceResourcePatch)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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); + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + JsonSerializer.Serialize(writer, Identity, serializeOptions); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InstanceResourcePatch 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(InstanceResourcePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInstanceResourcePatch(document.RootElement, options); + } + + internal static InstanceResourcePatch DeserializeInstanceResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + ManagedServiceIdentity identity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + 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; + } + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InstanceResourcePatch(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); + default: + throw new FormatException($"The model {nameof(InstanceResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + InstanceResourcePatch 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); + return DeserializeInstanceResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InstanceResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourcePatch.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourcePatch.cs new file mode 100644 index 000000000000..ce3bcb938c2c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/InstanceResourcePatch.cs @@ -0,0 +1,71 @@ +// 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.IoTOperations.Models +{ + /// The Instance update model. + public partial class InstanceResourcePatch + { + /// + /// 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 InstanceResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Resource tags. + /// The managed service identities assigned to this resource. + /// Keeps track of any properties unknown to the library. + internal InstanceResourcePatch(IDictionary tags, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) + { + Tags = tags; + Identity = identity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource tags. + public IDictionary Tags { get; } + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KafkaAuthMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KafkaAuthMethod.cs new file mode 100644 index 000000000000..e0ca84ddd67d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KafkaAuthMethod.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.IoTOperations.Models +{ + /// DataflowEndpoint Kafka Authentication Method properties. + public readonly partial struct KafkaAuthMethod : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public KafkaAuthMethod(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SystemAssignedManagedIdentityValue = "SystemAssignedManagedIdentity"; + private const string UserAssignedManagedIdentityValue = "UserAssignedManagedIdentity"; + private const string SaslValue = "Sasl"; + private const string X509CertificateValue = "X509Certificate"; + private const string AnonymousValue = "Anonymous"; + + /// SystemAssignedManagedIdentity type. + public static KafkaAuthMethod SystemAssignedManagedIdentity { get; } = new KafkaAuthMethod(SystemAssignedManagedIdentityValue); + /// UserAssignedManagedIdentity type. + public static KafkaAuthMethod UserAssignedManagedIdentity { get; } = new KafkaAuthMethod(UserAssignedManagedIdentityValue); + /// Sasl Option. + public static KafkaAuthMethod Sasl { get; } = new KafkaAuthMethod(SaslValue); + /// x509Certificate Option. + public static KafkaAuthMethod X509Certificate { get; } = new KafkaAuthMethod(X509CertificateValue); + /// Anonymous Option. + public static KafkaAuthMethod Anonymous { get; } = new KafkaAuthMethod(AnonymousValue); + /// Determines if two values are the same. + public static bool operator ==(KafkaAuthMethod left, KafkaAuthMethod right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(KafkaAuthMethod left, KafkaAuthMethod right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator KafkaAuthMethod(string value) => new KafkaAuthMethod(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is KafkaAuthMethod other && Equals(other); + /// + public bool Equals(KafkaAuthMethod 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KubernetesReference.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KubernetesReference.Serialization.cs new file mode 100644 index 000000000000..c053596b75e7 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KubernetesReference.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.IoTOperations.Models +{ + public partial class KubernetesReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KubernetesReference)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ApiGroup)) + { + writer.WritePropertyName("apiGroup"u8); + writer.WriteStringValue(ApiGroup); + } + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Namespace)) + { + writer.WritePropertyName("namespace"u8); + writer.WriteStringValue(Namespace); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + KubernetesReference 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(KubernetesReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKubernetesReference(document.RootElement, options); + } + + internal static KubernetesReference DeserializeKubernetesReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string apiGroup = default; + string kind = default; + string name = default; + string @namespace = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("apiGroup"u8)) + { + apiGroup = property.Value.GetString(); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("namespace"u8)) + { + @namespace = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KubernetesReference(apiGroup, kind, name, @namespace, 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); + default: + throw new FormatException($"The model {nameof(KubernetesReference)} does not support writing '{options.Format}' format."); + } + } + + KubernetesReference 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); + return DeserializeKubernetesReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KubernetesReference)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KubernetesReference.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KubernetesReference.cs new file mode 100644 index 000000000000..140fb09dc889 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/KubernetesReference.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Kubernetes reference. + public partial class KubernetesReference + { + /// + /// 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 . + /// Kind is the type of resource being referenced. + /// Name is the name of resource being referenced. + /// or is null. + public KubernetesReference(string kind, string name) + { + Argument.AssertNotNull(kind, nameof(kind)); + Argument.AssertNotNull(name, nameof(name)); + + Kind = kind; + Name = name; + } + + /// Initializes a new instance of . + /// APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. + /// Kind is the type of resource being referenced. + /// Name is the name of resource being referenced. + /// Namespace is the namespace of the resource being referenced. This field is required when the resource has a namespace. + /// Keeps track of any properties unknown to the library. + internal KubernetesReference(string apiGroup, string kind, string name, string @namespace, IDictionary serializedAdditionalRawData) + { + ApiGroup = apiGroup; + Kind = kind; + Name = name; + Namespace = @namespace; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KubernetesReference() + { + } + + /// APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. + public string ApiGroup { get; set; } + /// Kind is the type of resource being referenced. + public string Kind { get; set; } + /// Name is the name of resource being referenced. + public string Name { get; set; } + /// Namespace is the namespace of the resource being referenced. This field is required when the resource has a namespace. + public string Namespace { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ListenerPort.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ListenerPort.Serialization.cs new file mode 100644 index 000000000000..8d6f6294c96e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ListenerPort.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.IoTOperations.Models +{ + public partial class ListenerPort : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ListenerPort)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(AuthenticationRef)) + { + writer.WritePropertyName("authenticationRef"u8); + writer.WriteStringValue(AuthenticationRef); + } + if (Optional.IsDefined(AuthorizationRef)) + { + writer.WritePropertyName("authorizationRef"u8); + writer.WriteStringValue(AuthorizationRef); + } + if (Optional.IsDefined(NodePort)) + { + writer.WritePropertyName("nodePort"u8); + writer.WriteNumberValue(NodePort.Value); + } + writer.WritePropertyName("port"u8); + writer.WriteNumberValue(Port); + if (Optional.IsDefined(Protocol)) + { + writer.WritePropertyName("protocol"u8); + writer.WriteStringValue(Protocol.Value.ToString()); + } + if (Optional.IsDefined(Tls)) + { + writer.WritePropertyName("tls"u8); + writer.WriteObjectValue(Tls, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ListenerPort 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(ListenerPort)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeListenerPort(document.RootElement, options); + } + + internal static ListenerPort DeserializeListenerPort(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string authenticationRef = default; + string authorizationRef = default; + int? nodePort = default; + int port = default; + BrokerProtocolType? protocol = default; + TlsCertMethod tls = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("authenticationRef"u8)) + { + authenticationRef = property.Value.GetString(); + continue; + } + if (property.NameEquals("authorizationRef"u8)) + { + authorizationRef = property.Value.GetString(); + continue; + } + if (property.NameEquals("nodePort"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nodePort = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("port"u8)) + { + port = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("protocol"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + protocol = new BrokerProtocolType(property.Value.GetString()); + continue; + } + if (property.NameEquals("tls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + tls = TlsCertMethod.DeserializeTlsCertMethod(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ListenerPort( + authenticationRef, + authorizationRef, + nodePort, + port, + protocol, + tls, + 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); + default: + throw new FormatException($"The model {nameof(ListenerPort)} does not support writing '{options.Format}' format."); + } + } + + ListenerPort 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); + return DeserializeListenerPort(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListenerPort)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ListenerPort.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ListenerPort.cs new file mode 100644 index 000000000000..b43259c8b99e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ListenerPort.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Defines a TCP port on which a `BrokerListener` listens. + public partial class ListenerPort + { + /// + /// 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 . + /// TCP port for accepting client connections. + public ListenerPort(int port) + { + Port = port; + } + + /// Initializes a new instance of . + /// Reference to client authentication settings. Omit to disable authentication. + /// Reference to client authorization settings. Omit to disable authorization. + /// Kubernetes node port. Only relevant when this port is associated with a `NodePort` listener. + /// TCP port for accepting client connections. + /// Protocol to use for client connections. + /// TLS server certificate settings for this port. Omit to disable TLS. + /// Keeps track of any properties unknown to the library. + internal ListenerPort(string authenticationRef, string authorizationRef, int? nodePort, int port, BrokerProtocolType? protocol, TlsCertMethod tls, IDictionary serializedAdditionalRawData) + { + AuthenticationRef = authenticationRef; + AuthorizationRef = authorizationRef; + NodePort = nodePort; + Port = port; + Protocol = protocol; + Tls = tls; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ListenerPort() + { + } + + /// Reference to client authentication settings. Omit to disable authentication. + public string AuthenticationRef { get; set; } + /// Reference to client authorization settings. Omit to disable authorization. + public string AuthorizationRef { get; set; } + /// Kubernetes node port. Only relevant when this port is associated with a `NodePort` listener. + public int? NodePort { get; set; } + /// TCP port for accepting client connections. + public int Port { get; set; } + /// Protocol to use for client connections. + public BrokerProtocolType? Protocol { get; set; } + /// TLS server certificate settings for this port. Omit to disable TLS. + public TlsCertMethod Tls { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/LocalKubernetesReference.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/LocalKubernetesReference.Serialization.cs new file mode 100644 index 000000000000..3202cf1f37f5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/LocalKubernetesReference.Serialization.cs @@ -0,0 +1,138 @@ +// 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.IoTOperations.Models +{ + public partial class LocalKubernetesReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocalKubernetesReference)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ApiGroup)) + { + writer.WritePropertyName("apiGroup"u8); + writer.WriteStringValue(ApiGroup); + } + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + LocalKubernetesReference 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(LocalKubernetesReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocalKubernetesReference(document.RootElement, options); + } + + internal static LocalKubernetesReference DeserializeLocalKubernetesReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string apiGroup = default; + string kind = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("apiGroup"u8)) + { + apiGroup = property.Value.GetString(); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LocalKubernetesReference(apiGroup, kind, name, 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); + default: + throw new FormatException($"The model {nameof(LocalKubernetesReference)} does not support writing '{options.Format}' format."); + } + } + + LocalKubernetesReference 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); + return DeserializeLocalKubernetesReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocalKubernetesReference)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/LocalKubernetesReference.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/LocalKubernetesReference.cs new file mode 100644 index 000000000000..67e3e6a6b33a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/LocalKubernetesReference.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Kubernetes reference. + public partial class LocalKubernetesReference + { + /// + /// 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 . + /// Kind is the type of resource being referenced. + /// Name is the name of resource being referenced. + /// or is null. + public LocalKubernetesReference(string kind, string name) + { + Argument.AssertNotNull(kind, nameof(kind)); + Argument.AssertNotNull(name, nameof(name)); + + Kind = kind; + Name = name; + } + + /// Initializes a new instance of . + /// APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. + /// Kind is the type of resource being referenced. + /// Name is the name of resource being referenced. + /// Keeps track of any properties unknown to the library. + internal LocalKubernetesReference(string apiGroup, string kind, string name, IDictionary serializedAdditionalRawData) + { + ApiGroup = apiGroup; + Kind = kind; + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal LocalKubernetesReference() + { + } + + /// APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. + public string ApiGroup { get; set; } + /// Kind is the type of resource being referenced. + public string Kind { get; set; } + /// Name is the name of resource being referenced. + public string Name { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Metrics.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Metrics.Serialization.cs new file mode 100644 index 000000000000..78b7a65d6804 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Metrics.Serialization.cs @@ -0,0 +1,141 @@ +// 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.IoTOperations.Models +{ + public partial class Metrics : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Metrics)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(OpentelemetryExportConfig)) + { + writer.WritePropertyName("opentelemetryExportConfig"u8); + writer.WriteObjectValue(OpentelemetryExportConfig, options); + } + if (Optional.IsDefined(PrometheusPort)) + { + writer.WritePropertyName("prometheusPort"u8); + writer.WriteNumberValue(PrometheusPort.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Metrics 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(Metrics)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetrics(document.RootElement, options); + } + + internal static Metrics DeserializeMetrics(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenTelemetryExportConfig opentelemetryExportConfig = default; + int? prometheusPort = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("opentelemetryExportConfig"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + opentelemetryExportConfig = OpenTelemetryExportConfig.DeserializeOpenTelemetryExportConfig(property.Value, options); + continue; + } + if (property.NameEquals("prometheusPort"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + prometheusPort = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Metrics(opentelemetryExportConfig, prometheusPort, 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); + default: + throw new FormatException($"The model {nameof(Metrics)} does not support writing '{options.Format}' format."); + } + } + + Metrics 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); + return DeserializeMetrics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Metrics)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Metrics.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Metrics.cs new file mode 100644 index 000000000000..748363b6a7c4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Metrics.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.IoTOperations.Models +{ + /// Diagnostic Metrics properties. + public partial class Metrics + { + /// + /// 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 Metrics() + { + } + + /// Initializes a new instance of . + /// The open telemetry export configuration. + /// The prometheus port to expose the metrics. + /// Keeps track of any properties unknown to the library. + internal Metrics(OpenTelemetryExportConfig opentelemetryExportConfig, int? prometheusPort, IDictionary serializedAdditionalRawData) + { + OpentelemetryExportConfig = opentelemetryExportConfig; + PrometheusPort = prometheusPort; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The open telemetry export configuration. + public OpenTelemetryExportConfig OpentelemetryExportConfig { get; set; } + /// The prometheus port to expose the metrics. + public int? PrometheusPort { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/MqttAuthMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/MqttAuthMethod.cs new file mode 100644 index 000000000000..01ab16d9c220 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/MqttAuthMethod.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.IoTOperations.Models +{ + /// DataflowEndpoint Mqtt Authentication Method properties. + public readonly partial struct MqttAuthMethod : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MqttAuthMethod(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SystemAssignedManagedIdentityValue = "SystemAssignedManagedIdentity"; + private const string UserAssignedManagedIdentityValue = "UserAssignedManagedIdentity"; + private const string ServiceAccountTokenValue = "ServiceAccountToken"; + private const string X509CertificateValue = "X509Certificate"; + private const string AnonymousValue = "Anonymous"; + + /// SystemAssignedManagedIdentity type. + public static MqttAuthMethod SystemAssignedManagedIdentity { get; } = new MqttAuthMethod(SystemAssignedManagedIdentityValue); + /// UserAssignedManagedIdentity type. + public static MqttAuthMethod UserAssignedManagedIdentity { get; } = new MqttAuthMethod(UserAssignedManagedIdentityValue); + /// ServiceAccountToken Option. + public static MqttAuthMethod ServiceAccountToken { get; } = new MqttAuthMethod(ServiceAccountTokenValue); + /// x509Certificate Option. + public static MqttAuthMethod X509Certificate { get; } = new MqttAuthMethod(X509CertificateValue); + /// Anonymous Option. + public static MqttAuthMethod Anonymous { get; } = new MqttAuthMethod(AnonymousValue); + /// Determines if two values are the same. + public static bool operator ==(MqttAuthMethod left, MqttAuthMethod right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MqttAuthMethod left, MqttAuthMethod right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MqttAuthMethod(string value) => new MqttAuthMethod(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MqttAuthMethod other && Equals(other); + /// + public bool Equals(MqttAuthMethod 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/MqttRetainType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/MqttRetainType.cs new file mode 100644 index 000000000000..f89c640336ab --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/MqttRetainType.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.IoTOperations.Models +{ + /// Broker Retain types. + public readonly partial struct MqttRetainType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MqttRetainType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string KeepValue = "Keep"; + private const string NeverValue = "Never"; + + /// Retain the messages. + public static MqttRetainType Keep { get; } = new MqttRetainType(KeepValue); + /// Never retain messages. + public static MqttRetainType Never { get; } = new MqttRetainType(NeverValue); + /// Determines if two values are the same. + public static bool operator ==(MqttRetainType left, MqttRetainType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MqttRetainType left, MqttRetainType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MqttRetainType(string value) => new MqttRetainType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MqttRetainType other && Equals(other); + /// + public bool Equals(MqttRetainType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryExportConfig.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryExportConfig.Serialization.cs new file mode 100644 index 000000000000..0724905e1be9 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryExportConfig.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.IoTOperations.Models +{ + public partial class OpenTelemetryExportConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenTelemetryExportConfig)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("otlpGrpcEndpoint"u8); + writer.WriteStringValue(OtlpGrpcEndpoint); + if (Optional.IsDefined(IntervalSeconds)) + { + writer.WritePropertyName("intervalSeconds"u8); + writer.WriteNumberValue(IntervalSeconds.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OpenTelemetryExportConfig 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(OpenTelemetryExportConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenTelemetryExportConfig(document.RootElement, options); + } + + internal static OpenTelemetryExportConfig DeserializeOpenTelemetryExportConfig(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string otlpGrpcEndpoint = default; + int? intervalSeconds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("otlpGrpcEndpoint"u8)) + { + otlpGrpcEndpoint = property.Value.GetString(); + continue; + } + if (property.NameEquals("intervalSeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + intervalSeconds = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenTelemetryExportConfig(otlpGrpcEndpoint, intervalSeconds, 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); + default: + throw new FormatException($"The model {nameof(OpenTelemetryExportConfig)} does not support writing '{options.Format}' format."); + } + } + + OpenTelemetryExportConfig 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); + return DeserializeOpenTelemetryExportConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenTelemetryExportConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryExportConfig.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryExportConfig.cs new file mode 100644 index 000000000000..a65828210647 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryExportConfig.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// OpenTelemetry Export Configuration properties. + public partial class OpenTelemetryExportConfig + { + /// + /// 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 open telemetry collector endpoint to export to. + /// is null. + public OpenTelemetryExportConfig(string otlpGrpcEndpoint) + { + Argument.AssertNotNull(otlpGrpcEndpoint, nameof(otlpGrpcEndpoint)); + + OtlpGrpcEndpoint = otlpGrpcEndpoint; + } + + /// Initializes a new instance of . + /// The open telemetry collector endpoint to export to. + /// How often to export the metrics to the open telemetry collector. + /// Keeps track of any properties unknown to the library. + internal OpenTelemetryExportConfig(string otlpGrpcEndpoint, int? intervalSeconds, IDictionary serializedAdditionalRawData) + { + OtlpGrpcEndpoint = otlpGrpcEndpoint; + IntervalSeconds = intervalSeconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenTelemetryExportConfig() + { + } + + /// The open telemetry collector endpoint to export to. + public string OtlpGrpcEndpoint { get; set; } + /// How often to export the metrics to the open telemetry collector. + public int? IntervalSeconds { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryLogExportConfig.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryLogExportConfig.Serialization.cs new file mode 100644 index 000000000000..bcd38fc40ea5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryLogExportConfig.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.IoTOperations.Models +{ + public partial class OpenTelemetryLogExportConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenTelemetryLogExportConfig)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("otlpGrpcEndpoint"u8); + writer.WriteStringValue(OtlpGrpcEndpoint); + if (Optional.IsDefined(IntervalSeconds)) + { + writer.WritePropertyName("intervalSeconds"u8); + writer.WriteNumberValue(IntervalSeconds.Value); + } + if (Optional.IsDefined(Level)) + { + writer.WritePropertyName("level"u8); + writer.WriteStringValue(Level); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OpenTelemetryLogExportConfig 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(OpenTelemetryLogExportConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenTelemetryLogExportConfig(document.RootElement, options); + } + + internal static OpenTelemetryLogExportConfig DeserializeOpenTelemetryLogExportConfig(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string otlpGrpcEndpoint = default; + int? intervalSeconds = default; + string level = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("otlpGrpcEndpoint"u8)) + { + otlpGrpcEndpoint = property.Value.GetString(); + continue; + } + if (property.NameEquals("intervalSeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + intervalSeconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("level"u8)) + { + level = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenTelemetryLogExportConfig(otlpGrpcEndpoint, intervalSeconds, level, 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); + default: + throw new FormatException($"The model {nameof(OpenTelemetryLogExportConfig)} does not support writing '{options.Format}' format."); + } + } + + OpenTelemetryLogExportConfig 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); + return DeserializeOpenTelemetryLogExportConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenTelemetryLogExportConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryLogExportConfig.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryLogExportConfig.cs new file mode 100644 index 000000000000..c188c3697f5f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OpenTelemetryLogExportConfig.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// OpenTelemetry Log Export Configuration properties. + public partial class OpenTelemetryLogExportConfig + { + /// + /// 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 open telemetry collector endpoint to export to. + /// is null. + public OpenTelemetryLogExportConfig(string otlpGrpcEndpoint) + { + Argument.AssertNotNull(otlpGrpcEndpoint, nameof(otlpGrpcEndpoint)); + + OtlpGrpcEndpoint = otlpGrpcEndpoint; + } + + /// Initializes a new instance of . + /// The open telemetry collector endpoint to export to. + /// How often to export the metrics to the open telemetry collector. + /// The log level. Examples - 'debug', 'info', 'warn', 'error', 'trace'. + /// Keeps track of any properties unknown to the library. + internal OpenTelemetryLogExportConfig(string otlpGrpcEndpoint, int? intervalSeconds, string level, IDictionary serializedAdditionalRawData) + { + OtlpGrpcEndpoint = otlpGrpcEndpoint; + IntervalSeconds = intervalSeconds; + Level = level; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenTelemetryLogExportConfig() + { + } + + /// The open telemetry collector endpoint to export to. + public string OtlpGrpcEndpoint { get; set; } + /// How often to export the metrics to the open telemetry collector. + public int? IntervalSeconds { get; set; } + /// The log level. Examples - 'debug', 'info', 'warn', 'error', 'trace'. + public string Level { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Operation.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Operation.Serialization.cs new file mode 100644 index 000000000000..58854e064ec6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Operation.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.IoTOperations.Models +{ + public partial class Operation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Operation)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(IsDataAction)) + { + writer.WritePropertyName("isDataAction"u8); + writer.WriteBooleanValue(IsDataAction.Value); + } + if (options.Format != "W" && Optional.IsDefined(Display)) + { + writer.WritePropertyName("display"u8); + writer.WriteObjectValue(Display, options); + } + if (options.Format != "W" && Optional.IsDefined(Origin)) + { + writer.WritePropertyName("origin"u8); + writer.WriteStringValue(Origin.Value.ToString()); + } + if (Optional.IsDefined(ActionType)) + { + writer.WritePropertyName("actionType"u8); + writer.WriteStringValue(ActionType.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Operation 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(Operation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperation(document.RootElement, options); + } + + internal static Operation DeserializeOperation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + bool? isDataAction = default; + OperationDisplay display = default; + Origin? origin = default; + ActionType? actionType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("isDataAction"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isDataAction = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("display"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + display = OperationDisplay.DeserializeOperationDisplay(property.Value, options); + continue; + } + if (property.NameEquals("origin"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + origin = new Origin(property.Value.GetString()); + continue; + } + if (property.NameEquals("actionType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + actionType = new ActionType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Operation( + name, + isDataAction, + display, + origin, + actionType, + 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); + default: + throw new FormatException($"The model {nameof(Operation)} does not support writing '{options.Format}' format."); + } + } + + Operation 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); + return DeserializeOperation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Operation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Operation.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Operation.cs new file mode 100644 index 000000000000..40e605b28f11 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Operation.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.IoTOperations.Models +{ + /// Details of a REST API operation, returned from the Resource Provider Operations API. + public partial class Operation + { + /// + /// 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 Operation() + { + } + + /// Initializes a new instance of . + /// The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + /// Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. + /// Localized display information for this particular operation. + /// The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". + /// Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + /// Keeps track of any properties unknown to the library. + internal Operation(string name, bool? isDataAction, OperationDisplay display, Origin? origin, ActionType? actionType, IDictionary serializedAdditionalRawData) + { + Name = name; + IsDataAction = isDataAction; + Display = display; + Origin = origin; + ActionType = actionType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + public string Name { get; } + /// Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. + public bool? IsDataAction { get; } + /// Localized display information for this particular operation. + public OperationDisplay Display { get; } + /// The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". + public Origin? Origin { get; } + /// Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + public ActionType? ActionType { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationDisplay.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationDisplay.Serialization.cs new file mode 100644 index 000000000000..34fc81a2813f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationDisplay.Serialization.cs @@ -0,0 +1,155 @@ +// 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.IoTOperations.Models +{ + public partial class OperationDisplay : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationDisplay)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Provider)) + { + writer.WritePropertyName("provider"u8); + writer.WriteStringValue(Provider); + } + if (options.Format != "W" && Optional.IsDefined(Resource)) + { + writer.WritePropertyName("resource"u8); + writer.WriteStringValue(Resource); + } + if (options.Format != "W" && Optional.IsDefined(Operation)) + { + writer.WritePropertyName("operation"u8); + writer.WriteStringValue(Operation); + } + if (options.Format != "W" && Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OperationDisplay 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(OperationDisplay)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationDisplay(document.RootElement, options); + } + + internal static OperationDisplay DeserializeOperationDisplay(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string provider = default; + string resource = default; + string operation = default; + string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provider"u8)) + { + provider = property.Value.GetString(); + continue; + } + if (property.NameEquals("resource"u8)) + { + resource = property.Value.GetString(); + continue; + } + if (property.NameEquals("operation"u8)) + { + operation = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OperationDisplay(provider, resource, operation, description, 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); + default: + throw new FormatException($"The model {nameof(OperationDisplay)} does not support writing '{options.Format}' format."); + } + } + + OperationDisplay 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); + return DeserializeOperationDisplay(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationDisplay)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationDisplay.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..71194db7b301 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationDisplay.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.IoTOperations.Models +{ + /// Localized display information for and operation. + public partial class OperationDisplay + { + /// + /// 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 OperationDisplay() + { + } + + /// Initializes a new instance of . + /// The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + /// The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + /// The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + /// The short, localized friendly description of the operation; suitable for tool tips and detailed views. + /// Keeps track of any properties unknown to the library. + internal OperationDisplay(string provider, string resource, string operation, string description, IDictionary serializedAdditionalRawData) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + public string Provider { get; } + /// The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + public string Resource { get; } + /// The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + public string Operation { get; } + /// The short, localized friendly description of the operation; suitable for tool tips and detailed views. + public string Description { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationListResult.Serialization.cs new file mode 100644 index 000000000000..3947e7e24427 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationListResult.Serialization.cs @@ -0,0 +1,144 @@ +// 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.IoTOperations.Models +{ + internal partial class OperationListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OperationListResult 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(OperationListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationListResult(document.RootElement, options); + } + + internal static OperationListResult DeserializeOperationListResult(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(Operation.DeserializeOperation(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 OperationListResult(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); + default: + throw new FormatException($"The model {nameof(OperationListResult)} does not support writing '{options.Format}' format."); + } + } + + OperationListResult 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); + return DeserializeOperationListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationListResult.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationListResult.cs new file mode 100644 index 000000000000..245ac681d629 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationListResult.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.IoTOperations.Models +{ + /// A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + internal partial class OperationListResult + { + /// + /// 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 Operation items on this page. + /// is null. + internal OperationListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Operation items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal OperationListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OperationListResult() + { + } + + /// The Operation items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationType.cs new file mode 100644 index 000000000000..91466a89cf1a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationType.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.IoTOperations.Models +{ + /// Dataflow Operation Type properties. + public readonly partial struct OperationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OperationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SourceValue = "Source"; + private const string DestinationValue = "Destination"; + private const string BuiltInTransformationValue = "BuiltInTransformation"; + + /// Dataflow Source Operation. + public static OperationType Source { get; } = new OperationType(SourceValue); + /// Dataflow Destination Operation. + public static OperationType Destination { get; } = new OperationType(DestinationValue); + /// Dataflow BuiltIn Transformation Operation. + public static OperationType BuiltInTransformation { get; } = new OperationType(BuiltInTransformationValue); + /// Determines if two values are the same. + public static bool operator ==(OperationType left, OperationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OperationType left, OperationType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OperationType(string value) => new OperationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OperationType other && Equals(other); + /// + public bool Equals(OperationType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationalMode.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationalMode.cs new file mode 100644 index 000000000000..f137936c4316 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperationalMode.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.IoTOperations.Models +{ + /// Mode properties. + public readonly partial struct OperationalMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OperationalMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EnabledValue = "Enabled"; + private const string DisabledValue = "Disabled"; + + /// Enabled is equivalent to True. + public static OperationalMode Enabled { get; } = new OperationalMode(EnabledValue); + /// Disabled is equivalent to False. + public static OperationalMode Disabled { get; } = new OperationalMode(DisabledValue); + /// Determines if two values are the same. + public static bool operator ==(OperationalMode left, OperationalMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OperationalMode left, OperationalMode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OperationalMode(string value) => new OperationalMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OperationalMode other && Equals(other); + /// + public bool Equals(OperationalMode 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperatorValue.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperatorValue.cs new file mode 100644 index 000000000000..a197bb727d47 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/OperatorValue.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.IoTOperations.Models +{ + /// Valid operators are In, NotIn, Exists and DoesNotExist. + public readonly partial struct OperatorValue : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OperatorValue(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InValue = "In"; + private const string NotInValue = "NotIn"; + private const string ExistsValue = "Exists"; + private const string DoesNotExistValue = "DoesNotExist"; + + /// In operator. + public static OperatorValue In { get; } = new OperatorValue(InValue); + /// NotIn operator. + public static OperatorValue NotIn { get; } = new OperatorValue(NotInValue); + /// Exists operator. + public static OperatorValue Exists { get; } = new OperatorValue(ExistsValue); + /// DoesNotExist operator. + public static OperatorValue DoesNotExist { get; } = new OperatorValue(DoesNotExistValue); + /// Determines if two values are the same. + public static bool operator ==(OperatorValue left, OperatorValue right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OperatorValue left, OperatorValue right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OperatorValue(string value) => new OperatorValue(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OperatorValue other && Equals(other); + /// + public bool Equals(OperatorValue 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Origin.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Origin.cs new file mode 100644 index 000000000000..f5b24eee763c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Origin.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.IoTOperations.Models +{ + /// The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". + public readonly partial struct Origin : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public Origin(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UserValue = "user"; + private const string SystemValue = "system"; + private const string UserSystemValue = "user,system"; + + /// Indicates the operation is initiated by a user. + public static Origin User { get; } = new Origin(UserValue); + /// Indicates the operation is initiated by a system. + public static Origin System { get; } = new Origin(SystemValue); + /// Indicates the operation is initiated by a user or system. + public static Origin UserSystem { get; } = new Origin(UserSystemValue); + /// Determines if two values are the same. + public static bool operator ==(Origin left, Origin right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Origin left, Origin right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator Origin(string value) => new Origin(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Origin other && Equals(other); + /// + public bool Equals(Origin 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrincipalDefinition.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrincipalDefinition.Serialization.cs new file mode 100644 index 000000000000..75d1c019eba5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrincipalDefinition.Serialization.cs @@ -0,0 +1,209 @@ +// 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.IoTOperations.Models +{ + public partial class PrincipalDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PrincipalDefinition)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Attributes)) + { + writer.WritePropertyName("attributes"u8); + writer.WriteStartArray(); + foreach (var item in Attributes) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartObject(); + foreach (var item0 in item) + { + writer.WritePropertyName(item0.Key); + writer.WriteStringValue(item0.Value); + } + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ClientIds)) + { + writer.WritePropertyName("clientIds"u8); + writer.WriteStartArray(); + foreach (var item in ClientIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Usernames)) + { + writer.WritePropertyName("usernames"u8); + writer.WriteStartArray(); + foreach (var item in Usernames) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + PrincipalDefinition 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(PrincipalDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrincipalDefinition(document.RootElement, options); + } + + internal static PrincipalDefinition DeserializePrincipalDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList> attributes = default; + IList clientIds = default; + IList usernames = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("attributes"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 + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in item.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + array.Add(dictionary); + } + } + attributes = array; + continue; + } + if (property.NameEquals("clientIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + clientIds = array; + continue; + } + if (property.NameEquals("usernames"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + usernames = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PrincipalDefinition(attributes ?? new ChangeTrackingList>(), clientIds ?? new ChangeTrackingList(), usernames ?? 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); + default: + throw new FormatException($"The model {nameof(PrincipalDefinition)} does not support writing '{options.Format}' format."); + } + } + + PrincipalDefinition 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); + return DeserializePrincipalDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PrincipalDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrincipalDefinition.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrincipalDefinition.cs new file mode 100644 index 000000000000..ce94d2071a3f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrincipalDefinition.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// PrincipalDefinition properties of Rule. + public partial class PrincipalDefinition + { + /// + /// 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 PrincipalDefinition() + { + Attributes = new ChangeTrackingList>(); + ClientIds = new ChangeTrackingList(); + Usernames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// A list of key-value pairs that match the attributes of the clients. The attributes are case-sensitive and must match the attributes provided by the clients during authentication. + /// A list of client IDs that match the clients. The client IDs are case-sensitive and must match the client IDs provided by the clients during connection. + /// A list of usernames that match the clients. The usernames are case-sensitive and must match the usernames provided by the clients during authentication. + /// Keeps track of any properties unknown to the library. + internal PrincipalDefinition(IList> attributes, IList clientIds, IList usernames, IDictionary serializedAdditionalRawData) + { + Attributes = attributes; + ClientIds = clientIds; + Usernames = usernames; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A list of key-value pairs that match the attributes of the clients. The attributes are case-sensitive and must match the attributes provided by the clients during authentication. + public IList> Attributes { get; } + /// A list of client IDs that match the clients. The client IDs are case-sensitive and must match the client IDs provided by the clients during connection. + public IList ClientIds { get; } + /// A list of usernames that match the clients. The usernames are case-sensitive and must match the usernames provided by the clients during authentication. + public IList Usernames { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrivateKeyAlgorithm.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrivateKeyAlgorithm.cs new file mode 100644 index 000000000000..55e395c53935 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrivateKeyAlgorithm.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.IoTOperations.Models +{ + /// Private key algorithm types. + public readonly partial struct PrivateKeyAlgorithm : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PrivateKeyAlgorithm(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string Ec256Value = "Ec256"; + private const string Ec384Value = "Ec384"; + private const string Ec521Value = "Ec521"; + private const string Ed25519Value = "Ed25519"; + private const string Rsa2048Value = "Rsa2048"; + private const string Rsa4096Value = "Rsa4096"; + private const string Rsa8192Value = "Rsa8192"; + + /// Algorithm - ec256. + public static PrivateKeyAlgorithm Ec256 { get; } = new PrivateKeyAlgorithm(Ec256Value); + /// Algorithm - ec384. + public static PrivateKeyAlgorithm Ec384 { get; } = new PrivateKeyAlgorithm(Ec384Value); + /// Algorithm - ec521. + public static PrivateKeyAlgorithm Ec521 { get; } = new PrivateKeyAlgorithm(Ec521Value); + /// Algorithm - ed25519. + public static PrivateKeyAlgorithm Ed25519 { get; } = new PrivateKeyAlgorithm(Ed25519Value); + /// Algorithm - rsa2048. + public static PrivateKeyAlgorithm Rsa2048 { get; } = new PrivateKeyAlgorithm(Rsa2048Value); + /// Algorithm - rsa4096. + public static PrivateKeyAlgorithm Rsa4096 { get; } = new PrivateKeyAlgorithm(Rsa4096Value); + /// Algorithm - rsa8192. + public static PrivateKeyAlgorithm Rsa8192 { get; } = new PrivateKeyAlgorithm(Rsa8192Value); + /// Determines if two values are the same. + public static bool operator ==(PrivateKeyAlgorithm left, PrivateKeyAlgorithm right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PrivateKeyAlgorithm left, PrivateKeyAlgorithm right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator PrivateKeyAlgorithm(string value) => new PrivateKeyAlgorithm(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PrivateKeyAlgorithm other && Equals(other); + /// + public bool Equals(PrivateKeyAlgorithm 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrivateKeyRotationPolicy.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrivateKeyRotationPolicy.cs new file mode 100644 index 000000000000..42c0e0a31f73 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/PrivateKeyRotationPolicy.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.IoTOperations.Models +{ + /// Private key rotation policy. + public readonly partial struct PrivateKeyRotationPolicy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PrivateKeyRotationPolicy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AlwaysValue = "Always"; + private const string NeverValue = "Never"; + + /// Rotation Policy - Always. + public static PrivateKeyRotationPolicy Always { get; } = new PrivateKeyRotationPolicy(AlwaysValue); + /// Rotation Policy - Never. + public static PrivateKeyRotationPolicy Never { get; } = new PrivateKeyRotationPolicy(NeverValue); + /// Determines if two values are the same. + public static bool operator ==(PrivateKeyRotationPolicy left, PrivateKeyRotationPolicy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PrivateKeyRotationPolicy left, PrivateKeyRotationPolicy right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator PrivateKeyRotationPolicy(string value) => new PrivateKeyRotationPolicy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PrivateKeyRotationPolicy other && Equals(other); + /// + public bool Equals(PrivateKeyRotationPolicy 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProfileDiagnostics.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProfileDiagnostics.Serialization.cs new file mode 100644 index 000000000000..58648599100c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProfileDiagnostics.Serialization.cs @@ -0,0 +1,141 @@ +// 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.IoTOperations.Models +{ + public partial class ProfileDiagnostics : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProfileDiagnostics)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Logs)) + { + writer.WritePropertyName("logs"u8); + writer.WriteObjectValue(Logs, options); + } + if (Optional.IsDefined(Metrics)) + { + writer.WritePropertyName("metrics"u8); + writer.WriteObjectValue(Metrics, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ProfileDiagnostics 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(ProfileDiagnostics)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProfileDiagnostics(document.RootElement, options); + } + + internal static ProfileDiagnostics DeserializeProfileDiagnostics(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DiagnosticsLogs logs = default; + Metrics metrics = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("logs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + logs = DiagnosticsLogs.DeserializeDiagnosticsLogs(property.Value, options); + continue; + } + if (property.NameEquals("metrics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + metrics = Metrics.DeserializeMetrics(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ProfileDiagnostics(logs, metrics, 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); + default: + throw new FormatException($"The model {nameof(ProfileDiagnostics)} does not support writing '{options.Format}' format."); + } + } + + ProfileDiagnostics 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); + return DeserializeProfileDiagnostics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProfileDiagnostics)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProfileDiagnostics.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProfileDiagnostics.cs new file mode 100644 index 000000000000..cb37de58987e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProfileDiagnostics.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.IoTOperations.Models +{ + /// DataflowProfile Diagnostics properties. + public partial class ProfileDiagnostics + { + /// + /// 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 ProfileDiagnostics() + { + } + + /// Initializes a new instance of . + /// Diagnostic log settings for the resource. + /// The metrics settings for the resource. + /// Keeps track of any properties unknown to the library. + internal ProfileDiagnostics(DiagnosticsLogs logs, Metrics metrics, IDictionary serializedAdditionalRawData) + { + Logs = logs; + Metrics = metrics; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Diagnostic log settings for the resource. + public DiagnosticsLogs Logs { get; set; } + /// The metrics settings for the resource. + public Metrics Metrics { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProvisioningState.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..d67e461950ac --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ProvisioningState.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.IoTOperations.Models +{ + /// The enum defining status of 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 ProvisioningValue = "Provisioning"; + private const string UpdatingValue = "Updating"; + private const string DeletingValue = "Deleting"; + private const string AcceptedValue = "Accepted"; + + /// 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); + /// Resource is getting provisioned. + public static ProvisioningState Provisioning { get; } = new ProvisioningState(ProvisioningValue); + /// Resource is Updating. + public static ProvisioningState Updating { get; } = new ProvisioningState(UpdatingValue); + /// Resource is Deleting. + public static ProvisioningState Deleting { get; } = new ProvisioningState(DeletingValue); + /// Resource has been Accepted. + public static ProvisioningState Accepted { get; } = new ProvisioningState(AcceptedValue); + /// 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 string 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SanForCert.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SanForCert.Serialization.cs new file mode 100644 index 000000000000..af6e8bea0f97 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SanForCert.Serialization.cs @@ -0,0 +1,147 @@ +// 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.IoTOperations.Models +{ + public partial class SanForCert : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SanForCert)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("dns"u8); + writer.WriteStartArray(); + foreach (var item in Dns) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("ip"u8); + writer.WriteStartArray(); + foreach (var item in IP) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SanForCert 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(SanForCert)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSanForCert(document.RootElement, options); + } + + internal static SanForCert DeserializeSanForCert(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList dns = default; + IList ip = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("dns"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + dns = array; + continue; + } + if (property.NameEquals("ip"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + ip = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SanForCert(dns, ip, 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); + default: + throw new FormatException($"The model {nameof(SanForCert)} does not support writing '{options.Format}' format."); + } + } + + SanForCert 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); + return DeserializeSanForCert(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SanForCert)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SanForCert.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SanForCert.cs new file mode 100644 index 000000000000..750bd03821a1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SanForCert.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 System.Linq; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Subject Alternative Names (SANs) for certificate. + public partial class SanForCert + { + /// + /// 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 . + /// DNS SANs. + /// IP address SANs. + /// or is null. + public SanForCert(IEnumerable dns, IEnumerable ip) + { + Argument.AssertNotNull(dns, nameof(dns)); + Argument.AssertNotNull(ip, nameof(ip)); + + Dns = dns.ToList(); + IP = ip.ToList(); + } + + /// Initializes a new instance of . + /// DNS SANs. + /// IP address SANs. + /// Keeps track of any properties unknown to the library. + internal SanForCert(IList dns, IList ip, IDictionary serializedAdditionalRawData) + { + Dns = dns; + IP = ip; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SanForCert() + { + } + + /// DNS SANs. + public IList Dns { get; } + /// IP address SANs. + public IList IP { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SchemaRegistryInstanceProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SchemaRegistryInstanceProperties.Serialization.cs new file mode 100644 index 000000000000..31d751ff1bd6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SchemaRegistryInstanceProperties.Serialization.cs @@ -0,0 +1,119 @@ +// 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.IoTOperations.Models +{ + internal partial class SchemaRegistryInstanceProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SchemaRegistryInstanceProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SchemaRegistryInstanceProperties 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(SchemaRegistryInstanceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSchemaRegistryInstanceProperties(document.RootElement, options); + } + + internal static SchemaRegistryInstanceProperties DeserializeSchemaRegistryInstanceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode state = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("state"u8)) + { + state = new OperationalMode(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SchemaRegistryInstanceProperties(state, 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); + default: + throw new FormatException($"The model {nameof(SchemaRegistryInstanceProperties)} does not support writing '{options.Format}' format."); + } + } + + SchemaRegistryInstanceProperties 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); + return DeserializeSchemaRegistryInstanceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SchemaRegistryInstanceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SchemaRegistryInstanceProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SchemaRegistryInstanceProperties.cs new file mode 100644 index 000000000000..ed98515bc32b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SchemaRegistryInstanceProperties.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.IoTOperations.Models +{ + /// The properties of a Schema Registry instance. + internal partial class SchemaRegistryInstanceProperties + { + /// + /// 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 . + /// This determines if the Schema Registry service is enabled. + public SchemaRegistryInstanceProperties(OperationalMode state) + { + State = state; + } + + /// Initializes a new instance of . + /// This determines if the Schema Registry service is enabled. + /// Keeps track of any properties unknown to the library. + internal SchemaRegistryInstanceProperties(OperationalMode state, IDictionary serializedAdditionalRawData) + { + State = state; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SchemaRegistryInstanceProperties() + { + } + + /// This determines if the Schema Registry service is enabled. + public OperationalMode State { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfCheck.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfCheck.Serialization.cs new file mode 100644 index 000000000000..3ea66b84dbd9 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfCheck.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.Json; +using Azure.Core; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + public partial class SelfCheck : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SelfCheck)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + if (Optional.IsDefined(IntervalSeconds)) + { + writer.WritePropertyName("intervalSeconds"u8); + writer.WriteNumberValue(IntervalSeconds.Value); + } + if (Optional.IsDefined(TimeoutSeconds)) + { + writer.WritePropertyName("timeoutSeconds"u8); + writer.WriteNumberValue(TimeoutSeconds.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SelfCheck 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(SelfCheck)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSelfCheck(document.RootElement, options); + } + + internal static SelfCheck DeserializeSelfCheck(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode? mode = default; + int? intervalSeconds = default; + int? timeoutSeconds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("mode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mode = new OperationalMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("intervalSeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + intervalSeconds = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("timeoutSeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timeoutSeconds = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SelfCheck(mode, intervalSeconds, timeoutSeconds, 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); + default: + throw new FormatException($"The model {nameof(SelfCheck)} does not support writing '{options.Format}' format."); + } + } + + SelfCheck 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); + return DeserializeSelfCheck(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SelfCheck)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfCheck.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfCheck.cs new file mode 100644 index 000000000000..6fa8789c8bbf --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfCheck.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Broker Diagnostic Self check properties. + public partial class SelfCheck + { + /// + /// 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 SelfCheck() + { + } + + /// Initializes a new instance of . + /// The toggle to enable/disable self check. + /// The self check interval. + /// The timeout for self check. + /// Keeps track of any properties unknown to the library. + internal SelfCheck(OperationalMode? mode, int? intervalSeconds, int? timeoutSeconds, IDictionary serializedAdditionalRawData) + { + Mode = mode; + IntervalSeconds = intervalSeconds; + TimeoutSeconds = timeoutSeconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The toggle to enable/disable self check. + public OperationalMode? Mode { get; set; } + /// The self check interval. + public int? IntervalSeconds { get; set; } + /// The timeout for self check. + public int? TimeoutSeconds { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfTracing.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfTracing.Serialization.cs new file mode 100644 index 000000000000..c28fa4430d9f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfTracing.Serialization.cs @@ -0,0 +1,141 @@ +// 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.IoTOperations.Models +{ + public partial class SelfTracing : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SelfTracing)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + if (Optional.IsDefined(IntervalSeconds)) + { + writer.WritePropertyName("intervalSeconds"u8); + writer.WriteNumberValue(IntervalSeconds.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SelfTracing 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(SelfTracing)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSelfTracing(document.RootElement, options); + } + + internal static SelfTracing DeserializeSelfTracing(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode? mode = default; + int? intervalSeconds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("mode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mode = new OperationalMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("intervalSeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + intervalSeconds = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SelfTracing(mode, intervalSeconds, 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); + default: + throw new FormatException($"The model {nameof(SelfTracing)} does not support writing '{options.Format}' format."); + } + } + + SelfTracing 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); + return DeserializeSelfTracing(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SelfTracing)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfTracing.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfTracing.cs new file mode 100644 index 000000000000..9fe7f6412260 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SelfTracing.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.IoTOperations.Models +{ + /// Diagnostic Self tracing properties. + public partial class SelfTracing + { + /// + /// 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 SelfTracing() + { + } + + /// Initializes a new instance of . + /// The toggle to enable/disable self tracing. + /// The self tracing interval. + /// Keeps track of any properties unknown to the library. + internal SelfTracing(OperationalMode? mode, int? intervalSeconds, IDictionary serializedAdditionalRawData) + { + Mode = mode; + IntervalSeconds = intervalSeconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The toggle to enable/disable self tracing. + public OperationalMode? Mode { get; set; } + /// The self tracing interval. + public int? IntervalSeconds { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ServiceType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ServiceType.cs new file mode 100644 index 000000000000..83cab10fbe68 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/ServiceType.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.IoTOperations.Models +{ + /// Kubernetes Service Types supported by Listener. + public readonly partial struct ServiceType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ServiceType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ClusterIPValue = "ClusterIp"; + private const string LoadBalancerValue = "LoadBalancer"; + private const string NodePortValue = "NodePort"; + + /// Cluster IP Service. + public static ServiceType ClusterIP { get; } = new ServiceType(ClusterIPValue); + /// Load Balancer Service. + public static ServiceType LoadBalancer { get; } = new ServiceType(LoadBalancerValue); + /// Node Port Service. + public static ServiceType NodePort { get; } = new ServiceType(NodePortValue); + /// Determines if two values are the same. + public static bool operator ==(ServiceType left, ServiceType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ServiceType left, ServiceType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ServiceType(string value) => new ServiceType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ServiceType other && Equals(other); + /// + public bool Equals(ServiceType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SourceSerializationFormat.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SourceSerializationFormat.cs new file mode 100644 index 000000000000..585d936faa94 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SourceSerializationFormat.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Serialization Format properties. + public readonly partial struct SourceSerializationFormat : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SourceSerializationFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string JsonValue = "Json"; + + /// JSON Format. + public static SourceSerializationFormat Json { get; } = new SourceSerializationFormat(JsonValue); + /// Determines if two values are the same. + public static bool operator ==(SourceSerializationFormat left, SourceSerializationFormat right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SourceSerializationFormat left, SourceSerializationFormat right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator SourceSerializationFormat(string value) => new SourceSerializationFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SourceSerializationFormat other && Equals(other); + /// + public bool Equals(SourceSerializationFormat 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceDefinitionMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceDefinitionMethod.cs new file mode 100644 index 000000000000..fe787204b79c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceDefinitionMethod.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.IoTOperations.Models +{ + /// StateStoreResourceDefinitionMethods methods allowed. + public readonly partial struct StateStoreResourceDefinitionMethod : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public StateStoreResourceDefinitionMethod(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ReadValue = "Read"; + private const string WriteValue = "Write"; + private const string ReadWriteValue = "ReadWrite"; + + /// Get/KeyNotify from Store. + public static StateStoreResourceDefinitionMethod Read { get; } = new StateStoreResourceDefinitionMethod(ReadValue); + /// Set/Delete in Store. + public static StateStoreResourceDefinitionMethod Write { get; } = new StateStoreResourceDefinitionMethod(WriteValue); + /// Allowed all operations on Store - Get/KeyNotify/Set/Delete. + public static StateStoreResourceDefinitionMethod ReadWrite { get; } = new StateStoreResourceDefinitionMethod(ReadWriteValue); + /// Determines if two values are the same. + public static bool operator ==(StateStoreResourceDefinitionMethod left, StateStoreResourceDefinitionMethod right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(StateStoreResourceDefinitionMethod left, StateStoreResourceDefinitionMethod right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator StateStoreResourceDefinitionMethod(string value) => new StateStoreResourceDefinitionMethod(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is StateStoreResourceDefinitionMethod other && Equals(other); + /// + public bool Equals(StateStoreResourceDefinitionMethod 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceKeyType.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceKeyType.cs new file mode 100644 index 000000000000..4da55b6e9735 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceKeyType.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.IoTOperations.Models +{ + /// StateStoreResourceKeyTypes properties. + public readonly partial struct StateStoreResourceKeyType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public StateStoreResourceKeyType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PatternValue = "Pattern"; + private const string StringValue = "String"; + private const string BinaryValue = "Binary"; + + /// Key type - pattern. + public static StateStoreResourceKeyType Pattern { get; } = new StateStoreResourceKeyType(PatternValue); + /// Key type - string. + public static StateStoreResourceKeyType String { get; } = new StateStoreResourceKeyType(StringValue); + /// Key type - binary. + public static StateStoreResourceKeyType Binary { get; } = new StateStoreResourceKeyType(BinaryValue); + /// Determines if two values are the same. + public static bool operator ==(StateStoreResourceKeyType left, StateStoreResourceKeyType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(StateStoreResourceKeyType left, StateStoreResourceKeyType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator StateStoreResourceKeyType(string value) => new StateStoreResourceKeyType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is StateStoreResourceKeyType other && Equals(other); + /// + public bool Equals(StateStoreResourceKeyType 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceRule.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceRule.Serialization.cs new file mode 100644 index 000000000000..c0ec048a0ddb --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceRule.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.IoTOperations.Models +{ + public partial class StateStoreResourceRule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StateStoreResourceRule)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("keyType"u8); + writer.WriteStringValue(KeyType.ToString()); + writer.WritePropertyName("keys"u8); + writer.WriteStartArray(); + foreach (var item in Keys) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + StateStoreResourceRule 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(StateStoreResourceRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStateStoreResourceRule(document.RootElement, options); + } + + internal static StateStoreResourceRule DeserializeStateStoreResourceRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StateStoreResourceKeyType keyType = default; + IList keys = default; + StateStoreResourceDefinitionMethod method = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("keyType"u8)) + { + keyType = new StateStoreResourceKeyType(property.Value.GetString()); + continue; + } + if (property.NameEquals("keys"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + keys = array; + continue; + } + if (property.NameEquals("method"u8)) + { + method = new StateStoreResourceDefinitionMethod(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StateStoreResourceRule(keyType, keys, method, 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); + default: + throw new FormatException($"The model {nameof(StateStoreResourceRule)} does not support writing '{options.Format}' format."); + } + } + + StateStoreResourceRule 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); + return DeserializeStateStoreResourceRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StateStoreResourceRule)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceRule.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceRule.cs new file mode 100644 index 000000000000..9087cc273357 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/StateStoreResourceRule.cs @@ -0,0 +1,88 @@ +// 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.IoTOperations.Models +{ + /// State Store Resource Rule properties. + public partial class StateStoreResourceRule + { + /// + /// 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 . + /// Allowed keyTypes pattern, string, binary. The key type used for matching, for example pattern tries to match the key to a glob-style pattern and string checks key is equal to value provided in keys. + /// Give access to state store keys for the corresponding principals defined. When key type is pattern set glob-style pattern (e.g., '*', 'clients/*'). + /// Give access for `Read`, `Write` and `ReadWrite` access level. + /// is null. + public StateStoreResourceRule(StateStoreResourceKeyType keyType, IEnumerable keys, StateStoreResourceDefinitionMethod method) + { + Argument.AssertNotNull(keys, nameof(keys)); + + KeyType = keyType; + Keys = keys.ToList(); + Method = method; + } + + /// Initializes a new instance of . + /// Allowed keyTypes pattern, string, binary. The key type used for matching, for example pattern tries to match the key to a glob-style pattern and string checks key is equal to value provided in keys. + /// Give access to state store keys for the corresponding principals defined. When key type is pattern set glob-style pattern (e.g., '*', 'clients/*'). + /// Give access for `Read`, `Write` and `ReadWrite` access level. + /// Keeps track of any properties unknown to the library. + internal StateStoreResourceRule(StateStoreResourceKeyType keyType, IList keys, StateStoreResourceDefinitionMethod method, IDictionary serializedAdditionalRawData) + { + KeyType = keyType; + Keys = keys; + Method = method; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal StateStoreResourceRule() + { + } + + /// Allowed keyTypes pattern, string, binary. The key type used for matching, for example pattern tries to match the key to a glob-style pattern and string checks key is equal to value provided in keys. + public StateStoreResourceKeyType KeyType { get; set; } + /// Give access to state store keys for the corresponding principals defined. When key type is pattern set glob-style pattern (e.g., '*', 'clients/*'). + public IList Keys { get; } + /// Give access for `Read`, `Write` and `ReadWrite` access level. + public StateStoreResourceDefinitionMethod Method { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberMessageDropStrategy.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberMessageDropStrategy.cs new file mode 100644 index 000000000000..a6706bbc99c6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberMessageDropStrategy.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.IoTOperations.Models +{ + /// The enum defining strategies for dropping messages from the subscriber queue. + public readonly partial struct SubscriberMessageDropStrategy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SubscriberMessageDropStrategy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string DropOldestValue = "DropOldest"; + + /// Messages are never dropped. + public static SubscriberMessageDropStrategy None { get; } = new SubscriberMessageDropStrategy(NoneValue); + /// The oldest message is dropped. + public static SubscriberMessageDropStrategy DropOldest { get; } = new SubscriberMessageDropStrategy(DropOldestValue); + /// Determines if two values are the same. + public static bool operator ==(SubscriberMessageDropStrategy left, SubscriberMessageDropStrategy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SubscriberMessageDropStrategy left, SubscriberMessageDropStrategy right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator SubscriberMessageDropStrategy(string value) => new SubscriberMessageDropStrategy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SubscriberMessageDropStrategy other && Equals(other); + /// + public bool Equals(SubscriberMessageDropStrategy 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberQueueLimit.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberQueueLimit.Serialization.cs new file mode 100644 index 000000000000..e51b15d95765 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberQueueLimit.Serialization.cs @@ -0,0 +1,141 @@ +// 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.IoTOperations.Models +{ + public partial class SubscriberQueueLimit : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubscriberQueueLimit)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Length)) + { + writer.WritePropertyName("length"u8); + writer.WriteNumberValue(Length.Value); + } + if (Optional.IsDefined(Strategy)) + { + writer.WritePropertyName("strategy"u8); + writer.WriteStringValue(Strategy.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SubscriberQueueLimit 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(SubscriberQueueLimit)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubscriberQueueLimit(document.RootElement, options); + } + + internal static SubscriberQueueLimit DeserializeSubscriberQueueLimit(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long? length = default; + SubscriberMessageDropStrategy? strategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("length"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + length = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + strategy = new SubscriberMessageDropStrategy(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SubscriberQueueLimit(length, strategy, 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); + default: + throw new FormatException($"The model {nameof(SubscriberQueueLimit)} does not support writing '{options.Format}' format."); + } + } + + SubscriberQueueLimit 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); + return DeserializeSubscriberQueueLimit(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubscriberQueueLimit)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberQueueLimit.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberQueueLimit.cs new file mode 100644 index 000000000000..b397650aa427 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/SubscriberQueueLimit.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.IoTOperations.Models +{ + /// The settings of Subscriber Queue Limit. + public partial class SubscriberQueueLimit + { + /// + /// 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 SubscriberQueueLimit() + { + } + + /// Initializes a new instance of . + /// The maximum length of the queue before messages start getting dropped. + /// The strategy to use for dropping messages from the queue. + /// Keeps track of any properties unknown to the library. + internal SubscriberQueueLimit(long? length, SubscriberMessageDropStrategy? strategy, IDictionary serializedAdditionalRawData) + { + Length = length; + Strategy = strategy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The maximum length of the queue before messages start getting dropped. + public long? Length { get; set; } + /// The strategy to use for dropping messages from the queue. + public SubscriberMessageDropStrategy? Strategy { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethod.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethod.Serialization.cs new file mode 100644 index 000000000000..3b11cc0382ab --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethod.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.IoTOperations.Models +{ + public partial class TlsCertMethod : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TlsCertMethod)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.ToString()); + if (Optional.IsDefined(CertManagerCertificateSpec)) + { + writer.WritePropertyName("certManagerCertificateSpec"u8); + writer.WriteObjectValue(CertManagerCertificateSpec, options); + } + if (Optional.IsDefined(Manual)) + { + writer.WritePropertyName("manual"u8); + writer.WriteObjectValue(Manual, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TlsCertMethod 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(TlsCertMethod)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTlsCertMethod(document.RootElement, options); + } + + internal static TlsCertMethod DeserializeTlsCertMethod(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TlsCertMethodMode mode = default; + CertManagerCertificateSpec certManagerCertificateSpec = default; + X509ManualCertificate manual = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("mode"u8)) + { + mode = new TlsCertMethodMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("certManagerCertificateSpec"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + certManagerCertificateSpec = CertManagerCertificateSpec.DeserializeCertManagerCertificateSpec(property.Value, options); + continue; + } + if (property.NameEquals("manual"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + manual = X509ManualCertificate.DeserializeX509ManualCertificate(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TlsCertMethod(mode, certManagerCertificateSpec, manual, 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); + default: + throw new FormatException($"The model {nameof(TlsCertMethod)} does not support writing '{options.Format}' format."); + } + } + + TlsCertMethod 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); + return DeserializeTlsCertMethod(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TlsCertMethod)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethod.cs new file mode 100644 index 000000000000..2f0fc69c5814 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethod.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// Collection of different TLS types, NOTE- Enum at a time only one of them needs to be supported. + public partial class TlsCertMethod + { + /// + /// 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 . + /// Mode of TLS server certificate management. + public TlsCertMethod(TlsCertMethodMode mode) + { + Mode = mode; + } + + /// Initializes a new instance of . + /// Mode of TLS server certificate management. + /// Option 1 - Automatic TLS server certificate management with cert-manager. + /// Option 2 - Manual TLS server certificate management through a defined secret. + /// Keeps track of any properties unknown to the library. + internal TlsCertMethod(TlsCertMethodMode mode, CertManagerCertificateSpec certManagerCertificateSpec, X509ManualCertificate manual, IDictionary serializedAdditionalRawData) + { + Mode = mode; + CertManagerCertificateSpec = certManagerCertificateSpec; + Manual = manual; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TlsCertMethod() + { + } + + /// Mode of TLS server certificate management. + public TlsCertMethodMode Mode { get; set; } + /// Option 1 - Automatic TLS server certificate management with cert-manager. + public CertManagerCertificateSpec CertManagerCertificateSpec { get; set; } + /// Option 2 - Manual TLS server certificate management through a defined secret. + internal X509ManualCertificate Manual { get; set; } + /// Kubernetes secret containing an X.509 client certificate. This is a reference to the secret through an identifying name, not the secret itself. + public string ManualSecretRef + { + get => Manual is null ? default : Manual.SecretRef; + set => Manual = new X509ManualCertificate(value); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethodMode.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethodMode.cs new file mode 100644 index 000000000000..77788b42ca32 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsCertMethodMode.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.IoTOperations.Models +{ + /// Broker Authentication Mode. + public readonly partial struct TlsCertMethodMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TlsCertMethodMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AutomaticValue = "Automatic"; + private const string ManualValue = "Manual"; + + /// Automatic TLS server certificate configuration. + public static TlsCertMethodMode Automatic { get; } = new TlsCertMethodMode(AutomaticValue); + /// Manual TLS server certificate configuration. + public static TlsCertMethodMode Manual { get; } = new TlsCertMethodMode(ManualValue); + /// Determines if two values are the same. + public static bool operator ==(TlsCertMethodMode left, TlsCertMethodMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TlsCertMethodMode left, TlsCertMethodMode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator TlsCertMethodMode(string value) => new TlsCertMethodMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TlsCertMethodMode other && Equals(other); + /// + public bool Equals(TlsCertMethodMode 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsProperties.Serialization.cs new file mode 100644 index 000000000000..d7b35c878e1c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsProperties.Serialization.cs @@ -0,0 +1,137 @@ +// 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.IoTOperations.Models +{ + public partial class TlsProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TlsProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + if (Optional.IsDefined(TrustedCaCertificateConfigMapRef)) + { + writer.WritePropertyName("trustedCaCertificateConfigMapRef"u8); + writer.WriteStringValue(TrustedCaCertificateConfigMapRef); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TlsProperties 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(TlsProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTlsProperties(document.RootElement, options); + } + + internal static TlsProperties DeserializeTlsProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode? mode = default; + string trustedCaCertificateConfigMapRef = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("mode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mode = new OperationalMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("trustedCaCertificateConfigMapRef"u8)) + { + trustedCaCertificateConfigMapRef = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TlsProperties(mode, trustedCaCertificateConfigMapRef, 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); + default: + throw new FormatException($"The model {nameof(TlsProperties)} does not support writing '{options.Format}' format."); + } + } + + TlsProperties 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); + return DeserializeTlsProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TlsProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsProperties.cs new file mode 100644 index 000000000000..f0d2baf4ae46 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TlsProperties.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.IoTOperations.Models +{ + /// Tls properties. + public partial class TlsProperties + { + /// + /// 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 TlsProperties() + { + } + + /// Initializes a new instance of . + /// Mode for TLS. + /// Trusted CA certificate config map. + /// Keeps track of any properties unknown to the library. + internal TlsProperties(OperationalMode? mode, string trustedCaCertificateConfigMapRef, IDictionary serializedAdditionalRawData) + { + Mode = mode; + TrustedCaCertificateConfigMapRef = trustedCaCertificateConfigMapRef; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Mode for TLS. + public OperationalMode? Mode { get; set; } + /// Trusted CA certificate config map. + public string TrustedCaCertificateConfigMapRef { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Traces.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Traces.Serialization.cs new file mode 100644 index 000000000000..95ca84b854ba --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Traces.Serialization.cs @@ -0,0 +1,192 @@ +// 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.IoTOperations.Models +{ + public partial class Traces : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Traces)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + if (Optional.IsDefined(OpentelemetryExportConfig)) + { + writer.WritePropertyName("opentelemetryExportConfig"u8); + writer.WriteObjectValue(OpentelemetryExportConfig, options); + } + if (Optional.IsDefined(CacheSizeMegabytes)) + { + writer.WritePropertyName("cacheSizeMegabytes"u8); + writer.WriteNumberValue(CacheSizeMegabytes.Value); + } + if (Optional.IsDefined(SelfTracing)) + { + writer.WritePropertyName("selfTracing"u8); + writer.WriteObjectValue(SelfTracing, options); + } + if (Optional.IsDefined(SpanChannelCapacity)) + { + writer.WritePropertyName("spanChannelCapacity"u8); + writer.WriteNumberValue(SpanChannelCapacity.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Traces 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(Traces)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTraces(document.RootElement, options); + } + + internal static Traces DeserializeTraces(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationalMode? mode = default; + OpenTelemetryExportConfig opentelemetryExportConfig = default; + int? cacheSizeMegabytes = default; + SelfTracing selfTracing = default; + int? spanChannelCapacity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("mode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mode = new OperationalMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("opentelemetryExportConfig"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + opentelemetryExportConfig = OpenTelemetryExportConfig.DeserializeOpenTelemetryExportConfig(property.Value, options); + continue; + } + if (property.NameEquals("cacheSizeMegabytes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + cacheSizeMegabytes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("selfTracing"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + selfTracing = SelfTracing.DeserializeSelfTracing(property.Value, options); + continue; + } + if (property.NameEquals("spanChannelCapacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + spanChannelCapacity = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Traces( + mode, + opentelemetryExportConfig, + cacheSizeMegabytes, + selfTracing, + spanChannelCapacity, + 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); + default: + throw new FormatException($"The model {nameof(Traces)} does not support writing '{options.Format}' format."); + } + } + + Traces 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); + return DeserializeTraces(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Traces)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Traces.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Traces.cs new file mode 100644 index 000000000000..11f621579931 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/Traces.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.IoTOperations.Models +{ + /// Broker Diagnostic Trace properties. + public partial class Traces + { + /// + /// 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 Traces() + { + } + + /// Initializes a new instance of . + /// The toggle to enable/disable traces. + /// The open telemetry export configuration. + /// The cache size in megabytes. + /// The self tracing properties. + /// The span channel capacity. + /// Keeps track of any properties unknown to the library. + internal Traces(OperationalMode? mode, OpenTelemetryExportConfig opentelemetryExportConfig, int? cacheSizeMegabytes, SelfTracing selfTracing, int? spanChannelCapacity, IDictionary serializedAdditionalRawData) + { + Mode = mode; + OpentelemetryExportConfig = opentelemetryExportConfig; + CacheSizeMegabytes = cacheSizeMegabytes; + SelfTracing = selfTracing; + SpanChannelCapacity = spanChannelCapacity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The toggle to enable/disable traces. + public OperationalMode? Mode { get; set; } + /// The open telemetry export configuration. + public OpenTelemetryExportConfig OpentelemetryExportConfig { get; set; } + /// The cache size in megabytes. + public int? CacheSizeMegabytes { get; set; } + /// The self tracing properties. + public SelfTracing SelfTracing { get; set; } + /// The span channel capacity. + public int? SpanChannelCapacity { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TransformationSerializationFormat.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TransformationSerializationFormat.cs new file mode 100644 index 000000000000..d98876b8aca3 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/TransformationSerializationFormat.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.IoTOperations.Models +{ + /// Transformation Format properties. + public readonly partial struct TransformationSerializationFormat : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TransformationSerializationFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DeltaValue = "Delta"; + private const string JsonValue = "Json"; + private const string ParquetValue = "Parquet"; + + /// Delta Format. + public static TransformationSerializationFormat Delta { get; } = new TransformationSerializationFormat(DeltaValue); + /// JSON Format. + public static TransformationSerializationFormat Json { get; } = new TransformationSerializationFormat(JsonValue); + /// Parquet Format. + public static TransformationSerializationFormat Parquet { get; } = new TransformationSerializationFormat(ParquetValue); + /// Determines if two values are the same. + public static bool operator ==(TransformationSerializationFormat left, TransformationSerializationFormat right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TransformationSerializationFormat left, TransformationSerializationFormat right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator TransformationSerializationFormat(string value) => new TransformationSerializationFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TransformationSerializationFormat other && Equals(other); + /// + public bool Equals(TransformationSerializationFormat 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/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimResourceRequirements.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimResourceRequirements.Serialization.cs new file mode 100644 index 000000000000..5eee3e8dc5df --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimResourceRequirements.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.IoTOperations.Models +{ + public partial class VolumeClaimResourceRequirements : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VolumeClaimResourceRequirements)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Limits)) + { + writer.WritePropertyName("limits"u8); + writer.WriteStartObject(); + foreach (var item in Limits) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsCollectionDefined(Requests)) + { + writer.WritePropertyName("requests"u8); + writer.WriteStartObject(); + foreach (var item in Requests) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VolumeClaimResourceRequirements 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(VolumeClaimResourceRequirements)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVolumeClaimResourceRequirements(document.RootElement, options); + } + + internal static VolumeClaimResourceRequirements DeserializeVolumeClaimResourceRequirements(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary limits = default; + IDictionary requests = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("limits"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()); + } + limits = dictionary; + continue; + } + if (property.NameEquals("requests"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()); + } + requests = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VolumeClaimResourceRequirements(limits ?? new ChangeTrackingDictionary(), requests ?? 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); + default: + throw new FormatException($"The model {nameof(VolumeClaimResourceRequirements)} does not support writing '{options.Format}' format."); + } + } + + VolumeClaimResourceRequirements 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); + return DeserializeVolumeClaimResourceRequirements(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VolumeClaimResourceRequirements)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimResourceRequirements.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimResourceRequirements.cs new file mode 100644 index 000000000000..d681ac7b0a98 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimResourceRequirements.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// VolumeClaimResourceRequirements properties. + public partial class VolumeClaimResourceRequirements + { + /// + /// 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 VolumeClaimResourceRequirements() + { + Limits = new ChangeTrackingDictionary(); + Requests = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/. + /// Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/. + /// Keeps track of any properties unknown to the library. + internal VolumeClaimResourceRequirements(IDictionary limits, IDictionary requests, IDictionary serializedAdditionalRawData) + { + Limits = limits; + Requests = requests; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/. + public IDictionary Limits { get; } + /// Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/. + public IDictionary Requests { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpec.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpec.Serialization.cs new file mode 100644 index 000000000000..b65985aa4f93 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpec.Serialization.cs @@ -0,0 +1,238 @@ +// 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.IoTOperations.Models +{ + public partial class VolumeClaimSpec : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VolumeClaimSpec)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(VolumeName)) + { + writer.WritePropertyName("volumeName"u8); + writer.WriteStringValue(VolumeName); + } + if (Optional.IsDefined(VolumeMode)) + { + writer.WritePropertyName("volumeMode"u8); + writer.WriteStringValue(VolumeMode); + } + if (Optional.IsDefined(StorageClassName)) + { + writer.WritePropertyName("storageClassName"u8); + writer.WriteStringValue(StorageClassName); + } + if (Optional.IsCollectionDefined(AccessModes)) + { + writer.WritePropertyName("accessModes"u8); + writer.WriteStartArray(); + foreach (var item in AccessModes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(DataSource)) + { + writer.WritePropertyName("dataSource"u8); + writer.WriteObjectValue(DataSource, options); + } + if (Optional.IsDefined(DataSourceRef)) + { + writer.WritePropertyName("dataSourceRef"u8); + writer.WriteObjectValue(DataSourceRef, options); + } + if (Optional.IsDefined(Resources)) + { + writer.WritePropertyName("resources"u8); + writer.WriteObjectValue(Resources, options); + } + if (Optional.IsDefined(Selector)) + { + writer.WritePropertyName("selector"u8); + writer.WriteObjectValue(Selector, 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VolumeClaimSpec 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(VolumeClaimSpec)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVolumeClaimSpec(document.RootElement, options); + } + + internal static VolumeClaimSpec DeserializeVolumeClaimSpec(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string volumeName = default; + string volumeMode = default; + string storageClassName = default; + IList accessModes = default; + LocalKubernetesReference dataSource = default; + KubernetesReference dataSourceRef = default; + VolumeClaimResourceRequirements resources = default; + VolumeClaimSpecSelector selector = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("volumeName"u8)) + { + volumeName = property.Value.GetString(); + continue; + } + if (property.NameEquals("volumeMode"u8)) + { + volumeMode = property.Value.GetString(); + continue; + } + if (property.NameEquals("storageClassName"u8)) + { + storageClassName = property.Value.GetString(); + continue; + } + if (property.NameEquals("accessModes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + accessModes = array; + continue; + } + if (property.NameEquals("dataSource"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataSource = LocalKubernetesReference.DeserializeLocalKubernetesReference(property.Value, options); + continue; + } + if (property.NameEquals("dataSourceRef"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataSourceRef = KubernetesReference.DeserializeKubernetesReference(property.Value, options); + continue; + } + if (property.NameEquals("resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resources = VolumeClaimResourceRequirements.DeserializeVolumeClaimResourceRequirements(property.Value, options); + continue; + } + if (property.NameEquals("selector"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + selector = VolumeClaimSpecSelector.DeserializeVolumeClaimSpecSelector(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VolumeClaimSpec( + volumeName, + volumeMode, + storageClassName, + accessModes ?? new ChangeTrackingList(), + dataSource, + dataSourceRef, + resources, + selector, + 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); + default: + throw new FormatException($"The model {nameof(VolumeClaimSpec)} does not support writing '{options.Format}' format."); + } + } + + VolumeClaimSpec 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); + return DeserializeVolumeClaimSpec(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VolumeClaimSpec)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpec.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpec.cs new file mode 100644 index 000000000000..19e9bce5dd85 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpec.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// VolumeClaimSpec properties. + public partial class VolumeClaimSpec + { + /// + /// 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 VolumeClaimSpec() + { + AccessModes = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// VolumeName is the binding reference to the PersistentVolume backing this claim. + /// volumeMode defines what type of volume is required by the claim. Value of Filesystem is implied when not included in claim spec. This is a beta feature. + /// Name of the StorageClass required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1. + /// AccessModes contains the desired access modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1. + /// This field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source. If the AnyVolumeDataSource feature gate is enabled, this field will always have the same contents as the DataSourceRef field. + /// Specifies the object from which to populate the volume with data, if a non-empty volume is desired. This may be any local object from a non-empty API group (non core object) or a PersistentVolumeClaim object. When this field is specified, volume binding will only succeed if the type of the specified object matches some installed volume populator or dynamic provisioner. This field will replace the functionality of the DataSource field and as such if both fields are non-empty, they must have the same value. For backwards compatibility, both fields (DataSource and DataSourceRef) will be set to the same value automatically if one of them is empty and the other is non-empty. There are two important differences between DataSource and DataSourceRef: * While DataSource only allows two specific types of objects, DataSourceRef allows any non-core object, as well as PersistentVolumeClaim objects. * While DataSource ignores disallowed values (dropping them), DataSourceRef preserves all values, and generates an error if a disallowed value is specified. (Beta) Using this field requires the AnyVolumeDataSource feature gate to be enabled. + /// Resources represents the minimum resources the volume should have. If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements that are lower than previous value but must still be higher than capacity recorded in the status field of the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources. + /// A label query over volumes to consider for binding. + /// Keeps track of any properties unknown to the library. + internal VolumeClaimSpec(string volumeName, string volumeMode, string storageClassName, IList accessModes, LocalKubernetesReference dataSource, KubernetesReference dataSourceRef, VolumeClaimResourceRequirements resources, VolumeClaimSpecSelector selector, IDictionary serializedAdditionalRawData) + { + VolumeName = volumeName; + VolumeMode = volumeMode; + StorageClassName = storageClassName; + AccessModes = accessModes; + DataSource = dataSource; + DataSourceRef = dataSourceRef; + Resources = resources; + Selector = selector; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// VolumeName is the binding reference to the PersistentVolume backing this claim. + public string VolumeName { get; set; } + /// volumeMode defines what type of volume is required by the claim. Value of Filesystem is implied when not included in claim spec. This is a beta feature. + public string VolumeMode { get; set; } + /// Name of the StorageClass required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1. + public string StorageClassName { get; set; } + /// AccessModes contains the desired access modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1. + public IList AccessModes { get; } + /// This field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source. If the AnyVolumeDataSource feature gate is enabled, this field will always have the same contents as the DataSourceRef field. + public LocalKubernetesReference DataSource { get; set; } + /// Specifies the object from which to populate the volume with data, if a non-empty volume is desired. This may be any local object from a non-empty API group (non core object) or a PersistentVolumeClaim object. When this field is specified, volume binding will only succeed if the type of the specified object matches some installed volume populator or dynamic provisioner. This field will replace the functionality of the DataSource field and as such if both fields are non-empty, they must have the same value. For backwards compatibility, both fields (DataSource and DataSourceRef) will be set to the same value automatically if one of them is empty and the other is non-empty. There are two important differences between DataSource and DataSourceRef: * While DataSource only allows two specific types of objects, DataSourceRef allows any non-core object, as well as PersistentVolumeClaim objects. * While DataSource ignores disallowed values (dropping them), DataSourceRef preserves all values, and generates an error if a disallowed value is specified. (Beta) Using this field requires the AnyVolumeDataSource feature gate to be enabled. + public KubernetesReference DataSourceRef { get; set; } + /// Resources represents the minimum resources the volume should have. If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements that are lower than previous value but must still be higher than capacity recorded in the status field of the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources. + public VolumeClaimResourceRequirements Resources { get; set; } + /// A label query over volumes to consider for binding. + public VolumeClaimSpecSelector Selector { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelector.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelector.Serialization.cs new file mode 100644 index 000000000000..5820a2a855d5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelector.Serialization.cs @@ -0,0 +1,162 @@ +// 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.IoTOperations.Models +{ + public partial class VolumeClaimSpecSelector : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VolumeClaimSpecSelector)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(MatchExpressions)) + { + writer.WritePropertyName("matchExpressions"u8); + writer.WriteStartArray(); + foreach (var item in MatchExpressions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(MatchLabels)) + { + writer.WritePropertyName("matchLabels"u8); + writer.WriteStartObject(); + foreach (var item in MatchLabels) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VolumeClaimSpecSelector 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(VolumeClaimSpecSelector)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVolumeClaimSpecSelector(document.RootElement, options); + } + + internal static VolumeClaimSpecSelector DeserializeVolumeClaimSpecSelector(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList matchExpressions = default; + IDictionary matchLabels = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("matchExpressions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VolumeClaimSpecSelectorMatchExpressions.DeserializeVolumeClaimSpecSelectorMatchExpressions(item, options)); + } + matchExpressions = array; + continue; + } + if (property.NameEquals("matchLabels"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()); + } + matchLabels = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VolumeClaimSpecSelector(matchExpressions ?? new ChangeTrackingList(), matchLabels ?? 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); + default: + throw new FormatException($"The model {nameof(VolumeClaimSpecSelector)} does not support writing '{options.Format}' format."); + } + } + + VolumeClaimSpecSelector 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); + return DeserializeVolumeClaimSpecSelector(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VolumeClaimSpecSelector)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelector.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelector.cs new file mode 100644 index 000000000000..b795f5039667 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelector.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// VolumeClaimSpecSelector properties. + public partial class VolumeClaimSpecSelector + { + /// + /// 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 VolumeClaimSpecSelector() + { + MatchExpressions = new ChangeTrackingList(); + MatchLabels = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// MatchExpressions is a list of label selector requirements. The requirements are ANDed. + /// MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + /// Keeps track of any properties unknown to the library. + internal VolumeClaimSpecSelector(IList matchExpressions, IDictionary matchLabels, IDictionary serializedAdditionalRawData) + { + MatchExpressions = matchExpressions; + MatchLabels = matchLabels; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// MatchExpressions is a list of label selector requirements. The requirements are ANDed. + public IList MatchExpressions { get; } + /// MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + public IDictionary MatchLabels { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelectorMatchExpressions.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelectorMatchExpressions.Serialization.cs new file mode 100644 index 000000000000..892d0c1f31e7 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelectorMatchExpressions.Serialization.cs @@ -0,0 +1,152 @@ +// 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.IoTOperations.Models +{ + public partial class VolumeClaimSpecSelectorMatchExpressions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VolumeClaimSpecSelectorMatchExpressions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + writer.WritePropertyName("operator"u8); + writer.WriteStringValue(Operator.ToString()); + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (var item in Values) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VolumeClaimSpecSelectorMatchExpressions 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(VolumeClaimSpecSelectorMatchExpressions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVolumeClaimSpecSelectorMatchExpressions(document.RootElement, options); + } + + internal static VolumeClaimSpecSelectorMatchExpressions DeserializeVolumeClaimSpecSelectorMatchExpressions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string key = default; + OperatorValue @operator = default; + IList values = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("key"u8)) + { + key = property.Value.GetString(); + continue; + } + if (property.NameEquals("operator"u8)) + { + @operator = new OperatorValue(property.Value.GetString()); + continue; + } + if (property.NameEquals("values"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + values = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VolumeClaimSpecSelectorMatchExpressions(key, @operator, values ?? 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); + default: + throw new FormatException($"The model {nameof(VolumeClaimSpecSelectorMatchExpressions)} does not support writing '{options.Format}' format."); + } + } + + VolumeClaimSpecSelectorMatchExpressions 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); + return DeserializeVolumeClaimSpecSelectorMatchExpressions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VolumeClaimSpecSelectorMatchExpressions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelectorMatchExpressions.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelectorMatchExpressions.cs new file mode 100644 index 000000000000..29a3c93a77c4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/VolumeClaimSpecSelectorMatchExpressions.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; + +namespace Azure.ResourceManager.IoTOperations.Models +{ + /// VolumeClaimSpecSelectorMatchExpressions properties. + public partial class VolumeClaimSpecSelectorMatchExpressions + { + /// + /// 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 . + /// key is the label key that the selector applies to. + /// operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + /// is null. + public VolumeClaimSpecSelectorMatchExpressions(string key, OperatorValue @operator) + { + Argument.AssertNotNull(key, nameof(key)); + + Key = key; + Operator = @operator; + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// key is the label key that the selector applies to. + /// operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + /// values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + /// Keeps track of any properties unknown to the library. + internal VolumeClaimSpecSelectorMatchExpressions(string key, OperatorValue @operator, IList values, IDictionary serializedAdditionalRawData) + { + Key = key; + Operator = @operator; + Values = values; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VolumeClaimSpecSelectorMatchExpressions() + { + } + + /// key is the label key that the selector applies to. + public string Key { get; set; } + /// operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + public OperatorValue Operator { get; set; } + /// values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + public IList Values { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/X509ManualCertificate.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/X509ManualCertificate.Serialization.cs new file mode 100644 index 000000000000..e7443258e8a4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/X509ManualCertificate.Serialization.cs @@ -0,0 +1,119 @@ +// 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.IoTOperations.Models +{ + internal partial class X509ManualCertificate : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(X509ManualCertificate)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("secretRef"u8); + writer.WriteStringValue(SecretRef); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + X509ManualCertificate 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(X509ManualCertificate)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeX509ManualCertificate(document.RootElement, options); + } + + internal static X509ManualCertificate DeserializeX509ManualCertificate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string secretRef = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("secretRef"u8)) + { + secretRef = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new X509ManualCertificate(secretRef, 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); + default: + throw new FormatException($"The model {nameof(X509ManualCertificate)} does not support writing '{options.Format}' format."); + } + } + + X509ManualCertificate 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); + return DeserializeX509ManualCertificate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(X509ManualCertificate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/X509ManualCertificate.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/X509ManualCertificate.cs new file mode 100644 index 000000000000..690b57bfbf1b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/Models/X509ManualCertificate.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.IoTOperations.Models +{ + /// X509 Certificate Authentication properties. + internal partial class X509ManualCertificate + { + /// + /// 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 . + /// Kubernetes secret containing an X.509 client certificate. This is a reference to the secret through an identifying name, not the secret itself. + /// is null. + public X509ManualCertificate(string secretRef) + { + Argument.AssertNotNull(secretRef, nameof(secretRef)); + + SecretRef = secretRef; + } + + /// Initializes a new instance of . + /// Kubernetes secret containing an X.509 client certificate. This is a reference to the secret through an identifying name, not the secret itself. + /// Keeps track of any properties unknown to the library. + internal X509ManualCertificate(string secretRef, IDictionary serializedAdditionalRawData) + { + SecretRef = secretRef; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal X509ManualCertificate() + { + } + + /// Kubernetes secret containing an X.509 client certificate. This is a reference to the secret through an identifying name, not the secret itself. + public string SecretRef { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/ProviderConstants.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..4b35d29c2858 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/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.IoTOperations +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerAuthenticationRestOperations.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerAuthenticationRestOperations.cs new file mode 100644 index 000000000000..b83c456697f7 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerAuthenticationRestOperations.cs @@ -0,0 +1,549 @@ +// 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.IoTOperations.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + internal partial class BrokerAuthenticationRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of BrokerAuthenticationRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public BrokerAuthenticationRestOperations(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 ?? "2024-08-15-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authenticationName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authentications/", false); + uri.AppendPath(authenticationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authenticationName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authentications/", false); + uri.AppendPath(authenticationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a BrokerAuthenticationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authentication 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 instanceName, string brokerName, string authenticationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authenticationName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthenticationResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerAuthenticationResourceData.DeserializeBrokerAuthenticationResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((BrokerAuthenticationResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a BrokerAuthenticationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authentication 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 instanceName, string brokerName, string authenticationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authenticationName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthenticationResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerAuthenticationResourceData.DeserializeBrokerAuthenticationResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((BrokerAuthenticationResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authenticationName, BrokerAuthenticationResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authentications/", false); + uri.AppendPath(authenticationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authenticationName, BrokerAuthenticationResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authentications/", false); + uri.AppendPath(authenticationName, 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 BrokerAuthenticationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authentication 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 instanceName, string brokerName, string authenticationName, BrokerAuthenticationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authenticationName, 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 BrokerAuthenticationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authentication 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 instanceName, string brokerName, string authenticationName, BrokerAuthenticationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authenticationName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authenticationName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authentications/", false); + uri.AppendPath(authenticationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authenticationName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authentications/", false); + uri.AppendPath(authenticationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a BrokerAuthenticationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authentication 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 instanceName, string brokerName, string authenticationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authenticationName); + 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 BrokerAuthenticationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authentication 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 instanceName, string brokerName, string authenticationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authenticationName); + _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, string instanceName, string brokerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authentications", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authentications", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List BrokerAuthenticationResource resources by BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName, brokerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthenticationResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerAuthenticationResourceListResult.DeserializeBrokerAuthenticationResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List BrokerAuthenticationResource resources by BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName, brokerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthenticationResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerAuthenticationResourceListResult.DeserializeBrokerAuthenticationResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + 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 BrokerAuthenticationResource resources by BrokerResource. + /// 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. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName, brokerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthenticationResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerAuthenticationResourceListResult.DeserializeBrokerAuthenticationResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List BrokerAuthenticationResource resources by BrokerResource. + /// 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. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName, brokerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthenticationResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerAuthenticationResourceListResult.DeserializeBrokerAuthenticationResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerAuthorizationRestOperations.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerAuthorizationRestOperations.cs new file mode 100644 index 000000000000..cc5949ebb91e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerAuthorizationRestOperations.cs @@ -0,0 +1,549 @@ +// 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.IoTOperations.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + internal partial class BrokerAuthorizationRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of BrokerAuthorizationRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public BrokerAuthorizationRestOperations(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 ?? "2024-08-15-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authorizationName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authorizations/", false); + uri.AppendPath(authorizationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authorizationName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authorizations/", false); + uri.AppendPath(authorizationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a BrokerAuthorizationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authorization 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 instanceName, string brokerName, string authorizationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authorizationName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthorizationResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerAuthorizationResourceData.DeserializeBrokerAuthorizationResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((BrokerAuthorizationResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a BrokerAuthorizationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authorization 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 instanceName, string brokerName, string authorizationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authorizationName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthorizationResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerAuthorizationResourceData.DeserializeBrokerAuthorizationResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((BrokerAuthorizationResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authorizationName, BrokerAuthorizationResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authorizations/", false); + uri.AppendPath(authorizationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authorizationName, BrokerAuthorizationResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authorizations/", false); + uri.AppendPath(authorizationName, 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 BrokerAuthorizationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authorization 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 instanceName, string brokerName, string authorizationName, BrokerAuthorizationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authorizationName, 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 BrokerAuthorizationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authorization 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 instanceName, string brokerName, string authorizationName, BrokerAuthorizationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authorizationName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authorizationName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authorizations/", false); + uri.AppendPath(authorizationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authorizationName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authorizations/", false); + uri.AppendPath(authorizationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a BrokerAuthorizationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authorization 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 instanceName, string brokerName, string authorizationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authorizationName); + 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 BrokerAuthorizationResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker authorization 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 instanceName, string brokerName, string authorizationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, brokerName, authorizationName); + _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, string instanceName, string brokerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authorizations", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/authorizations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List BrokerAuthorizationResource resources by BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName, brokerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthorizationResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerAuthorizationResourceListResult.DeserializeBrokerAuthorizationResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List BrokerAuthorizationResource resources by BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName, brokerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthorizationResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerAuthorizationResourceListResult.DeserializeBrokerAuthorizationResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + 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 BrokerAuthorizationResource resources by BrokerResource. + /// 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. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName, brokerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthorizationResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerAuthorizationResourceListResult.DeserializeBrokerAuthorizationResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List BrokerAuthorizationResource resources by BrokerResource. + /// 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. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName, brokerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerAuthorizationResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerAuthorizationResourceListResult.DeserializeBrokerAuthorizationResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerListenerRestOperations.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerListenerRestOperations.cs new file mode 100644 index 000000000000..454283588042 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerListenerRestOperations.cs @@ -0,0 +1,549 @@ +// 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.IoTOperations.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + internal partial class BrokerListenerRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of BrokerListenerRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public BrokerListenerRestOperations(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 ?? "2024-08-15-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string listenerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/listeners/", false); + uri.AppendPath(listenerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string listenerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/listeners/", false); + uri.AppendPath(listenerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a BrokerListenerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker listener 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 instanceName, string brokerName, string listenerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, brokerName, listenerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerListenerResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerListenerResourceData.DeserializeBrokerListenerResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((BrokerListenerResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a BrokerListenerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker listener 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 instanceName, string brokerName, string listenerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, brokerName, listenerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerListenerResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerListenerResourceData.DeserializeBrokerListenerResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((BrokerListenerResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string listenerName, BrokerListenerResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/listeners/", false); + uri.AppendPath(listenerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string listenerName, BrokerListenerResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/listeners/", false); + uri.AppendPath(listenerName, 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 BrokerListenerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker listener 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 instanceName, string brokerName, string listenerName, BrokerListenerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, brokerName, listenerName, 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 BrokerListenerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker listener 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 instanceName, string brokerName, string listenerName, BrokerListenerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, brokerName, listenerName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string listenerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/listeners/", false); + uri.AppendPath(listenerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string listenerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/listeners/", false); + uri.AppendPath(listenerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a BrokerListenerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker listener 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 instanceName, string brokerName, string listenerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, brokerName, listenerName); + 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 BrokerListenerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// Name of Instance broker listener 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 instanceName, string brokerName, string listenerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, brokerName, listenerName); + _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, string instanceName, string brokerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/listeners", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendPath("/listeners", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List BrokerListenerResource resources by BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName, brokerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerListenerResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerListenerResourceListResult.DeserializeBrokerListenerResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List BrokerListenerResource resources by BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName, brokerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerListenerResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerListenerResourceListResult.DeserializeBrokerListenerResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + 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 BrokerListenerResource resources by BrokerResource. + /// 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. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName, brokerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerListenerResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerListenerResourceListResult.DeserializeBrokerListenerResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List BrokerListenerResource resources by BrokerResource. + /// 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. + /// Name of instance. + /// Name of broker. + /// 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, string instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName, brokerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerListenerResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerListenerResourceListResult.DeserializeBrokerListenerResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerRestOperations.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerRestOperations.cs new file mode 100644 index 000000000000..8bc7d42dd4fd --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/BrokerRestOperations.cs @@ -0,0 +1,513 @@ +// 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.IoTOperations.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + internal partial class BrokerRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of BrokerRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public BrokerRestOperations(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 ?? "2024-08-15-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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 instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, brokerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerResourceData.DeserializeBrokerResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((BrokerResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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 instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, brokerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerResourceData.DeserializeBrokerResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((BrokerResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, BrokerResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, BrokerResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, 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 BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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 instanceName, string brokerName, BrokerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, brokerName, 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 BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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 instanceName, string brokerName, BrokerResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, brokerName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string instanceName, string brokerName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers/", false); + uri.AppendPath(brokerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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 instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, brokerName); + 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 BrokerResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of broker. + /// 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 instanceName, string brokerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, brokerName); + _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, string instanceName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName, string instanceName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/brokers", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List BrokerResource resources by InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerResourceListResult.DeserializeBrokerResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List BrokerResource resources by InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerResourceListResult.DeserializeBrokerResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string instanceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string instanceName) + { + 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 BrokerResource resources by InstanceResource. + /// 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. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BrokerResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BrokerResourceListResult.DeserializeBrokerResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List BrokerResource resources by InstanceResource. + /// 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. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BrokerResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BrokerResourceListResult.DeserializeBrokerResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowEndpointRestOperations.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowEndpointRestOperations.cs new file mode 100644 index 000000000000..7c4c2870986d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowEndpointRestOperations.cs @@ -0,0 +1,513 @@ +// 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.IoTOperations.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + internal partial class DataflowEndpointRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of DataflowEndpointRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public DataflowEndpointRestOperations(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 ?? "2024-08-15-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowEndpointName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowEndpoints/", false); + uri.AppendPath(dataflowEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string instanceName, string dataflowEndpointName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowEndpoints/", false); + uri.AppendPath(dataflowEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a DataflowEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowEndpoint 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 instanceName, string dataflowEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DataflowEndpointResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DataflowEndpointResourceData.DeserializeDataflowEndpointResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DataflowEndpointResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a DataflowEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowEndpoint 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 instanceName, string dataflowEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DataflowEndpointResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DataflowEndpointResourceData.DeserializeDataflowEndpointResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DataflowEndpointResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowEndpointName, DataflowEndpointResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowEndpoints/", false); + uri.AppendPath(dataflowEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string instanceName, string dataflowEndpointName, DataflowEndpointResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowEndpoints/", false); + uri.AppendPath(dataflowEndpointName, 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 DataflowEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowEndpoint 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 instanceName, string dataflowEndpointName, DataflowEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName, 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 DataflowEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowEndpoint 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 instanceName, string dataflowEndpointName, DataflowEndpointResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowEndpointName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowEndpoints/", false); + uri.AppendPath(dataflowEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string instanceName, string dataflowEndpointName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowEndpoints/", false); + uri.AppendPath(dataflowEndpointName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a DataflowEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowEndpoint 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 instanceName, string dataflowEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + 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 DataflowEndpointResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowEndpoint 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 instanceName, string dataflowEndpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + _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, string instanceName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName, string instanceName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List DataflowEndpointResource resources by InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DataflowEndpointResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DataflowEndpointResourceListResult.DeserializeDataflowEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List DataflowEndpointResource resources by InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DataflowEndpointResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DataflowEndpointResourceListResult.DeserializeDataflowEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string instanceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string instanceName) + { + 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 DataflowEndpointResource resources by InstanceResource. + /// 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. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DataflowEndpointResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DataflowEndpointResourceListResult.DeserializeDataflowEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List DataflowEndpointResource resources by InstanceResource. + /// 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. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DataflowEndpointResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DataflowEndpointResourceListResult.DeserializeDataflowEndpointResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowProfileRestOperations.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowProfileRestOperations.cs new file mode 100644 index 000000000000..71fc5cdd9f69 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowProfileRestOperations.cs @@ -0,0 +1,513 @@ +// 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.IoTOperations.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + internal partial class DataflowProfileRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of DataflowProfileRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public DataflowProfileRestOperations(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 ?? "2024-08-15-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a DataflowProfileResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile 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 instanceName, string dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DataflowProfileResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DataflowProfileResourceData.DeserializeDataflowProfileResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DataflowProfileResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a DataflowProfileResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile 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 instanceName, string dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DataflowProfileResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DataflowProfileResourceData.DeserializeDataflowProfileResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DataflowProfileResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName, DataflowProfileResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName, DataflowProfileResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, 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 DataflowProfileResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile 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 instanceName, string dataflowProfileName, DataflowProfileResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, 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 DataflowProfileResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile 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 instanceName, string dataflowProfileName, DataflowProfileResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a DataflowProfileResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile 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 instanceName, string dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + 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 DataflowProfileResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile 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 instanceName, string dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + _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, string instanceName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName, string instanceName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List DataflowProfileResource resources by InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DataflowProfileResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DataflowProfileResourceListResult.DeserializeDataflowProfileResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List DataflowProfileResource resources by InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DataflowProfileResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DataflowProfileResourceListResult.DeserializeDataflowProfileResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string instanceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string instanceName) + { + 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 DataflowProfileResource resources by InstanceResource. + /// 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. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DataflowProfileResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DataflowProfileResourceListResult.DeserializeDataflowProfileResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List DataflowProfileResource resources by InstanceResource. + /// 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. + /// Name of instance. + /// 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, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DataflowProfileResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DataflowProfileResourceListResult.DeserializeDataflowProfileResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowRestOperations.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowRestOperations.cs new file mode 100644 index 000000000000..828a4579a2e3 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/DataflowRestOperations.cs @@ -0,0 +1,549 @@ +// 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.IoTOperations.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + internal partial class DataflowRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of DataflowRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public DataflowRestOperations(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 ?? "2024-08-15-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName, string dataflowName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendPath("/dataflows/", false); + uri.AppendPath(dataflowName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName, string dataflowName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendPath("/dataflows/", false); + uri.AppendPath(dataflowName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a DataflowResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile resource. + /// Name of Instance dataflowProfile dataflow 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 instanceName, string dataflowProfileName, string dataflowName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DataflowResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DataflowResourceData.DeserializeDataflowResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DataflowResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a DataflowResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile resource. + /// Name of Instance dataflowProfile dataflow 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 instanceName, string dataflowProfileName, string dataflowName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DataflowResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DataflowResourceData.DeserializeDataflowResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DataflowResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName, string dataflowName, DataflowResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendPath("/dataflows/", false); + uri.AppendPath(dataflowName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName, string dataflowName, DataflowResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendPath("/dataflows/", false); + uri.AppendPath(dataflowName, 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 DataflowResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile resource. + /// Name of Instance dataflowProfile dataflow 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 instanceName, string dataflowProfileName, string dataflowName, DataflowResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName, 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 DataflowResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile resource. + /// Name of Instance dataflowProfile dataflow 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 instanceName, string dataflowProfileName, string dataflowName, DataflowResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName, string dataflowName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendPath("/dataflows/", false); + uri.AppendPath(dataflowName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName, string dataflowName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendPath("/dataflows/", false); + uri.AppendPath(dataflowName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a DataflowResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile resource. + /// Name of Instance dataflowProfile dataflow 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 instanceName, string dataflowProfileName, string dataflowName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + 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 DataflowResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile resource. + /// Name of Instance dataflowProfile dataflow 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 instanceName, string dataflowProfileName, string dataflowName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + _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, string instanceName, string dataflowProfileName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendPath("/dataflows", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendPath("/dataflowProfiles/", false); + uri.AppendPath(dataflowProfileName, true); + uri.AppendPath("/dataflows", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List DataflowResource resources by DataflowProfileResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile resource. + /// 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, string instanceName, string dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DataflowResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DataflowResourceListResult.DeserializeDataflowResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List DataflowResource resources by DataflowProfileResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// Name of Instance dataflowProfile resource. + /// 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, string instanceName, string dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DataflowResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DataflowResourceListResult.DeserializeDataflowResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName) + { + 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 DataflowResource resources by DataflowProfileResource. + /// 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. + /// Name of instance. + /// Name of Instance dataflowProfile resource. + /// 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, string instanceName, string dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DataflowResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DataflowResourceListResult.DeserializeDataflowResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List DataflowResource resources by DataflowProfileResource. + /// 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. + /// Name of instance. + /// Name of Instance dataflowProfile resource. + /// 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, string instanceName, string dataflowProfileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DataflowResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DataflowResourceListResult.DeserializeDataflowResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/InstanceRestOperations.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/InstanceRestOperations.cs new file mode 100644 index 000000000000..4639d5b964d2 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/InstanceRestOperations.cs @@ -0,0 +1,731 @@ +// 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.IoTOperations.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + internal partial class InstanceRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of InstanceRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public InstanceRestOperations(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 ?? "2024-08-15-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string instanceName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string instanceName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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 instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + InstanceResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = InstanceResourceData.DeserializeInstanceResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((InstanceResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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 instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, instanceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + InstanceResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = InstanceResourceData.DeserializeInstanceResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((InstanceResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, InstanceResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string instanceName, InstanceResourceData 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, 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 InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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 instanceName, InstanceResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, 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 InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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 instanceName, InstanceResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, instanceName, 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 instanceName, InstanceResourcePatch 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string instanceName, InstanceResourcePatch 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, 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 InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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 instanceName, InstanceResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, instanceName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + InstanceResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = InstanceResourceData.DeserializeInstanceResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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 instanceName, InstanceResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, instanceName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + InstanceResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = InstanceResourceData.DeserializeInstanceResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string instanceName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string instanceName) + { + 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.IoTOperations/instances/", false); + uri.AppendPath(instanceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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 instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName); + 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 InstanceResource. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of instance. + /// 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 instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, instanceName); + _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.IoTOperations/instances", 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.IoTOperations/instances", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List InstanceResource 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: + { + InstanceResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = InstanceResourceListResult.DeserializeInstanceResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List InstanceResource 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: + { + InstanceResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = InstanceResourceListResult.DeserializeInstanceResourceListResult(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.IoTOperations/instances", 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.IoTOperations/instances", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List InstanceResource 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: + { + InstanceResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = InstanceResourceListResult.DeserializeInstanceResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List InstanceResource 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: + { + InstanceResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = InstanceResourceListResult.DeserializeInstanceResourceListResult(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 InstanceResource 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: + { + InstanceResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = InstanceResourceListResult.DeserializeInstanceResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List InstanceResource 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: + { + InstanceResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = InstanceResourceListResult.DeserializeInstanceResourceListResult(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 InstanceResource 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: + { + InstanceResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = InstanceResourceListResult.DeserializeInstanceResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List InstanceResource 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: + { + InstanceResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = InstanceResourceListResult.DeserializeInstanceResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/OperationsRestOperations.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/OperationsRestOperations.cs new file mode 100644 index 000000000000..14dd2577d854 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Generated/RestOperations/OperationsRestOperations.cs @@ -0,0 +1,173 @@ +// 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.IoTOperations.Models; + +namespace Azure.ResourceManager.IoTOperations +{ + internal partial class OperationsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of OperationsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public OperationsRestOperations(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 ?? "2024-08-15-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri() + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.IoTOperations/operations", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.IoTOperations/operations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List the operations for the provider. + /// The cancellation token to use. + public async Task> ListAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List the operations for the provider. + /// The cancellation token to use. + public Response List(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink) + { + 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 the operations for the provider. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public async Task> ListNextPageAsync(string nextLink, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + + using var message = CreateListNextPageRequest(nextLink); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List the operations for the provider. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public Response ListNextPage(string nextLink, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + + using var message = CreateListNextPageRequest(nextLink); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Properties/AssemblyInfo.cs b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..67978c3ac1f0 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.ResourceManager.IoTOperations.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/tests/Azure.ResourceManager.IoTOperations.Tests.csproj b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/tests/Azure.ResourceManager.IoTOperations.Tests.csproj new file mode 100644 index 000000000000..583882085427 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/tests/Azure.ResourceManager.IoTOperations.Tests.csproj @@ -0,0 +1,12 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + diff --git a/sdk/iotoperations/Azure.ResourceManager.IoTOperations/tsp-location.yaml b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/tsp-location.yaml new file mode 100644 index 000000000000..f33d11b627b0 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IoTOperations/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/iotoperations/IoTOperations.Management +commit: a47eee316a7816f765fdf8f4f273faf0c652c8da +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/iotoperations/ci.yml b/sdk/iotoperations/ci.yml new file mode 100644 index 000000000000..64c81deb6405 --- /dev/null +++ b/sdk/iotoperations/ci.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/iotoperations + - sdk/iotoperations/ci.yml + - sdk/iotoperations/Azure.ResourceManager.IoTOperations + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/iotoperations + - sdk/iotoperations/ci.yml + - sdk/iotoperations/Azure.ResourceManager.IoTOperations + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: iotoperations + ArtifactName: packages + Artifacts: + - name: Azure.ResourceManager.IoTOperations + safeName: AzureResourceManagerIoTOperations