From cc0d53367d55d36db3e3cf991bb2f06e3124525e Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 22 Jan 2025 11:15:17 +0000 Subject: [PATCH] CodeGen from PR 32209 in Azure/azure-rest-api-specs Merge dba00b359259830af35de08f7df8d62d7a5d7f48 into acd0437204d5fcd0ccfcbe09257caec0edfc198e --- .../Azure.ResourceManager.IotOperations.sln | 56 ++ .../CHANGELOG.md | 11 + .../Directory.Build.props | 6 + .../README.md | 80 ++ .../assets.json | 7 + ...sourceManager.IotOperations.Samples.csproj | 13 + ...perationsBrokerAuthenticationCollection.cs | 301 ++++++ ...tOperationsBrokerAuthenticationResource.cs | 209 ++++ ...OperationsBrokerAuthorizationCollection.cs | 361 +++++++ ...otOperationsBrokerAuthorizationResource.cs | 266 +++++ .../Sample_IotOperationsBrokerCollection.cs | 473 +++++++++ ...e_IotOperationsBrokerListenerCollection.cs | 344 +++++++ ...ple_IotOperationsBrokerListenerResource.cs | 249 +++++ .../Sample_IotOperationsBrokerResource.cs | 377 ++++++++ .../Sample_IotOperationsDataflowCollection.cs | 580 +++++++++++ ...IotOperationsDataflowEndpointCollection.cs | 756 +++++++++++++++ ...e_IotOperationsDataflowEndpointResource.cs | 642 +++++++++++++ ..._IotOperationsDataflowProfileCollection.cs | 292 ++++++ ...le_IotOperationsDataflowProfileResource.cs | 199 ++++ .../Sample_IotOperationsDataflowResource.cs | 476 +++++++++ .../Sample_IotOperationsInstanceCollection.cs | 205 ++++ .../Sample_IotOperationsInstanceResource.cs | 114 +++ .../Sample_SubscriptionResourceExtensions.cs | 50 + ...Azure.ResourceManager.IotOperations.csproj | 8 + .../Generated/ArmIotOperationsModelFactory.cs | 299 ++++++ .../Extensions/IotOperationsExtensions.cs | 352 +++++++ .../MockableIotOperationsArmClient.cs | 133 +++ ...kableIotOperationsResourceGroupResource.cs | 105 ++ ...ckableIotOperationsSubscriptionResource.cs | 102 ++ .../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 ++ ...perationsBrokerAuthenticationCollection.cs | 493 ++++++++++ ...sBrokerAuthenticationData.Serialization.cs | 164 ++++ .../IotOperationsBrokerAuthenticationData.cs | 89 ++ ...kerAuthenticationResource.Serialization.cs | 26 + ...tOperationsBrokerAuthenticationResource.cs | 348 +++++++ ...OperationsBrokerAuthorizationCollection.cs | 493 ++++++++++ ...nsBrokerAuthorizationData.Serialization.cs | 164 ++++ .../IotOperationsBrokerAuthorizationData.cs | 89 ++ ...okerAuthorizationResource.Serialization.cs | 26 + ...otOperationsBrokerAuthorizationResource.cs | 348 +++++++ .../IotOperationsBrokerCollection.cs | 493 ++++++++++ .../IotOperationsBrokerData.Serialization.cs | 164 ++++ .../src/Generated/IotOperationsBrokerData.cs | 89 ++ .../IotOperationsBrokerListenerCollection.cs | 493 ++++++++++ ...rationsBrokerListenerData.Serialization.cs | 164 ++++ .../IotOperationsBrokerListenerData.cs | 89 ++ ...onsBrokerListenerResource.Serialization.cs | 26 + .../IotOperationsBrokerListenerResource.cs | 348 +++++++ ...tOperationsBrokerResource.Serialization.cs | 26 + .../Generated/IotOperationsBrokerResource.cs | 554 +++++++++++ .../IotOperationsDataflowCollection.cs | 493 ++++++++++ ...IotOperationsDataflowData.Serialization.cs | 164 ++++ .../Generated/IotOperationsDataflowData.cs | 89 ++ ...IotOperationsDataflowEndpointCollection.cs | 493 ++++++++++ ...tionsDataflowEndpointData.Serialization.cs | 164 ++++ .../IotOperationsDataflowEndpointData.cs | 89 ++ ...sDataflowEndpointResource.Serialization.cs | 26 + .../IotOperationsDataflowEndpointResource.cs | 347 +++++++ .../IotOperationsDataflowProfileCollection.cs | 493 ++++++++++ ...ationsDataflowProfileData.Serialization.cs | 164 ++++ .../IotOperationsDataflowProfileData.cs | 89 ++ ...nsDataflowProfileResource.Serialization.cs | 26 + .../IotOperationsDataflowProfileResource.cs | 416 ++++++++ ...perationsDataflowResource.Serialization.cs | 26 + .../IotOperationsDataflowResource.cs | 348 +++++++ .../IotOperationsInstanceCollection.cs | 494 ++++++++++ ...IotOperationsInstanceData.Serialization.cs | 205 ++++ .../Generated/IotOperationsInstanceData.cs | 96 ++ ...perationsInstanceResource.Serialization.cs | 26 + .../IotOperationsInstanceResource.cs | 906 ++++++++++++++++++ .../IotOperationsArmOperation.cs | 94 ++ .../IotOperationsArmOperationOfT.cs | 100 ++ ...ionsBrokerAuthenticationOperationSource.cs | 38 + ...tionsBrokerAuthorizationOperationSource.cs | 38 + ...OperationsBrokerListenerOperationSource.cs | 38 + .../IotOperationsBrokerOperationSource.cs | 38 + ...erationsDataflowEndpointOperationSource.cs | 38 + .../IotOperationsDataflowOperationSource.cs | 38 + ...perationsDataflowProfileOperationSource.cs | 38 + .../IotOperationsInstanceOperationSource.cs | 38 + .../Models/BlockerListenerServiceType.cs | 54 ++ .../BrokerAdvancedSettings.Serialization.cs | 163 ++++ .../Models/BrokerAdvancedSettings.cs | 73 ++ .../Models/BrokerAuthenticationMethod.cs | 54 ++ ...icationResourceListResult.Serialization.cs | 151 +++ .../BrokerAuthenticationResourceListResult.cs | 80 ++ ...erAuthenticatorCustomAuth.Serialization.cs | 126 +++ .../Models/BrokerAuthenticatorCustomAuth.cs | 81 ++ ...AuthenticatorMethodCustom.Serialization.cs | 178 ++++ .../Models/BrokerAuthenticatorMethodCustom.cs | 95 ++ ...kerAuthenticatorMethodSat.Serialization.cs | 136 +++ .../Models/BrokerAuthenticatorMethodSat.cs | 76 ++ ...erAuthenticatorMethodX509.Serialization.cs | 155 +++ .../Models/BrokerAuthenticatorMethodX509.cs | 70 ++ ...catorMethodX509Attributes.Serialization.cs | 145 +++ ...BrokerAuthenticatorMethodX509Attributes.cs | 82 ++ ...rokerAuthenticatorMethods.Serialization.cs | 171 ++++ .../Models/BrokerAuthenticatorMethods.cs | 91 ++ ...BrokerAuthorizationConfig.Serialization.cs | 158 +++ .../Models/BrokerAuthorizationConfig.cs | 70 ++ ...izationResourceListResult.Serialization.cs | 151 +++ .../BrokerAuthorizationResourceListResult.cs | 80 ++ .../BrokerAuthorizationRule.Serialization.cs | 169 ++++ .../Models/BrokerAuthorizationRule.cs | 88 ++ .../BrokerBackendChain.Serialization.cs | 149 +++ .../Generated/Models/BrokerBackendChain.cs | 82 ++ .../Models/BrokerCardinality.Serialization.cs | 134 +++ .../src/Generated/Models/BrokerCardinality.cs | 82 ++ .../BrokerClientConfig.Serialization.cs | 215 +++++ .../Generated/Models/BrokerClientConfig.cs | 85 ++ ...BrokerDiagnosticSelfCheck.Serialization.cs | 163 ++++ .../Models/BrokerDiagnosticSelfCheck.cs | 73 ++ .../BrokerDiagnosticTraces.Serialization.cs | 178 ++++ .../Models/BrokerDiagnosticTraces.cs | 77 ++ .../Models/BrokerDiagnostics.Serialization.cs | 178 ++++ .../src/Generated/Models/BrokerDiagnostics.cs | 101 ++ .../Models/BrokerFrontend.Serialization.cs | 141 +++ .../src/Generated/Models/BrokerFrontend.cs | 76 ++ .../BrokerListenerPort.Serialization.cs | 200 ++++ .../Generated/Models/BrokerListenerPort.cs | 92 ++ ...istenerResourceListResult.Serialization.cs | 151 +++ .../BrokerListenerResourceListResult.cs | 80 ++ .../Generated/Models/BrokerMemoryProfile.cs | 57 ++ .../Generated/Models/BrokerOperatorValue.cs | 57 ++ .../Generated/Models/BrokerProtocolType.cs | 51 + .../Models/BrokerResourceDefinitionMethod.cs | 54 ++ .../BrokerResourceListResult.Serialization.cs | 151 +++ .../Models/BrokerResourceListResult.cs | 80 ++ .../BrokerResourceRule.Serialization.cs | 176 ++++ .../Generated/Models/BrokerResourceRule.cs | 82 ++ .../CertManagerCertConfig.Serialization.cs | 142 +++ .../Generated/Models/CertManagerCertConfig.cs | 89 ++ ...ertManagerCertificateSpec.Serialization.cs | 196 ++++ .../Models/CertManagerCertificateSpec.cs | 95 ++ .../Generated/Models/CertManagerIssuerKind.cs | 51 + .../CertManagerIssuerRef.Serialization.cs | 142 +++ .../Generated/Models/CertManagerIssuerRef.cs | 88 ++ .../CertManagerPrivateKey.Serialization.cs | 134 +++ .../Generated/Models/CertManagerPrivateKey.cs | 78 ++ .../Models/CloudEventAttributeType.cs | 51 + .../Models/DataExplorerAuthMethod.cs | 51 + .../Models/DataLakeStorageAuthMethod.cs | 54 ++ ...ltInTransformationDataset.Serialization.cs | 183 ++++ .../DataflowBuiltInTransformationDataset.cs | 95 ++ ...iltInTransformationFilter.Serialization.cs | 170 ++++ .../DataflowBuiltInTransformationFilter.cs | 91 ++ ...wBuiltInTransformationMap.Serialization.cs | 187 ++++ .../DataflowBuiltInTransformationMap.cs | 95 ++ ...tInTransformationSettings.Serialization.cs | 225 +++++ .../DataflowBuiltInTransformationSettings.cs | 84 ++ ...tinationOperationSettings.Serialization.cs | 134 +++ .../DataflowDestinationOperationSettings.cs | 82 ++ ...AuthenticationAccessToken.Serialization.cs | 126 +++ ...taflowEndpointAuthenticationAccessToken.cs | 75 ++ ...ndpointAuthenticationSasl.Serialization.cs | 134 +++ .../DataflowEndpointAuthenticationSasl.cs | 81 ++ .../DataflowEndpointAuthenticationSaslType.cs | 54 ++ ...cationServiceAccountToken.Serialization.cs | 126 +++ ...dpointAuthenticationServiceAccountToken.cs | 75 ++ ...emAssignedManagedIdentity.Serialization.cs | 129 +++ ...enticationSystemAssignedManagedIdentity.cs | 65 ++ ...erAssignedManagedIdentity.Serialization.cs | 145 +++ ...thenticationUserAssignedManagedIdentity.cs | 86 ++ ...ndpointAuthenticationX509.Serialization.cs | 126 +++ .../DataflowEndpointAuthenticationX509.cs | 75 ++ ...aflowEndpointDataExplorer.Serialization.cs | 157 +++ .../Models/DataflowEndpointDataExplorer.cs | 93 ++ ...ataExplorerAuthentication.Serialization.cs | 156 +++ ...aflowEndpointDataExplorerAuthentication.cs | 92 ++ ...owEndpointDataLakeStorage.Serialization.cs | 149 +++ .../Models/DataflowEndpointDataLakeStorage.cs | 86 ++ ...LakeStorageAuthentication.Serialization.cs | 171 ++++ ...owEndpointDataLakeStorageAuthentication.cs | 103 ++ ...flowEndpointFabricOneLake.Serialization.cs | 171 ++++ .../Models/DataflowEndpointFabricOneLake.cs | 99 ++ ...bricOneLakeAuthentication.Serialization.cs | 156 +++ ...flowEndpointFabricOneLakeAuthentication.cs | 92 ++ ...ndpointFabricOneLakeNames.Serialization.cs | 134 +++ .../DataflowEndpointFabricOneLakeNames.cs | 82 ++ .../Models/DataflowEndpointFabricPathType.cs | 51 + .../DataflowEndpointKafka.Serialization.cs | 261 +++++ .../Generated/Models/DataflowEndpointKafka.cs | 114 +++ .../Models/DataflowEndpointKafkaAck.cs | 54 ++ ...dpointKafkaAuthentication.Serialization.cs | 192 ++++ .../DataflowEndpointKafkaAuthentication.cs | 106 ++ ...flowEndpointKafkaBatching.Serialization.cs | 178 ++++ .../Models/DataflowEndpointKafkaBatching.cs | 77 ++ .../DataflowEndpointKafkaCompression.cs | 57 ++ .../DataflowEndpointKafkaPartitionStrategy.cs | 57 ++ ...aflowEndpointLocalStorage.Serialization.cs | 126 +++ .../Models/DataflowEndpointLocalStorage.cs | 75 ++ .../DataflowEndpointMqtt.Serialization.cs | 280 ++++++ .../Generated/Models/DataflowEndpointMqtt.cs | 115 +++ ...ndpointMqttAuthentication.Serialization.cs | 192 ++++ .../DataflowEndpointMqttAuthentication.cs | 113 +++ ...ndpointResourceListResult.Serialization.cs | 151 +++ .../DataflowEndpointResourceListResult.cs | 80 ++ .../Generated/Models/DataflowEndpointType.cs | 63 ++ .../Generated/Models/DataflowFilterType.cs | 48 + .../Generated/Models/DataflowMappingType.cs | 60 ++ ...taflowOperationProperties.Serialization.cs | 188 ++++ .../Models/DataflowOperationProperties.cs | 88 ++ .../Generated/Models/DataflowOperationType.cs | 54 ++ ...ProfileResourceListResult.Serialization.cs | 151 +++ .../DataflowProfileResourceListResult.cs | 80 ++ ...ataflowResourceListResult.Serialization.cs | 151 +++ .../Models/DataflowResourceListResult.cs | 80 ++ ...owSourceOperationSettings.Serialization.cs | 187 ++++ .../Models/DataflowSourceOperationSettings.cs | 95 ++ .../DataflowSourceSerializationFormat.cs | 48 + .../DiagnosticSelfTracing.Serialization.cs | 148 +++ .../Generated/Models/DiagnosticSelfTracing.cs | 69 ++ .../Models/DiagnosticsLogs.Serialization.cs | 129 +++ .../src/Generated/Models/DiagnosticsLogs.cs | 65 ++ .../DiskBackedMessageBuffer.Serialization.cs | 156 +++ .../Models/DiskBackedMessageBuffer.cs | 83 ++ .../Models/FabricOneLakeAuthMethod.cs | 51 + .../GenerateResourceLimits.Serialization.cs | 133 +++ .../Models/GenerateResourceLimits.cs | 65 ++ ...nstanceResourceListResult.Serialization.cs | 151 +++ .../Models/InstanceResourceListResult.cs | 80 ++ ...tOperationsBatchingConfig.Serialization.cs | 148 +++ .../Models/IotOperationsBatchingConfig.cs | 69 ++ ...rAuthenticationProperties.Serialization.cs | 151 +++ ...perationsBrokerAuthenticationProperties.cs | 80 ++ ...erAuthorizationProperties.Serialization.cs | 141 +++ ...OperationsBrokerAuthorizationProperties.cs | 79 ++ ...sBrokerListenerProperties.Serialization.cs | 177 ++++ .../IotOperationsBrokerListenerProperties.cs | 88 ++ ...perationsBrokerProperties.Serialization.cs | 231 +++++ .../Models/IotOperationsBrokerProperties.cs | 101 ++ ...ataflowEndpointProperties.Serialization.cs | 240 +++++ ...IotOperationsDataflowEndpointProperties.cs | 107 +++ ...DataflowProfileProperties.Serialization.cs | 163 ++++ .../IotOperationsDataflowProfileProperties.cs | 73 ++ ...rationsDataflowProperties.Serialization.cs | 166 ++++ .../Models/IotOperationsDataflowProperties.cs | 84 ++ ...perationsExtendedLocation.Serialization.cs | 134 +++ .../Models/IotOperationsExtendedLocation.cs | 81 ++ .../IotOperationsExtendedLocationType.cs | 48 + ...otOperationsInstancePatch.Serialization.cs | 162 ++++ .../Models/IotOperationsInstancePatch.cs | 71 ++ ...rationsInstanceProperties.Serialization.cs | 163 ++++ .../Models/IotOperationsInstanceProperties.cs | 94 ++ .../IotOperationsMetrics.Serialization.cs | 133 +++ .../Generated/Models/IotOperationsMetrics.cs | 65 ++ .../Models/IotOperationsOperationalMode.cs | 51 + .../Models/IotOperationsProvisioningState.cs | 66 ++ ...otOperationsTlsProperties.Serialization.cs | 144 +++ .../Models/IotOperationsTlsProperties.cs | 69 ++ .../src/Generated/Models/KafkaAuthMethod.cs | 60 ++ .../KubernetesReference.Serialization.cs | 156 +++ .../Generated/Models/KubernetesReference.cs | 90 ++ .../LocalKubernetesReference.Serialization.cs | 145 +++ .../Models/LocalKubernetesReference.cs | 86 ++ .../src/Generated/Models/MqttAuthMethod.cs | 60 ++ .../src/Generated/Models/MqttRetainType.cs | 51 + .../Models/PrincipalConfig.Serialization.cs | 216 +++++ .../src/Generated/Models/PrincipalConfig.cs | 76 ++ .../Generated/Models/PrivateKeyAlgorithm.cs | 66 ++ .../Models/PrivateKeyRotationPolicy.cs | 51 + .../ProfileDiagnostics.Serialization.cs | 148 +++ .../Generated/Models/ProfileDiagnostics.cs | 92 ++ .../Models/SanForCert.Serialization.cs | 154 +++ .../src/Generated/Models/SanForCert.cs | 83 ++ .../Models/SchemaRegistryRef.Serialization.cs | 126 +++ .../src/Generated/Models/SchemaRegistryRef.cs | 76 ++ .../StateStoreResourceDefinitionMethod.cs | 54 ++ .../Models/StateStoreResourceKeyType.cs | 54 ++ .../StateStoreResourceRule.Serialization.cs | 152 +++ .../Models/StateStoreResourceRule.cs | 88 ++ .../Models/SubscriberMessageDropStrategy.cs | 51 + .../SubscriberQueueLimit.Serialization.cs | 148 +++ .../Generated/Models/SubscriberQueueLimit.cs | 69 ++ .../Models/TlsCertMethod.Serialization.cs | 156 +++ .../src/Generated/Models/TlsCertMethod.cs | 86 ++ .../src/Generated/Models/TlsCertMethodMode.cs | 51 + .../TransformationSerializationFormat.cs | 54 ++ ...ClaimResourceRequirements.Serialization.cs | 170 ++++ .../Models/VolumeClaimResourceRequirements.cs | 71 ++ .../Models/VolumeClaimSpec.Serialization.cs | 245 +++++ .../src/Generated/Models/VolumeClaimSpec.cs | 94 ++ .../VolumeClaimSpecSelector.Serialization.cs | 169 ++++ .../Models/VolumeClaimSpecSelector.cs | 71 ++ ...cSelectorMatchExpressions.Serialization.cs | 159 +++ ...VolumeClaimSpecSelectorMatchExpressions.cs | 86 ++ .../X509ManualCertificate.Serialization.cs | 126 +++ .../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 ++++++++++++++ .../src/Properties/AssemblyInfo.cs | 11 + ...ResourceManager.IotOperations.Tests.csproj | 8 + .../tests/IotOperationsManagementTestBase.cs | 45 + .../IotOperationsManagementTestEnvironment.cs | 11 + .../tsp-location.yaml | 4 + sdk/iotoperations/ci.mgmt.yml | 26 + sdk/resourcemanager/ci.mgmt.yml | 2 + 309 files changed, 46209 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/assets.json create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Azure.ResourceManager.IotOperations.Samples.csproj create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthenticationCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthenticationResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthorizationCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthorizationResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerListenerCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerListenerResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowEndpointCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowEndpointResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowProfileCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowProfileResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsInstanceCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsInstanceResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs 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/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/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/IotOperationsBrokerAuthenticationCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowResource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceCollection.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceData.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceData.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceResource.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceResource.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/LongRunningOperation/IotOperationsBrokerAuthenticationOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerAuthorizationOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerListenerOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowEndpointOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowProfileOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsInstanceOperationSource.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BlockerListenerServiceType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAdvancedSettings.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAdvancedSettings.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/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/BrokerAuthorizationConfig.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationConfig.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/BrokerAuthorizationRule.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationRule.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerBackendChain.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerBackendChain.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerCardinality.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerCardinality.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerClientConfig.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerClientConfig.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticSelfCheck.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticSelfCheck.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticTraces.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticTraces.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/BrokerFrontend.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerFrontend.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerListenerPort.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerListenerPort.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/BrokerOperatorValue.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/CertManagerCertConfig.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/CertManagerCertConfig.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/CloudEventAttributeType.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/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/DataflowEndpointType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowFilterType.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/DataflowOperationProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowOperationProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowOperationType.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/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/DataflowSourceSerializationFormat.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DiagnosticSelfTracing.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DiagnosticSelfTracing.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/FabricOneLakeAuthMethod.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/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/IotOperationsBatchingConfig.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBatchingConfig.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthenticationProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthenticationProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthorizationProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthorizationProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerListenerProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerListenerProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowEndpointProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowEndpointProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProfileProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProfileProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocation.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocation.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocationType.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstancePatch.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstancePatch.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstanceProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstanceProperties.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsMetrics.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsMetrics.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsOperationalMode.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsProvisioningState.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsTlsProperties.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsTlsProperties.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/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/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/PrincipalConfig.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/PrincipalConfig.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/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/SchemaRegistryRef.Serialization.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/SchemaRegistryRef.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/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/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/tests/IotOperationsManagementTestBase.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/tests/IotOperationsManagementTestEnvironment.cs create mode 100644 sdk/iotoperations/Azure.ResourceManager.IotOperations/tsp-location.yaml create mode 100644 sdk/iotoperations/ci.mgmt.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 00000000000000..0df4ff40b42076 --- /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.ResourceManager.IotOperations.Samples", "samples\Azure.ResourceManager.IotOperations.Samples.csproj", "{7A2DFF15-5746-49F4-BD0F-C6C35337088A}" +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 + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.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 00000000000000..8b33f0fedccc18 --- /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 \ No newline at end of file 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 00000000000000..63bd836ad44b77 --- /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 00000000000000..3381528275c193 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure IotOperations management client library for .NET + +**[Describe the service briefly first.]** + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Microsoft Azure IotOperations management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.IotOperations --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://learn.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ \ No newline at end of file diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/assets.json b/sdk/iotoperations/Azure.ResourceManager.IotOperations/assets.json new file mode 100644 index 00000000000000..5ead83375b3d04 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/assets.json @@ -0,0 +1,7 @@ + +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/iotoperations/Azure.ResourceManager.IotOperations", + "Tag": "" +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Azure.ResourceManager.IotOperations.Samples.csproj b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Azure.ResourceManager.IotOperations.Samples.csproj new file mode 100644 index 00000000000000..e763780a95782f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Azure.ResourceManager.IotOperations.Samples.csproj @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthenticationCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthenticationCollection.cs new file mode 100644 index 00000000000000..9f121cef186585 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthenticationCollection.cs @@ -0,0 +1,301 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsBrokerAuthenticationCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_BrokerAuthenticationCreateOrUpdateComplex() + { + // Generated from example definition: 2024-11-01/BrokerAuthentication_CreateOrUpdate_Complex.json + // this example is just showing the usage of "BrokerAuthenticationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthenticationResource + IotOperationsBrokerAuthenticationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthentications(); + + // invoke the operation + string authenticationName = "resource-name123"; + IotOperationsBrokerAuthenticationData data = new IotOperationsBrokerAuthenticationData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerAuthenticationProperties(new BrokerAuthenticatorMethods[] + { +new BrokerAuthenticatorMethods(BrokerAuthenticationMethod.ServiceAccountToken) +{ +ServiceAccountTokenAudiences = {"aio-internal"}, +}, +new BrokerAuthenticatorMethods(BrokerAuthenticationMethod.X509) +{ +X509Settings = new BrokerAuthenticatorMethodX509 +{ +AuthorizationAttributes = +{ +["root"] = new BrokerAuthenticatorMethodX509Attributes(new Dictionary +{ +["organization"] = "contoso" +}, "CN = Contoso Root CA Cert, OU = Engineering, C = US"), +["intermediate"] = new BrokerAuthenticatorMethodX509Attributes(new Dictionary +{ +["city"] = "seattle", +["foo"] = "bar" +}, "CN = Contoso Intermediate CA"), +["smart-fan"] = new BrokerAuthenticatorMethodX509Attributes(new Dictionary +{ +["building"] = "17" +}, "CN = smart-fan") +}, +TrustedClientCaCert = "my-ca", +}, +} + }), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authenticationName, data); + IotOperationsBrokerAuthenticationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_BrokerAuthenticationCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/BrokerAuthentication_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthenticationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthenticationResource + IotOperationsBrokerAuthenticationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthentications(); + + // invoke the operation + string authenticationName = "resource-name123"; + IotOperationsBrokerAuthenticationData data = new IotOperationsBrokerAuthenticationData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerAuthenticationProperties(new BrokerAuthenticatorMethods[] + { +new BrokerAuthenticatorMethods(BrokerAuthenticationMethod.Custom) +{ +CustomSettings = new BrokerAuthenticatorMethodCustom(new Uri("https://www.example.com")) +{ +X509SecretRef = "secret-name", +CaCertConfigMap = "pdecudefqyolvncbus", +Headers = +{ +["key8518"] = "bwityjy" +}, +}, +ServiceAccountTokenAudiences = {"jqyhyqatuydg"}, +X509Settings = new BrokerAuthenticatorMethodX509 +{ +AuthorizationAttributes = +{ +["key3384"] = new BrokerAuthenticatorMethodX509Attributes(new Dictionary +{ +["key186"] = "ucpajramsz" +}, "jpgwctfeixitptfgfnqhua") +}, +TrustedClientCaCert = "vlctsqddl", +}, +} + }), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authenticationName, data); + IotOperationsBrokerAuthenticationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_BrokerAuthenticationGet() + { + // Generated from example definition: 2024-11-01/BrokerAuthentication_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthenticationResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthenticationResource + IotOperationsBrokerAuthenticationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthentications(); + + // invoke the operation + string authenticationName = "resource-name123"; + IotOperationsBrokerAuthenticationResource result = await collection.GetAsync(authenticationName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_BrokerAuthenticationListByResourceGroup() + { + // Generated from example definition: 2024-11-01/BrokerAuthentication_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthenticationResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthenticationResource + IotOperationsBrokerAuthenticationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthentications(); + + // invoke the operation and iterate over the result + await foreach (IotOperationsBrokerAuthenticationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerAuthenticationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_BrokerAuthenticationGet() + { + // Generated from example definition: 2024-11-01/BrokerAuthentication_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthenticationResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthenticationResource + IotOperationsBrokerAuthenticationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthentications(); + + // invoke the operation + string authenticationName = "resource-name123"; + bool result = await collection.ExistsAsync(authenticationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_BrokerAuthenticationGet() + { + // Generated from example definition: 2024-11-01/BrokerAuthentication_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthenticationResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthenticationResource + IotOperationsBrokerAuthenticationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthentications(); + + // invoke the operation + string authenticationName = "resource-name123"; + NullableResponse response = await collection.GetIfExistsAsync(authenticationName); + IotOperationsBrokerAuthenticationResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthenticationResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthenticationResource.cs new file mode 100644 index 00000000000000..6058e48bf4304f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthenticationResource.cs @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsBrokerAuthenticationResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_BrokerAuthenticationGet() + { + // Generated from example definition: 2024-11-01/BrokerAuthentication_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthenticationResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerAuthenticationResource created on azure + // for more information of creating IotOperationsBrokerAuthenticationResource, please refer to the document of IotOperationsBrokerAuthenticationResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string authenticationName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerAuthenticationResourceId = IotOperationsBrokerAuthenticationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, authenticationName); + IotOperationsBrokerAuthenticationResource iotOperationsBrokerAuthentication = client.GetIotOperationsBrokerAuthenticationResource(iotOperationsBrokerAuthenticationResourceId); + + // invoke the operation + IotOperationsBrokerAuthenticationResource result = await iotOperationsBrokerAuthentication.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_BrokerAuthenticationDelete() + { + // Generated from example definition: 2024-11-01/BrokerAuthentication_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthenticationResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerAuthenticationResource created on azure + // for more information of creating IotOperationsBrokerAuthenticationResource, please refer to the document of IotOperationsBrokerAuthenticationResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string authenticationName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerAuthenticationResourceId = IotOperationsBrokerAuthenticationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, authenticationName); + IotOperationsBrokerAuthenticationResource iotOperationsBrokerAuthentication = client.GetIotOperationsBrokerAuthenticationResource(iotOperationsBrokerAuthenticationResourceId); + + // invoke the operation + await iotOperationsBrokerAuthentication.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_BrokerAuthenticationCreateOrUpdateComplex() + { + // Generated from example definition: 2024-11-01/BrokerAuthentication_CreateOrUpdate_Complex.json + // this example is just showing the usage of "BrokerAuthenticationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerAuthenticationResource created on azure + // for more information of creating IotOperationsBrokerAuthenticationResource, please refer to the document of IotOperationsBrokerAuthenticationResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string authenticationName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerAuthenticationResourceId = IotOperationsBrokerAuthenticationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, authenticationName); + IotOperationsBrokerAuthenticationResource iotOperationsBrokerAuthentication = client.GetIotOperationsBrokerAuthenticationResource(iotOperationsBrokerAuthenticationResourceId); + + // invoke the operation + IotOperationsBrokerAuthenticationData data = new IotOperationsBrokerAuthenticationData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerAuthenticationProperties(new BrokerAuthenticatorMethods[] + { +new BrokerAuthenticatorMethods(BrokerAuthenticationMethod.ServiceAccountToken) +{ +ServiceAccountTokenAudiences = {"aio-internal"}, +}, +new BrokerAuthenticatorMethods(BrokerAuthenticationMethod.X509) +{ +X509Settings = new BrokerAuthenticatorMethodX509 +{ +AuthorizationAttributes = +{ +["root"] = new BrokerAuthenticatorMethodX509Attributes(new Dictionary +{ +["organization"] = "contoso" +}, "CN = Contoso Root CA Cert, OU = Engineering, C = US"), +["intermediate"] = new BrokerAuthenticatorMethodX509Attributes(new Dictionary +{ +["city"] = "seattle", +["foo"] = "bar" +}, "CN = Contoso Intermediate CA"), +["smart-fan"] = new BrokerAuthenticatorMethodX509Attributes(new Dictionary +{ +["building"] = "17" +}, "CN = smart-fan") +}, +TrustedClientCaCert = "my-ca", +}, +} + }), + }; + ArmOperation lro = await iotOperationsBrokerAuthentication.UpdateAsync(WaitUntil.Completed, data); + IotOperationsBrokerAuthenticationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_BrokerAuthenticationCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/BrokerAuthentication_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthenticationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerAuthenticationResource created on azure + // for more information of creating IotOperationsBrokerAuthenticationResource, please refer to the document of IotOperationsBrokerAuthenticationResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string authenticationName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerAuthenticationResourceId = IotOperationsBrokerAuthenticationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, authenticationName); + IotOperationsBrokerAuthenticationResource iotOperationsBrokerAuthentication = client.GetIotOperationsBrokerAuthenticationResource(iotOperationsBrokerAuthenticationResourceId); + + // invoke the operation + IotOperationsBrokerAuthenticationData data = new IotOperationsBrokerAuthenticationData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerAuthenticationProperties(new BrokerAuthenticatorMethods[] + { +new BrokerAuthenticatorMethods(BrokerAuthenticationMethod.Custom) +{ +CustomSettings = new BrokerAuthenticatorMethodCustom(new Uri("https://www.example.com")) +{ +X509SecretRef = "secret-name", +CaCertConfigMap = "pdecudefqyolvncbus", +Headers = +{ +["key8518"] = "bwityjy" +}, +}, +ServiceAccountTokenAudiences = {"jqyhyqatuydg"}, +X509Settings = new BrokerAuthenticatorMethodX509 +{ +AuthorizationAttributes = +{ +["key3384"] = new BrokerAuthenticatorMethodX509Attributes(new Dictionary +{ +["key186"] = "ucpajramsz" +}, "jpgwctfeixitptfgfnqhua") +}, +TrustedClientCaCert = "vlctsqddl", +}, +} + }), + }; + ArmOperation lro = await iotOperationsBrokerAuthentication.UpdateAsync(WaitUntil.Completed, data); + IotOperationsBrokerAuthenticationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthorizationCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthorizationCollection.cs new file mode 100644 index 00000000000000..88a3e06aac5ea0 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthorizationCollection.cs @@ -0,0 +1,361 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsBrokerAuthorizationCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_BrokerAuthorizationCreateOrUpdateComplex() + { + // Generated from example definition: 2024-11-01/BrokerAuthorization_CreateOrUpdate_Complex.json + // this example is just showing the usage of "BrokerAuthorizationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthorizationResource + IotOperationsBrokerAuthorizationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthorizations(); + + // invoke the operation + string authorizationName = "resource-name123"; + IotOperationsBrokerAuthorizationData data = new IotOperationsBrokerAuthorizationData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerAuthorizationProperties(new BrokerAuthorizationConfig + { + Cache = IotOperationsOperationalMode.Enabled, + Rules = {new BrokerAuthorizationRule(new BrokerResourceRule[] +{ +new BrokerResourceRule(BrokerResourceDefinitionMethod.Connect) +{ +ClientIds = {"{principal.attributes.building}*"}, +}, +new BrokerResourceRule(BrokerResourceDefinitionMethod.Publish) +{ +Topics = {"sensors/{principal.attributes.building}/{principal.clientId}/telemetry/*"}, +}, +new BrokerResourceRule(BrokerResourceDefinitionMethod.Subscribe) +{ +Topics = {"commands/{principal.attributes.organization}"}, +} +}, new PrincipalConfig +{ +Attributes = { +{ +["building"] = "17", +["organization"] = "contoso" +}}, +Usernames = {"temperature-sensor", "humidity-sensor"}, +}) + { + StateStoreResources = { new StateStoreResourceRule(StateStoreResourceKeyType.Pattern, new string[] { "myreadkey", "myotherkey?", "mynumerickeysuffix[0-9]", "clients:{principal.clientId}:*" }, StateStoreResourceDefinitionMethod.Read), new StateStoreResourceRule(StateStoreResourceKeyType.Binary, new string[] { "MTE2IDEwMSAxMTUgMTE2" }, StateStoreResourceDefinitionMethod.ReadWrite) }, + } + }, + }), +}; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationName, data); + IotOperationsBrokerAuthorizationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); +} + +[Test] +[Ignore("Only validating compilation of examples")] +public async Task CreateOrUpdate_BrokerAuthorizationCreateOrUpdate() +{ + // Generated from example definition: 2024-11-01/BrokerAuthorization_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthorizationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + Azure.ResourceManager.ArmClient client = new Azure.ResourceManager.ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = Azure.ResourceManager.IotOperations.IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + Azure.ResourceManager.IotOperations.IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthorizationResource + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthorizations(); + + // invoke the operation + string authorizationName = "resource-name123"; + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData data = new Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerAuthorizationProperties(new BrokerAuthorizationConfig + { + Cache = IotOperationsOperationalMode.Enabled, + Rules = {new BrokerAuthorizationRule(new BrokerResourceRule[] +{ +new BrokerResourceRule(BrokerResourceDefinitionMethod.Connect) +{ +ClientIds = {"nlc"}, +Topics = {"wvuca"}, +} +}, new PrincipalConfig +{ +Attributes = { +{ +["key5526"] = "nydhzdhbldygqcn" +}}, +ClientIds = {"smopeaeddsygz"}, +Usernames = {"iozngyqndrteikszkbasinzdjtm"}, +}) + { + StateStoreResources = { new StateStoreResourceRule(StateStoreResourceKeyType.Pattern, new string[] { "tkounsqtwvzyaklxjqoerpu" }, StateStoreResourceDefinitionMethod.Read) }, + } + }, +}), +}; +Azure.ResourceManager.ArmOperation lro = await collection.CreateOrUpdateAsync(Azure.WaitUntil.Completed, authorizationName, data); +Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationResource result = lro.Value; + +// the variable result is a resource, you could call other operations on this instance as well +// but just for demo, we get its data from this resource instance +Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData resourceData = result.Data; +// for demo we just print out the id +Console.WriteLine($"Succeeded on id: {resourceData.Id}"); +} + +[Test] +[Ignore("Only validating compilation of examples")] +public async Task CreateOrUpdate_BrokerAuthorizationCreateOrUpdateSimple() +{ + // Generated from example definition: 2024-11-01/BrokerAuthorization_CreateOrUpdate_Simple.json + // this example is just showing the usage of "BrokerAuthorizationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + Azure.ResourceManager.ArmClient client = new Azure.ResourceManager.ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = Azure.ResourceManager.IotOperations.IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + Azure.ResourceManager.IotOperations.IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthorizationResource + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthorizations(); + + // invoke the operation + string authorizationName = "resource-name123"; + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData data = new Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerAuthorizationProperties(new BrokerAuthorizationConfig + { + Cache = IotOperationsOperationalMode.Enabled, + Rules = {new BrokerAuthorizationRule(new BrokerResourceRule[] +{ +new BrokerResourceRule(BrokerResourceDefinitionMethod.Connect), +new BrokerResourceRule(BrokerResourceDefinitionMethod.Subscribe) +{ +Topics = {"topic", "topic/with/wildcard/#"}, +} +}, new PrincipalConfig +{ +Attributes = { +{ +["floor"] = "floor1", +["site"] = "site1" +}}, +ClientIds = {"my-client-id"}, +}) + { + StateStoreResources = { new StateStoreResourceRule(StateStoreResourceKeyType.Pattern, new string[] { "*" }, StateStoreResourceDefinitionMethod.ReadWrite) }, + } + }, +}), +}; +Azure.ResourceManager.ArmOperation lro = await collection.CreateOrUpdateAsync(Azure.WaitUntil.Completed, authorizationName, data); +Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationResource result = lro.Value; + +// the variable result is a resource, you could call other operations on this instance as well +// but just for demo, we get its data from this resource instance +Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData resourceData = result.Data; +// for demo we just print out the id +Console.WriteLine($"Succeeded on id: {resourceData.Id}"); +} + +[Test] +[Ignore("Only validating compilation of examples")] +public async Task Get_BrokerAuthorizationGet() +{ + // Generated from example definition: 2024-11-01/BrokerAuthorization_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthorizationResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + Azure.ResourceManager.ArmClient client = new Azure.ResourceManager.ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = Azure.ResourceManager.IotOperations.IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + Azure.ResourceManager.IotOperations.IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthorizationResource + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthorizations(); + + // invoke the operation + string authorizationName = "resource-name123"; + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationResource result = await collection.GetAsync(authorizationName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); +} + +[Test] +[Ignore("Only validating compilation of examples")] +public async Task GetAll_BrokerAuthorizationListByResourceGroup() +{ + // Generated from example definition: 2024-11-01/BrokerAuthorization_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthorizationResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + Azure.ResourceManager.ArmClient client = new Azure.ResourceManager.ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = Azure.ResourceManager.IotOperations.IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + Azure.ResourceManager.IotOperations.IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthorizationResource + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthorizations(); + + // invoke the operation and iterate over the result + await foreach (Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); +} + +[Test] +[Ignore("Only validating compilation of examples")] +public async Task Exists_BrokerAuthorizationGet() +{ + // Generated from example definition: 2024-11-01/BrokerAuthorization_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthorizationResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + Azure.ResourceManager.ArmClient client = new Azure.ResourceManager.ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = Azure.ResourceManager.IotOperations.IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + Azure.ResourceManager.IotOperations.IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthorizationResource + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthorizations(); + + // invoke the operation + string authorizationName = "resource-name123"; + bool result = await collection.ExistsAsync(authorizationName); + + Console.WriteLine($"Succeeded: {result}"); +} + +[Test] +[Ignore("Only validating compilation of examples")] +public async Task GetIfExists_BrokerAuthorizationGet() +{ + // Generated from example definition: 2024-11-01/BrokerAuthorization_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthorizationResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + Azure.ResourceManager.ArmClient client = new Azure.ResourceManager.ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = Azure.ResourceManager.IotOperations.IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + Azure.ResourceManager.IotOperations.IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerAuthorizationResource + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationCollection collection = iotOperationsBroker.GetIotOperationsBrokerAuthorizations(); + + // invoke the operation + string authorizationName = "resource-name123"; + Azure.NullableResponse response = await collection.GetIfExistsAsync(authorizationName); + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } +} +} +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthorizationResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthorizationResource.cs new file mode 100644 index 00000000000000..cca43ba7b59931 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerAuthorizationResource.cs @@ -0,0 +1,266 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsBrokerAuthorizationResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_BrokerAuthorizationGet() + { + // Generated from example definition: 2024-11-01/BrokerAuthorization_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthorizationResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerAuthorizationResource created on azure + // for more information of creating IotOperationsBrokerAuthorizationResource, please refer to the document of IotOperationsBrokerAuthorizationResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string authorizationName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerAuthorizationResourceId = IotOperationsBrokerAuthorizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, authorizationName); + IotOperationsBrokerAuthorizationResource iotOperationsBrokerAuthorization = client.GetIotOperationsBrokerAuthorizationResource(iotOperationsBrokerAuthorizationResourceId); + + // invoke the operation + IotOperationsBrokerAuthorizationResource result = await iotOperationsBrokerAuthorization.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_BrokerAuthorizationDelete() + { + // Generated from example definition: 2024-11-01/BrokerAuthorization_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthorizationResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerAuthorizationResource created on azure + // for more information of creating IotOperationsBrokerAuthorizationResource, please refer to the document of IotOperationsBrokerAuthorizationResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string authorizationName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerAuthorizationResourceId = IotOperationsBrokerAuthorizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, authorizationName); + IotOperationsBrokerAuthorizationResource iotOperationsBrokerAuthorization = client.GetIotOperationsBrokerAuthorizationResource(iotOperationsBrokerAuthorizationResourceId); + + // invoke the operation + await iotOperationsBrokerAuthorization.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_BrokerAuthorizationCreateOrUpdateComplex() + { + // Generated from example definition: 2024-11-01/BrokerAuthorization_CreateOrUpdate_Complex.json + // this example is just showing the usage of "BrokerAuthorizationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerAuthorizationResource created on azure + // for more information of creating IotOperationsBrokerAuthorizationResource, please refer to the document of IotOperationsBrokerAuthorizationResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string authorizationName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerAuthorizationResourceId = IotOperationsBrokerAuthorizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, authorizationName); + IotOperationsBrokerAuthorizationResource iotOperationsBrokerAuthorization = client.GetIotOperationsBrokerAuthorizationResource(iotOperationsBrokerAuthorizationResourceId); + + // invoke the operation + IotOperationsBrokerAuthorizationData data = new IotOperationsBrokerAuthorizationData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerAuthorizationProperties(new BrokerAuthorizationConfig + { + Cache = IotOperationsOperationalMode.Enabled, + Rules = {new BrokerAuthorizationRule(new BrokerResourceRule[] +{ +new BrokerResourceRule(BrokerResourceDefinitionMethod.Connect) +{ +ClientIds = {"{principal.attributes.building}*"}, +}, +new BrokerResourceRule(BrokerResourceDefinitionMethod.Publish) +{ +Topics = {"sensors/{principal.attributes.building}/{principal.clientId}/telemetry/*"}, +}, +new BrokerResourceRule(BrokerResourceDefinitionMethod.Subscribe) +{ +Topics = {"commands/{principal.attributes.organization}"}, +} +}, new PrincipalConfig +{ +Attributes = { +{ +["building"] = "17", +["organization"] = "contoso" +}}, +Usernames = {"temperature-sensor", "humidity-sensor"}, +}) + { + StateStoreResources = { new StateStoreResourceRule(StateStoreResourceKeyType.Pattern, new string[] { "myreadkey", "myotherkey?", "mynumerickeysuffix[0-9]", "clients:{principal.clientId}:*" }, StateStoreResourceDefinitionMethod.Read), new StateStoreResourceRule(StateStoreResourceKeyType.Binary, new string[] { "MTE2IDEwMSAxMTUgMTE2" }, StateStoreResourceDefinitionMethod.ReadWrite) }, + } + }, + }), +}; + ArmOperation lro = await iotOperationsBrokerAuthorization.UpdateAsync(WaitUntil.Completed, data); + IotOperationsBrokerAuthorizationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); +} + +[Test] +[Ignore("Only validating compilation of examples")] +public async Task Update_BrokerAuthorizationCreateOrUpdate() +{ + // Generated from example definition: 2024-11-01/BrokerAuthorization_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerAuthorizationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + Azure.ResourceManager.ArmClient client = new Azure.ResourceManager.ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerAuthorizationResource created on azure + // for more information of creating IotOperationsBrokerAuthorizationResource, please refer to the document of IotOperationsBrokerAuthorizationResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string authorizationName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerAuthorizationResourceId = Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, authorizationName); + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationResource iotOperationsBrokerAuthorization = client.GetIotOperationsBrokerAuthorizationResource(iotOperationsBrokerAuthorizationResourceId); + + // invoke the operation + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData data = new Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerAuthorizationProperties(new BrokerAuthorizationConfig + { + Cache = IotOperationsOperationalMode.Enabled, + Rules = {new BrokerAuthorizationRule(new BrokerResourceRule[] +{ +new BrokerResourceRule(BrokerResourceDefinitionMethod.Connect) +{ +ClientIds = {"nlc"}, +Topics = {"wvuca"}, +} +}, new PrincipalConfig +{ +Attributes = { +{ +["key5526"] = "nydhzdhbldygqcn" +}}, +ClientIds = {"smopeaeddsygz"}, +Usernames = {"iozngyqndrteikszkbasinzdjtm"}, +}) + { + StateStoreResources = { new StateStoreResourceRule(StateStoreResourceKeyType.Pattern, new string[] { "tkounsqtwvzyaklxjqoerpu" }, StateStoreResourceDefinitionMethod.Read) }, + } + }, +}), +}; +Azure.ResourceManager.ArmOperation lro = await iotOperationsBrokerAuthorization.UpdateAsync(Azure.WaitUntil.Completed, data); +Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationResource result = lro.Value; + +// the variable result is a resource, you could call other operations on this instance as well +// but just for demo, we get its data from this resource instance +Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData resourceData = result.Data; +// for demo we just print out the id +Console.WriteLine($"Succeeded on id: {resourceData.Id}"); +} + +[Test] +[Ignore("Only validating compilation of examples")] +public async Task Update_BrokerAuthorizationCreateOrUpdateSimple() +{ + // Generated from example definition: 2024-11-01/BrokerAuthorization_CreateOrUpdate_Simple.json + // this example is just showing the usage of "BrokerAuthorizationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + Azure.ResourceManager.ArmClient client = new Azure.ResourceManager.ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerAuthorizationResource created on azure + // for more information of creating IotOperationsBrokerAuthorizationResource, please refer to the document of IotOperationsBrokerAuthorizationResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string authorizationName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerAuthorizationResourceId = Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, authorizationName); + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationResource iotOperationsBrokerAuthorization = client.GetIotOperationsBrokerAuthorizationResource(iotOperationsBrokerAuthorizationResourceId); + + // invoke the operation + Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData data = new Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerAuthorizationProperties(new BrokerAuthorizationConfig + { + Cache = IotOperationsOperationalMode.Enabled, + Rules = {new BrokerAuthorizationRule(new BrokerResourceRule[] +{ +new BrokerResourceRule(BrokerResourceDefinitionMethod.Connect), +new BrokerResourceRule(BrokerResourceDefinitionMethod.Subscribe) +{ +Topics = {"topic", "topic/with/wildcard/#"}, +} +}, new PrincipalConfig +{ +Attributes = { +{ +["floor"] = "floor1", +["site"] = "site1" +}}, +ClientIds = {"my-client-id"}, +}) + { + StateStoreResources = { new StateStoreResourceRule(StateStoreResourceKeyType.Pattern, new string[] { "*" }, StateStoreResourceDefinitionMethod.ReadWrite) }, + } + }, +}), +}; +Azure.ResourceManager.ArmOperation lro = await iotOperationsBrokerAuthorization.UpdateAsync(Azure.WaitUntil.Completed, data); +Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationResource result = lro.Value; + +// the variable result is a resource, you could call other operations on this instance as well +// but just for demo, we get its data from this resource instance +Azure.ResourceManager.IotOperations.IotOperationsBrokerAuthorizationData resourceData = result.Data; +// for demo we just print out the id +Console.WriteLine($"Succeeded on id: {resourceData.Id}"); +} +} +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerCollection.cs new file mode 100644 index 00000000000000..2162fc3a56a4e5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerCollection.cs @@ -0,0 +1,473 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsBrokerCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_BrokerCreateOrUpdateComplex() + { + // Generated from example definition: 2024-11-01/Broker_CreateOrUpdate_Complex.json + // this example is just showing the usage of "BrokerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsBrokerResource + IotOperationsBrokerCollection collection = iotOperationsInstance.GetIotOperationsBrokers(); + + // invoke the operation + string brokerName = "resource-name123"; + IotOperationsBrokerData data = new IotOperationsBrokerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerProperties + { + Cardinality = new BrokerCardinality(new BrokerBackendChain(2, 2) + { + Workers = 2, + }, new BrokerFrontend(2) + { + Workers = 2, + }), + DiskBackedMessageBuffer = new DiskBackedMessageBuffer("50M"), + GenerateResourceLimitsCpu = IotOperationsOperationalMode.Enabled, + MemoryProfile = BrokerMemoryProfile.Medium, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, brokerName, data); + IotOperationsBrokerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_BrokerCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/Broker_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsBrokerResource + IotOperationsBrokerCollection collection = iotOperationsInstance.GetIotOperationsBrokers(); + + // invoke the operation + string brokerName = "resource-name123"; + IotOperationsBrokerData data = new IotOperationsBrokerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerProperties + { + Advanced = new BrokerAdvancedSettings + { + Clients = new BrokerClientConfig + { + MaxSessionExpirySeconds = 3859, + MaxMessageExpirySeconds = 3263, + MaxPacketSizeBytes = 3029, + SubscriberQueueLimit = new SubscriberQueueLimit + { + Length = 6L, + Strategy = SubscriberMessageDropStrategy.None, + }, + MaxReceiveMaximum = 2365, + MaxKeepAliveSeconds = 3744, + }, + EncryptInternalTraffic = IotOperationsOperationalMode.Enabled, + InternalCerts = new CertManagerCertConfig("bchrc", "xkafmpgjfifkwwrhkswtopdnne", new CertManagerPrivateKey(PrivateKeyAlgorithm.Ec256, PrivateKeyRotationPolicy.Always)), + }, + Cardinality = new BrokerCardinality(new BrokerBackendChain(11, 5) + { + Workers = 15, + }, new BrokerFrontend(2) + { + Workers = 6, + }), + Diagnostics = new BrokerDiagnostics + { + LogsLevel = "rnmwokumdmebpmfxxxzvvjfdywotav", + MetricsPrometheusPort = 7581, + SelfCheck = new BrokerDiagnosticSelfCheck + { + Mode = IotOperationsOperationalMode.Enabled, + IntervalSeconds = 158, + TimeoutSeconds = 14, + }, + Traces = new BrokerDiagnosticTraces + { + Mode = IotOperationsOperationalMode.Enabled, + CacheSizeMegabytes = 28, + SelfTracing = new DiagnosticSelfTracing + { + Mode = IotOperationsOperationalMode.Enabled, + IntervalSeconds = 22, + }, + SpanChannelCapacity = 1000, + }, + }, + DiskBackedMessageBuffer = new DiskBackedMessageBuffer("500M") + { + EphemeralVolumeClaimSpec = new VolumeClaimSpec + { + VolumeName = "c", + VolumeMode = "rxvpksjuuugqnqzeiprocknbn", + StorageClassName = "sseyhrjptkhrqvpdpjmornkqvon", + AccessModes = { "nuluhigrbb" }, + DataSource = new LocalKubernetesReference("wazgyb", "cwhsgxxcxsyppoefm") + { + ApiGroup = "npqapyksvvpkohujx", + }, + DataSourceRef = new KubernetesReference("odynqzekfzsnawrctaxg", "envszivbbmixbyddzg") + { + ApiGroup = "mnfnykznjjsoqpfsgdqioupt", + Namespace = "etcfzvxqd", + }, + Resources = new VolumeClaimResourceRequirements + { + Limits = +{ +["key2719"] = "hmphcrgctu" +}, + Requests = +{ +["key2909"] = "txocprnyrsgvhfrg" +}, + }, + Selector = new VolumeClaimSpecSelector + { + MatchExpressions = {new VolumeClaimSpecSelectorMatchExpressions("e", BrokerOperatorValue.In) +{ +Values = {"slmpajlywqvuyknipgztsonqyybt"}, +}}, + MatchLabels = +{ +["key6673"] = "wlngfalznwxnurzpgxomcxhbqefpr" +}, + }, + }, + PersistentVolumeClaimSpec = new VolumeClaimSpec + { + VolumeName = "c", + VolumeMode = "rxvpksjuuugqnqzeiprocknbn", + StorageClassName = "sseyhrjptkhrqvpdpjmornkqvon", + AccessModes = { "nuluhigrbb" }, + DataSource = new LocalKubernetesReference("wazgyb", "cwhsgxxcxsyppoefm") + { + ApiGroup = "npqapyksvvpkohujx", + }, + DataSourceRef = new KubernetesReference("odynqzekfzsnawrctaxg", "envszivbbmixbyddzg") + { + ApiGroup = "mnfnykznjjsoqpfsgdqioupt", + Namespace = "etcfzvxqd", + }, + Resources = new VolumeClaimResourceRequirements + { + Limits = +{ +["key2719"] = "hmphcrgctu" +}, + Requests = +{ +["key2909"] = "txocprnyrsgvhfrg" +}, + }, + Selector = new VolumeClaimSpecSelector + { + MatchExpressions = {new VolumeClaimSpecSelectorMatchExpressions("e", BrokerOperatorValue.In) +{ +Values = {"slmpajlywqvuyknipgztsonqyybt"}, +}}, + MatchLabels = +{ +["key6673"] = "wlngfalznwxnurzpgxomcxhbqefpr" +}, + }, + }, + }, + GenerateResourceLimitsCpu = IotOperationsOperationalMode.Enabled, + MemoryProfile = BrokerMemoryProfile.Tiny, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, brokerName, data); + IotOperationsBrokerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_BrokerCreateOrUpdateMinimal() + { + // Generated from example definition: 2024-11-01/Broker_CreateOrUpdate_Minimal.json + // this example is just showing the usage of "BrokerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsBrokerResource + IotOperationsBrokerCollection collection = iotOperationsInstance.GetIotOperationsBrokers(); + + // invoke the operation + string brokerName = "resource-name123"; + IotOperationsBrokerData data = new IotOperationsBrokerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerProperties + { + MemoryProfile = BrokerMemoryProfile.Tiny, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, brokerName, data); + IotOperationsBrokerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_BrokerCreateOrUpdateSimple() + { + // Generated from example definition: 2024-11-01/Broker_CreateOrUpdate_Simple.json + // this example is just showing the usage of "BrokerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsBrokerResource + IotOperationsBrokerCollection collection = iotOperationsInstance.GetIotOperationsBrokers(); + + // invoke the operation + string brokerName = "resource-name123"; + IotOperationsBrokerData data = new IotOperationsBrokerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerProperties + { + Cardinality = new BrokerCardinality(new BrokerBackendChain(2, 2) + { + Workers = 2, + }, new BrokerFrontend(2) + { + Workers = 2, + }), + GenerateResourceLimitsCpu = IotOperationsOperationalMode.Enabled, + MemoryProfile = BrokerMemoryProfile.Low, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, brokerName, data); + IotOperationsBrokerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_BrokerGet() + { + // Generated from example definition: 2024-11-01/Broker_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsBrokerResource + IotOperationsBrokerCollection collection = iotOperationsInstance.GetIotOperationsBrokers(); + + // invoke the operation + string brokerName = "resource-name123"; + IotOperationsBrokerResource result = await collection.GetAsync(brokerName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_BrokerListByResourceGroup() + { + // Generated from example definition: 2024-11-01/Broker_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsBrokerResource + IotOperationsBrokerCollection collection = iotOperationsInstance.GetIotOperationsBrokers(); + + // invoke the operation and iterate over the result + await foreach (IotOperationsBrokerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_BrokerGet() + { + // Generated from example definition: 2024-11-01/Broker_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsBrokerResource + IotOperationsBrokerCollection collection = iotOperationsInstance.GetIotOperationsBrokers(); + + // invoke the operation + string brokerName = "resource-name123"; + bool result = await collection.ExistsAsync(brokerName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_BrokerGet() + { + // Generated from example definition: 2024-11-01/Broker_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsBrokerResource + IotOperationsBrokerCollection collection = iotOperationsInstance.GetIotOperationsBrokers(); + + // invoke the operation + string brokerName = "resource-name123"; + NullableResponse response = await collection.GetIfExistsAsync(brokerName); + IotOperationsBrokerResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerListenerCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerListenerCollection.cs new file mode 100644 index 00000000000000..d0c4bf988d0a79 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerListenerCollection.cs @@ -0,0 +1,344 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsBrokerListenerCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_BrokerListenerCreateOrUpdateComplex() + { + // Generated from example definition: 2024-11-01/BrokerListener_CreateOrUpdate_Complex.json + // this example is just showing the usage of "BrokerListenerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerListenerResource + IotOperationsBrokerListenerCollection collection = iotOperationsBroker.GetIotOperationsBrokerListeners(); + + // invoke the operation + string listenerName = "resource-name123"; + IotOperationsBrokerListenerData data = new IotOperationsBrokerListenerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerListenerProperties(new BrokerListenerPort[] + { +new BrokerListenerPort(8080) +{ +AuthenticationRef = "example-authentication", +Protocol = BrokerProtocolType.WebSockets, +}, +new BrokerListenerPort(8443) +{ +AuthenticationRef = "example-authentication", +Protocol = BrokerProtocolType.WebSockets, +Tls = new TlsCertMethod(TlsCertMethodMode.Automatic) +{ +CertManagerCertificateSpec = new CertManagerCertificateSpec(new CertManagerIssuerRef("jtmuladdkpasfpoyvewekmiy", CertManagerIssuerKind.Issuer, "example-issuer")), +}, +}, +new BrokerListenerPort(1883) +{ +AuthenticationRef = "example-authentication", +}, +new BrokerListenerPort(8883) +{ +AuthenticationRef = "example-authentication", +Tls = new TlsCertMethod(TlsCertMethodMode.Manual) +{ +ManualSecretRef = "example-secret", +}, +} + }) + { + ServiceType = BlockerListenerServiceType.LoadBalancer, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, listenerName, data); + IotOperationsBrokerListenerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerListenerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_BrokerListenerCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/BrokerListener_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerListenerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerListenerResource + IotOperationsBrokerListenerCollection collection = iotOperationsBroker.GetIotOperationsBrokerListeners(); + + // invoke the operation + string listenerName = "resource-name123"; + IotOperationsBrokerListenerData data = new IotOperationsBrokerListenerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerListenerProperties(new BrokerListenerPort[] + { +new BrokerListenerPort(1268) +{ +AuthenticationRef = "tjvdroaqqy", +AuthorizationRef = "inxhvxnwswyrvt", +NodePort = 7281, +Protocol = BrokerProtocolType.Mqtt, +Tls = new TlsCertMethod(TlsCertMethodMode.Automatic) +{ +CertManagerCertificateSpec = new CertManagerCertificateSpec(new CertManagerIssuerRef("jtmuladdkpasfpoyvewekmiy", CertManagerIssuerKind.Issuer, "ocwoqpgucvjrsuudtjhb")) +{ +Duration = "qmpeffoksron", +SecretName = "oagi", +RenewBefore = "hutno", +PrivateKey = new CertManagerPrivateKey(PrivateKeyAlgorithm.Ec256, PrivateKeyRotationPolicy.Always), +San = new SanForCert(new string[]{"xhvmhrrhgfsapocjeebqtnzarlj"}, new string[]{"zbgugfzcgsmegevzktsnibyuyp"}), +}, +ManualSecretRef = "secret-name", +}, +} + }) + { + ServiceName = "tpfiszlapdpxktx", + ServiceType = BlockerListenerServiceType.ClusterIP, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, listenerName, data); + IotOperationsBrokerListenerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerListenerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_BrokerListenerCreateOrUpdateSimple() + { + // Generated from example definition: 2024-11-01/BrokerListener_CreateOrUpdate_Simple.json + // this example is just showing the usage of "BrokerListenerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerListenerResource + IotOperationsBrokerListenerCollection collection = iotOperationsBroker.GetIotOperationsBrokerListeners(); + + // invoke the operation + string listenerName = "resource-name123"; + IotOperationsBrokerListenerData data = new IotOperationsBrokerListenerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerListenerProperties(new BrokerListenerPort[] + { +new BrokerListenerPort(1883) + }), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, listenerName, data); + IotOperationsBrokerListenerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerListenerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_BrokerListenerGet() + { + // Generated from example definition: 2024-11-01/BrokerListener_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerListenerResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerListenerResource + IotOperationsBrokerListenerCollection collection = iotOperationsBroker.GetIotOperationsBrokerListeners(); + + // invoke the operation + string listenerName = "resource-name123"; + IotOperationsBrokerListenerResource result = await collection.GetAsync(listenerName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerListenerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_BrokerListenerListByResourceGroup() + { + // Generated from example definition: 2024-11-01/BrokerListener_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerListenerResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerListenerResource + IotOperationsBrokerListenerCollection collection = iotOperationsBroker.GetIotOperationsBrokerListeners(); + + // invoke the operation and iterate over the result + await foreach (IotOperationsBrokerListenerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerListenerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_BrokerListenerGet() + { + // Generated from example definition: 2024-11-01/BrokerListener_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerListenerResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerListenerResource + IotOperationsBrokerListenerCollection collection = iotOperationsBroker.GetIotOperationsBrokerListeners(); + + // invoke the operation + string listenerName = "resource-name123"; + bool result = await collection.ExistsAsync(listenerName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_BrokerListenerGet() + { + // Generated from example definition: 2024-11-01/BrokerListener_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerListenerResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // get the collection of this IotOperationsBrokerListenerResource + IotOperationsBrokerListenerCollection collection = iotOperationsBroker.GetIotOperationsBrokerListeners(); + + // invoke the operation + string listenerName = "resource-name123"; + NullableResponse response = await collection.GetIfExistsAsync(listenerName); + IotOperationsBrokerListenerResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerListenerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerListenerResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerListenerResource.cs new file mode 100644 index 00000000000000..84808b682f8fcb --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerListenerResource.cs @@ -0,0 +1,249 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsBrokerListenerResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_BrokerListenerGet() + { + // Generated from example definition: 2024-11-01/BrokerListener_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerListenerResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerListenerResource created on azure + // for more information of creating IotOperationsBrokerListenerResource, please refer to the document of IotOperationsBrokerListenerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string listenerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerListenerResourceId = IotOperationsBrokerListenerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, listenerName); + IotOperationsBrokerListenerResource iotOperationsBrokerListener = client.GetIotOperationsBrokerListenerResource(iotOperationsBrokerListenerResourceId); + + // invoke the operation + IotOperationsBrokerListenerResource result = await iotOperationsBrokerListener.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerListenerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_BrokerListenerDelete() + { + // Generated from example definition: 2024-11-01/BrokerListener_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerListenerResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerListenerResource created on azure + // for more information of creating IotOperationsBrokerListenerResource, please refer to the document of IotOperationsBrokerListenerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string listenerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerListenerResourceId = IotOperationsBrokerListenerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, listenerName); + IotOperationsBrokerListenerResource iotOperationsBrokerListener = client.GetIotOperationsBrokerListenerResource(iotOperationsBrokerListenerResourceId); + + // invoke the operation + await iotOperationsBrokerListener.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_BrokerListenerCreateOrUpdateComplex() + { + // Generated from example definition: 2024-11-01/BrokerListener_CreateOrUpdate_Complex.json + // this example is just showing the usage of "BrokerListenerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerListenerResource created on azure + // for more information of creating IotOperationsBrokerListenerResource, please refer to the document of IotOperationsBrokerListenerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string listenerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerListenerResourceId = IotOperationsBrokerListenerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, listenerName); + IotOperationsBrokerListenerResource iotOperationsBrokerListener = client.GetIotOperationsBrokerListenerResource(iotOperationsBrokerListenerResourceId); + + // invoke the operation + IotOperationsBrokerListenerData data = new IotOperationsBrokerListenerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerListenerProperties(new BrokerListenerPort[] + { +new BrokerListenerPort(8080) +{ +AuthenticationRef = "example-authentication", +Protocol = BrokerProtocolType.WebSockets, +}, +new BrokerListenerPort(8443) +{ +AuthenticationRef = "example-authentication", +Protocol = BrokerProtocolType.WebSockets, +Tls = new TlsCertMethod(TlsCertMethodMode.Automatic) +{ +CertManagerCertificateSpec = new CertManagerCertificateSpec(new CertManagerIssuerRef("jtmuladdkpasfpoyvewekmiy", CertManagerIssuerKind.Issuer, "example-issuer")), +}, +}, +new BrokerListenerPort(1883) +{ +AuthenticationRef = "example-authentication", +}, +new BrokerListenerPort(8883) +{ +AuthenticationRef = "example-authentication", +Tls = new TlsCertMethod(TlsCertMethodMode.Manual) +{ +ManualSecretRef = "example-secret", +}, +} + }) + { + ServiceType = BlockerListenerServiceType.LoadBalancer, + }, + }; + ArmOperation lro = await iotOperationsBrokerListener.UpdateAsync(WaitUntil.Completed, data); + IotOperationsBrokerListenerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerListenerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_BrokerListenerCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/BrokerListener_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerListenerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerListenerResource created on azure + // for more information of creating IotOperationsBrokerListenerResource, please refer to the document of IotOperationsBrokerListenerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string listenerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerListenerResourceId = IotOperationsBrokerListenerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, listenerName); + IotOperationsBrokerListenerResource iotOperationsBrokerListener = client.GetIotOperationsBrokerListenerResource(iotOperationsBrokerListenerResourceId); + + // invoke the operation + IotOperationsBrokerListenerData data = new IotOperationsBrokerListenerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerListenerProperties(new BrokerListenerPort[] + { +new BrokerListenerPort(1268) +{ +AuthenticationRef = "tjvdroaqqy", +AuthorizationRef = "inxhvxnwswyrvt", +NodePort = 7281, +Protocol = BrokerProtocolType.Mqtt, +Tls = new TlsCertMethod(TlsCertMethodMode.Automatic) +{ +CertManagerCertificateSpec = new CertManagerCertificateSpec(new CertManagerIssuerRef("jtmuladdkpasfpoyvewekmiy", CertManagerIssuerKind.Issuer, "ocwoqpgucvjrsuudtjhb")) +{ +Duration = "qmpeffoksron", +SecretName = "oagi", +RenewBefore = "hutno", +PrivateKey = new CertManagerPrivateKey(PrivateKeyAlgorithm.Ec256, PrivateKeyRotationPolicy.Always), +San = new SanForCert(new string[]{"xhvmhrrhgfsapocjeebqtnzarlj"}, new string[]{"zbgugfzcgsmegevzktsnibyuyp"}), +}, +ManualSecretRef = "secret-name", +}, +} + }) + { + ServiceName = "tpfiszlapdpxktx", + ServiceType = BlockerListenerServiceType.ClusterIP, + }, + }; + ArmOperation lro = await iotOperationsBrokerListener.UpdateAsync(WaitUntil.Completed, data); + IotOperationsBrokerListenerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerListenerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_BrokerListenerCreateOrUpdateSimple() + { + // Generated from example definition: 2024-11-01/BrokerListener_CreateOrUpdate_Simple.json + // this example is just showing the usage of "BrokerListenerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerListenerResource created on azure + // for more information of creating IotOperationsBrokerListenerResource, please refer to the document of IotOperationsBrokerListenerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + string listenerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerListenerResourceId = IotOperationsBrokerListenerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName, listenerName); + IotOperationsBrokerListenerResource iotOperationsBrokerListener = client.GetIotOperationsBrokerListenerResource(iotOperationsBrokerListenerResourceId); + + // invoke the operation + IotOperationsBrokerListenerData data = new IotOperationsBrokerListenerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerListenerProperties(new BrokerListenerPort[] + { +new BrokerListenerPort(1883) + }), + }; + ArmOperation lro = await iotOperationsBrokerListener.UpdateAsync(WaitUntil.Completed, data); + IotOperationsBrokerListenerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerListenerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerResource.cs new file mode 100644 index 00000000000000..47157e7c8f239a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsBrokerResource.cs @@ -0,0 +1,377 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsBrokerResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_BrokerGet() + { + // Generated from example definition: 2024-11-01/Broker_Get_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // invoke the operation + IotOperationsBrokerResource result = await iotOperationsBroker.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_BrokerDelete() + { + // Generated from example definition: 2024-11-01/Broker_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // invoke the operation + await iotOperationsBroker.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_BrokerCreateOrUpdateComplex() + { + // Generated from example definition: 2024-11-01/Broker_CreateOrUpdate_Complex.json + // this example is just showing the usage of "BrokerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // invoke the operation + IotOperationsBrokerData data = new IotOperationsBrokerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerProperties + { + Cardinality = new BrokerCardinality(new BrokerBackendChain(2, 2) + { + Workers = 2, + }, new BrokerFrontend(2) + { + Workers = 2, + }), + DiskBackedMessageBuffer = new DiskBackedMessageBuffer("50M"), + GenerateResourceLimitsCpu = IotOperationsOperationalMode.Enabled, + MemoryProfile = BrokerMemoryProfile.Medium, + }, + }; + ArmOperation lro = await iotOperationsBroker.UpdateAsync(WaitUntil.Completed, data); + IotOperationsBrokerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_BrokerCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/Broker_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "BrokerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // invoke the operation + IotOperationsBrokerData data = new IotOperationsBrokerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerProperties + { + Advanced = new BrokerAdvancedSettings + { + Clients = new BrokerClientConfig + { + MaxSessionExpirySeconds = 3859, + MaxMessageExpirySeconds = 3263, + MaxPacketSizeBytes = 3029, + SubscriberQueueLimit = new SubscriberQueueLimit + { + Length = 6L, + Strategy = SubscriberMessageDropStrategy.None, + }, + MaxReceiveMaximum = 2365, + MaxKeepAliveSeconds = 3744, + }, + EncryptInternalTraffic = IotOperationsOperationalMode.Enabled, + InternalCerts = new CertManagerCertConfig("bchrc", "xkafmpgjfifkwwrhkswtopdnne", new CertManagerPrivateKey(PrivateKeyAlgorithm.Ec256, PrivateKeyRotationPolicy.Always)), + }, + Cardinality = new BrokerCardinality(new BrokerBackendChain(11, 5) + { + Workers = 15, + }, new BrokerFrontend(2) + { + Workers = 6, + }), + Diagnostics = new BrokerDiagnostics + { + LogsLevel = "rnmwokumdmebpmfxxxzvvjfdywotav", + MetricsPrometheusPort = 7581, + SelfCheck = new BrokerDiagnosticSelfCheck + { + Mode = IotOperationsOperationalMode.Enabled, + IntervalSeconds = 158, + TimeoutSeconds = 14, + }, + Traces = new BrokerDiagnosticTraces + { + Mode = IotOperationsOperationalMode.Enabled, + CacheSizeMegabytes = 28, + SelfTracing = new DiagnosticSelfTracing + { + Mode = IotOperationsOperationalMode.Enabled, + IntervalSeconds = 22, + }, + SpanChannelCapacity = 1000, + }, + }, + DiskBackedMessageBuffer = new DiskBackedMessageBuffer("500M") + { + EphemeralVolumeClaimSpec = new VolumeClaimSpec + { + VolumeName = "c", + VolumeMode = "rxvpksjuuugqnqzeiprocknbn", + StorageClassName = "sseyhrjptkhrqvpdpjmornkqvon", + AccessModes = { "nuluhigrbb" }, + DataSource = new LocalKubernetesReference("wazgyb", "cwhsgxxcxsyppoefm") + { + ApiGroup = "npqapyksvvpkohujx", + }, + DataSourceRef = new KubernetesReference("odynqzekfzsnawrctaxg", "envszivbbmixbyddzg") + { + ApiGroup = "mnfnykznjjsoqpfsgdqioupt", + Namespace = "etcfzvxqd", + }, + Resources = new VolumeClaimResourceRequirements + { + Limits = +{ +["key2719"] = "hmphcrgctu" +}, + Requests = +{ +["key2909"] = "txocprnyrsgvhfrg" +}, + }, + Selector = new VolumeClaimSpecSelector + { + MatchExpressions = {new VolumeClaimSpecSelectorMatchExpressions("e", BrokerOperatorValue.In) +{ +Values = {"slmpajlywqvuyknipgztsonqyybt"}, +}}, + MatchLabels = +{ +["key6673"] = "wlngfalznwxnurzpgxomcxhbqefpr" +}, + }, + }, + PersistentVolumeClaimSpec = new VolumeClaimSpec + { + VolumeName = "c", + VolumeMode = "rxvpksjuuugqnqzeiprocknbn", + StorageClassName = "sseyhrjptkhrqvpdpjmornkqvon", + AccessModes = { "nuluhigrbb" }, + DataSource = new LocalKubernetesReference("wazgyb", "cwhsgxxcxsyppoefm") + { + ApiGroup = "npqapyksvvpkohujx", + }, + DataSourceRef = new KubernetesReference("odynqzekfzsnawrctaxg", "envszivbbmixbyddzg") + { + ApiGroup = "mnfnykznjjsoqpfsgdqioupt", + Namespace = "etcfzvxqd", + }, + Resources = new VolumeClaimResourceRequirements + { + Limits = +{ +["key2719"] = "hmphcrgctu" +}, + Requests = +{ +["key2909"] = "txocprnyrsgvhfrg" +}, + }, + Selector = new VolumeClaimSpecSelector + { + MatchExpressions = {new VolumeClaimSpecSelectorMatchExpressions("e", BrokerOperatorValue.In) +{ +Values = {"slmpajlywqvuyknipgztsonqyybt"}, +}}, + MatchLabels = +{ +["key6673"] = "wlngfalznwxnurzpgxomcxhbqefpr" +}, + }, + }, + }, + GenerateResourceLimitsCpu = IotOperationsOperationalMode.Enabled, + MemoryProfile = BrokerMemoryProfile.Tiny, + }, + }; + ArmOperation lro = await iotOperationsBroker.UpdateAsync(WaitUntil.Completed, data); + IotOperationsBrokerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_BrokerCreateOrUpdateMinimal() + { + // Generated from example definition: 2024-11-01/Broker_CreateOrUpdate_Minimal.json + // this example is just showing the usage of "BrokerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // invoke the operation + IotOperationsBrokerData data = new IotOperationsBrokerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerProperties + { + MemoryProfile = BrokerMemoryProfile.Tiny, + }, + }; + ArmOperation lro = await iotOperationsBroker.UpdateAsync(WaitUntil.Completed, data); + IotOperationsBrokerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_BrokerCreateOrUpdateSimple() + { + // Generated from example definition: 2024-11-01/Broker_CreateOrUpdate_Simple.json + // this example is just showing the usage of "BrokerResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsBrokerResource created on azure + // for more information of creating IotOperationsBrokerResource, please refer to the document of IotOperationsBrokerResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string brokerName = "resource-name123"; + ResourceIdentifier iotOperationsBrokerResourceId = IotOperationsBrokerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, brokerName); + IotOperationsBrokerResource iotOperationsBroker = client.GetIotOperationsBrokerResource(iotOperationsBrokerResourceId); + + // invoke the operation + IotOperationsBrokerData data = new IotOperationsBrokerData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsBrokerProperties + { + Cardinality = new BrokerCardinality(new BrokerBackendChain(2, 2) + { + Workers = 2, + }, new BrokerFrontend(2) + { + Workers = 2, + }), + GenerateResourceLimitsCpu = IotOperationsOperationalMode.Enabled, + MemoryProfile = BrokerMemoryProfile.Low, + }, + }; + ArmOperation lro = await iotOperationsBroker.UpdateAsync(WaitUntil.Completed, data); + IotOperationsBrokerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowCollection.cs new file mode 100644 index 00000000000000..728994d656b331 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowCollection.cs @@ -0,0 +1,580 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsDataflowCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowCreateOrUpdateComplexContextualization() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_ComplexContextualization.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // get the collection of this IotOperationsDataflowResource + IotOperationsDataflowCollection collection = iotOperationsDataflowProfile.GetIotOperationsDataflows(); + + // invoke the operation + string dataflowName = "aio-to-adx-contexualized"; + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "source1", +SourceSettings = new DataflowSourceOperationSettings("aio-builtin-broker-endpoint", new string[]{"azure-iot-operations/data/thermostat"}), +}, +new DataflowOperationProperties(DataflowOperationType.BuiltInTransformation) +{ +Name = "transformation1", +BuiltInTransformationSettings = new DataflowBuiltInTransformationSettings +{ +Datasets = {new DataflowBuiltInTransformationDataset("quality", new string[]{"$source.country", "$context.country"}) +{ +Expression = "$1 == $2", +}}, +Map = {new DataflowBuiltInTransformationMap(new string[]{"*"}, "*"), new DataflowBuiltInTransformationMap(new string[]{"$context(quality).*"}, "enriched.*")}, +}, +}, +new DataflowOperationProperties(DataflowOperationType.Destination) +{ +Name = "destination1", +DestinationSettings = new DataflowDestinationOperationSettings("adx-endpoint", "mytable"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowName, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowCreateOrUpdateComplexEventHub() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_ComplexEventHub.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // get the collection of this IotOperationsDataflowResource + IotOperationsDataflowCollection collection = iotOperationsDataflowProfile.GetIotOperationsDataflows(); + + // invoke the operation + string dataflowName = "aio-to-event-hub-transformed"; + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "source1", +SourceSettings = new DataflowSourceOperationSettings("aio-builtin-broker-endpoint", new string[]{"azure-iot-operations/data/thermostat"}), +}, +new DataflowOperationProperties(DataflowOperationType.BuiltInTransformation) +{ +BuiltInTransformationSettings = new DataflowBuiltInTransformationSettings +{ +Filter = {new DataflowBuiltInTransformationFilter(new string[]{"temperature.Value", "\"Tag 10\".Value"}, "$1 > 9000 && $2 >= 8000")}, +Map = {new DataflowBuiltInTransformationMap(new string[]{"*"}, "*"), new DataflowBuiltInTransformationMap(new string[]{"temperature.Value", "\"Tag 10\".Value"}, "AvgTemp.Value") +{ +Expression = "($1+$2)/2", +}, new DataflowBuiltInTransformationMap(Array.Empty(), "dataflow-processed") +{ +Expression = "true", +}, new DataflowBuiltInTransformationMap(new string[]{"temperature.SourceTimestamp"}, "") +{ +Expression = "", +}, new DataflowBuiltInTransformationMap(new string[]{"\"Tag 10\""}, "pressure") +{ +Expression = "", +}, new DataflowBuiltInTransformationMap(new string[]{"temperature.Value"}, "temperatureF.Value") +{ +Expression = "cToF($1)", +}, new DataflowBuiltInTransformationMap(new string[]{"\"Tag 10\".Value"}, "\"Scale Tag 10\".Value") +{ +Expression = "scale ($1,0,10,0,100)", +}}, +}, +}, +new DataflowOperationProperties(DataflowOperationType.Destination) +{ +Name = "destination1", +DestinationSettings = new DataflowDestinationOperationSettings("event-hub-endpoint", "myuniqueeventhub"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowName, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowCreateOrUpdateFilterToTopic() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_FilterToTopic.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // get the collection of this IotOperationsDataflowResource + IotOperationsDataflowCollection collection = iotOperationsDataflowProfile.GetIotOperationsDataflows(); + + // invoke the operation + string dataflowName = "mqtt-filter-to-topic"; + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "source1", +SourceSettings = new DataflowSourceOperationSettings("aio-builtin-broker-endpoint", new string[]{"azure-iot-operations/data/thermostat"}), +}, +new DataflowOperationProperties(DataflowOperationType.BuiltInTransformation) +{ +Name = "transformation1", +BuiltInTransformationSettings = new DataflowBuiltInTransformationSettings +{ +Filter = {new DataflowBuiltInTransformationFilter(new string[]{"temperature.Value", "\"Tag 10\".Value"}, "$1 > 9000 && $2 >= 8000") +{ +Type = DataflowFilterType.Filter, +Description = "filter-datapoint", +}}, +Map = {new DataflowBuiltInTransformationMap(new string[]{"*"}, "*") +{ +Type = DataflowMappingType.PassThrough, +}}, +}, +}, +new DataflowOperationProperties(DataflowOperationType.Destination) +{ +Name = "destination1", +DestinationSettings = new DataflowDestinationOperationSettings("aio-builtin-broker-endpoint", "data/filtered/thermostat"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowName, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // get the collection of this IotOperationsDataflowResource + IotOperationsDataflowCollection collection = iotOperationsDataflowProfile.GetIotOperationsDataflows(); + + // invoke the operation + string dataflowName = "resource-name123"; + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "knnafvkwoeakm", +SourceSettings = new DataflowSourceOperationSettings("iixotodhvhkkfcfyrkoveslqig", new string[]{"chkkpymxhp"}) +{ +AssetRef = "zayyykwmckaocywdkohmu", +SerializationFormat = DataflowSourceSerializationFormat.Json, +SchemaRef = "pknmdzqll", +}, +BuiltInTransformationSettings = new DataflowBuiltInTransformationSettings +{ +SerializationFormat = TransformationSerializationFormat.Delta, +SchemaRef = "mcdc", +Datasets = {new DataflowBuiltInTransformationDataset("qsfqcgxaxnhfumrsdsokwyv", new string[]{"mosffpsslifkq"}) +{ +Description = "Lorem ipsum odor amet, consectetuer adipiscing elit.", +SchemaRef = "n", +Expression = "aatbwomvflemsxialv", +}}, +Filter = {new DataflowBuiltInTransformationFilter(new string[]{"sxmjkbntgb"}, "n") +{ +Type = DataflowFilterType.Filter, +Description = "Lorem ipsum odor amet, consectetuer adipiscing elit.", +}}, +Map = {new DataflowBuiltInTransformationMap(new string[]{"xsbxuk"}, "nvgtmkfl") +{ +Type = DataflowMappingType.NewProperties, +Description = "Lorem ipsum odor amet, consectetuer adipiscing elit.", +Expression = "txoiltogsarwkzalsphvlmt", +}}, +}, +DestinationSettings = new DataflowDestinationOperationSettings("kybkchnzimerguekuvqlqiqdvvrt", "cbrh"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowName, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowCreateOrUpdateSimpleEventGrid() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_SimpleEventGrid.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // get the collection of this IotOperationsDataflowResource + IotOperationsDataflowCollection collection = iotOperationsDataflowProfile.GetIotOperationsDataflows(); + + // invoke the operation + string dataflowName = "aio-to-event-grid"; + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "source1", +SourceSettings = new DataflowSourceOperationSettings("aio-builtin-broker-endpoint", new string[]{"thermostats/+/telemetry/temperature/#"}), +}, +new DataflowOperationProperties(DataflowOperationType.Destination) +{ +Name = "destination1", +DestinationSettings = new DataflowDestinationOperationSettings("event-grid-endpoint", "factory/telemetry"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowName, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowCreateOrUpdateSimpleFabric() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_SimpleFabric.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // get the collection of this IotOperationsDataflowResource + IotOperationsDataflowCollection collection = iotOperationsDataflowProfile.GetIotOperationsDataflows(); + + // invoke the operation + string dataflowName = "aio-to-fabric"; + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "source1", +SourceSettings = new DataflowSourceOperationSettings("aio-builtin-broker-endpoint", new string[]{"azure-iot-operations/data/thermostat"}), +}, +new DataflowOperationProperties(DataflowOperationType.BuiltInTransformation) +{ +BuiltInTransformationSettings = new DataflowBuiltInTransformationSettings +{ +SerializationFormat = TransformationSerializationFormat.Parquet, +SchemaRef = "aio-sr://exampleNamespace/exmapleParquetSchema:1.0.0", +}, +}, +new DataflowOperationProperties(DataflowOperationType.Destination) +{ +Name = "destination1", +DestinationSettings = new DataflowDestinationOperationSettings("fabric-endpoint", "telemetryTable"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowName, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_DataflowGet() + { + // Generated from example definition: 2024-11-01/Dataflow_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // get the collection of this IotOperationsDataflowResource + IotOperationsDataflowCollection collection = iotOperationsDataflowProfile.GetIotOperationsDataflows(); + + // invoke the operation + string dataflowName = "resource-name123"; + IotOperationsDataflowResource result = await collection.GetAsync(dataflowName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_DataflowListByProfileResource() + { + // Generated from example definition: 2024-11-01/Dataflow_ListByProfileResource_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // get the collection of this IotOperationsDataflowResource + IotOperationsDataflowCollection collection = iotOperationsDataflowProfile.GetIotOperationsDataflows(); + + // invoke the operation and iterate over the result + await foreach (IotOperationsDataflowResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_DataflowGet() + { + // Generated from example definition: 2024-11-01/Dataflow_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // get the collection of this IotOperationsDataflowResource + IotOperationsDataflowCollection collection = iotOperationsDataflowProfile.GetIotOperationsDataflows(); + + // invoke the operation + string dataflowName = "resource-name123"; + bool result = await collection.ExistsAsync(dataflowName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_DataflowGet() + { + // Generated from example definition: 2024-11-01/Dataflow_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // get the collection of this IotOperationsDataflowResource + IotOperationsDataflowCollection collection = iotOperationsDataflowProfile.GetIotOperationsDataflows(); + + // invoke the operation + string dataflowName = "resource-name123"; + NullableResponse response = await collection.GetIfExistsAsync(dataflowName); + IotOperationsDataflowResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowEndpointCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowEndpointCollection.cs new file mode 100644 index 00000000000000..fee6e655a60bb6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowEndpointCollection.cs @@ -0,0 +1,756 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsDataflowEndpointCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowEndpointCreateOrUpdateADLSv2() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_ADLSv2.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "adlsv2-endpoint"; + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.DataLakeStorage) + { + DataLakeStorageSettings = new DataflowEndpointDataLakeStorage(new DataflowEndpointDataLakeStorageAuthentication(DataLakeStorageAuthMethod.AccessToken) + { + AccessTokenSecretRef = "my-secret", + }, "example.blob.core.windows.net"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowEndpointName, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowEndpointCreateOrUpdateADX() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_ADX.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "adx-endpoint"; + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.DataExplorer) + { + DataExplorerSettings = new DataflowEndpointDataExplorer(new DataflowEndpointDataExplorerAuthentication(DataExplorerAuthMethod.SystemAssignedManagedIdentity), "example-database", "example.westeurope.kusto.windows.net") + { + Batching = new IotOperationsBatchingConfig + { + LatencySeconds = 9312, + MaxMessages = 9028, + }, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowEndpointName, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowEndpointCreateOrUpdateAIO() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_AIO.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "aio-builtin-broker-endpoint"; + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.Mqtt) + { + MqttSettings = new DataflowEndpointMqtt(new DataflowEndpointMqttAuthentication(default) + { + ServiceAccountTokenAudience = "aio-internal", + }) + { + Host = "aio-broker:18883", + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + TrustedCaCertificateConfigMapRef = "aio-ca-trust-bundle-test-only", + }, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowEndpointName, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowEndpointCreateOrUpdateEventGrid() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_EventGrid.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "event-grid-endpoint"; + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.Mqtt) + { + MqttSettings = new DataflowEndpointMqtt(new DataflowEndpointMqttAuthentication(MqttAuthMethod.SystemAssignedManagedIdentity)) + { + Host = "example.westeurope-1.ts.eventgrid.azure.net:8883", + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowEndpointName, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowEndpointCreateOrUpdateEventHub() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_EventHub.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "event-hub-endpoint"; + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.Kafka) + { + KafkaSettings = new DataflowEndpointKafka(new DataflowEndpointKafkaAuthentication(KafkaAuthMethod.SystemAssignedManagedIdentity), "example.servicebus.windows.net:9093") + { + ConsumerGroupId = "aiodataflows", + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowEndpointName, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowEndpointCreateOrUpdateFabric() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_Fabric.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "fabric-endpoint"; + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.FabricOneLake) + { + FabricOneLakeSettings = new DataflowEndpointFabricOneLake(new DataflowEndpointFabricOneLakeAuthentication(FabricOneLakeAuthMethod.SystemAssignedManagedIdentity), new DataflowEndpointFabricOneLakeNames("example-lakehouse", "example-workspace"), DataflowEndpointFabricPathType.Tables, "onelake.dfs.fabric.microsoft.com"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowEndpointName, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowEndpointCreateOrUpdateKafka() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_Kafka.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "generic-kafka-endpoint"; + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.Kafka) + { + KafkaSettings = new DataflowEndpointKafka(new DataflowEndpointKafkaAuthentication(KafkaAuthMethod.Sasl) + { + SaslSettings = new DataflowEndpointAuthenticationSasl(DataflowEndpointAuthenticationSaslType.Plain, "my-secret"), + }, "example.kafka.local:9093") + { + ConsumerGroupId = "dataflows", + Batching = new DataflowEndpointKafkaBatching + { + Mode = IotOperationsOperationalMode.Enabled, + LatencyMs = 5, + MaxBytes = 1000000, + MaxMessages = 100000, + }, + CopyMqttProperties = IotOperationsOperationalMode.Enabled, + Compression = DataflowEndpointKafkaCompression.Gzip, + KafkaAcks = DataflowEndpointKafkaAck.All, + PartitionStrategy = DataflowEndpointKafkaPartitionStrategy.Default, + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + TrustedCaCertificateConfigMapRef = "ca-certificates", + }, + CloudEventAttributes = CloudEventAttributeType.Propagate, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowEndpointName, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowEndpointCreateOrUpdateLocalStorage() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_LocalStorage.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "local-storage-endpoint"; + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.LocalStorage) + { + LocalStoragePersistentVolumeClaimRef = "example-pvc", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowEndpointName, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowEndpointCreateOrUpdateMQTT() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_MQTT.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "generic-mqtt-broker-endpoint"; + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.Mqtt) + { + MqttSettings = new DataflowEndpointMqtt(new DataflowEndpointMqttAuthentication(MqttAuthMethod.X509Certificate) + { + X509CertificateSecretRef = "example-secret", + }) + { + ClientIdPrefix = "factory-gateway", + Host = "example.broker.local:1883", + Protocol = BrokerProtocolType.WebSockets, + KeepAliveSeconds = 60, + Retain = MqttRetainType.Keep, + MaxInflightMessages = 100, + Qos = 1, + SessionExpirySeconds = 3600, + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Disabled, + }, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowEndpointName, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowEndpointCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "resource-name123"; + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.DataExplorer) + { + DataExplorerSettings = new DataflowEndpointDataExplorer(new DataflowEndpointDataExplorerAuthentication(DataExplorerAuthMethod.SystemAssignedManagedIdentity) + { + SystemAssignedManagedIdentityAudience = "psxomrfbhoflycm", + UserAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationUserAssignedManagedIdentity("fb90f267-8872-431a-a76a-a1cec5d3c4d2", "ed060aa2-71ff-4d3f-99c4-a9138356fdec") + { + Scope = "zop", + }, + }, "yqcdpjsifm", "..kusto.windows.net") + { + Batching = new IotOperationsBatchingConfig + { + LatencySeconds = 9312, + MaxMessages = 9028, + }, + }, + DataLakeStorageSettings = new DataflowEndpointDataLakeStorage(new DataflowEndpointDataLakeStorageAuthentication(DataLakeStorageAuthMethod.SystemAssignedManagedIdentity) + { + AccessTokenSecretRef = "sevriyphcvnlrnfudqzejecwa", + SystemAssignedManagedIdentityAudience = "psxomrfbhoflycm", + UserAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationUserAssignedManagedIdentity("fb90f267-8872-431a-a76a-a1cec5d3c4d2", "ed060aa2-71ff-4d3f-99c4-a9138356fdec") + { + Scope = "zop", + }, + }, ".blob.core.windows.net") + { + Batching = new IotOperationsBatchingConfig + { + LatencySeconds = 9312, + MaxMessages = 9028, + }, + }, + FabricOneLakeSettings = new DataflowEndpointFabricOneLake(new DataflowEndpointFabricOneLakeAuthentication(FabricOneLakeAuthMethod.SystemAssignedManagedIdentity) + { + SystemAssignedManagedIdentityAudience = "psxomrfbhoflycm", + UserAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationUserAssignedManagedIdentity("fb90f267-8872-431a-a76a-a1cec5d3c4d2", "ed060aa2-71ff-4d3f-99c4-a9138356fdec") + { + Scope = "zop", + }, + }, new DataflowEndpointFabricOneLakeNames("wpeathi", "nwgmitkbljztgms"), DataflowEndpointFabricPathType.Files, "https://.fabric.microsoft.com") + { + Batching = new IotOperationsBatchingConfig + { + LatencySeconds = 9312, + MaxMessages = 9028, + }, + }, + KafkaSettings = new DataflowEndpointKafka(new DataflowEndpointKafkaAuthentication(KafkaAuthMethod.SystemAssignedManagedIdentity) + { + SystemAssignedManagedIdentityAudience = "psxomrfbhoflycm", + UserAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationUserAssignedManagedIdentity("fb90f267-8872-431a-a76a-a1cec5d3c4d2", "ed060aa2-71ff-4d3f-99c4-a9138356fdec") + { + Scope = "zop", + }, + SaslSettings = new DataflowEndpointAuthenticationSasl(DataflowEndpointAuthenticationSaslType.Plain, "visyxoztqnylvbyokhtmpdkwes"), + X509CertificateSecretRef = "afwizrystfslkfqd", + }, "pwcqfiqclcgneolpewnyavoulbip") + { + ConsumerGroupId = "ukkzcjiyenhxokat", + Batching = new DataflowEndpointKafkaBatching + { + Mode = IotOperationsOperationalMode.Enabled, + LatencyMs = 3679, + MaxBytes = 8887, + MaxMessages = 2174, + }, + CopyMqttProperties = IotOperationsOperationalMode.Enabled, + Compression = DataflowEndpointKafkaCompression.None, + KafkaAcks = DataflowEndpointKafkaAck.Zero, + PartitionStrategy = DataflowEndpointKafkaPartitionStrategy.Default, + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + TrustedCaCertificateConfigMapRef = "tectjjvukvelsreihwadh", + }, + }, + LocalStoragePersistentVolumeClaimRef = "jjwqwvd", + MqttSettings = new DataflowEndpointMqtt(new DataflowEndpointMqttAuthentication(MqttAuthMethod.SystemAssignedManagedIdentity) + { + SystemAssignedManagedIdentityAudience = "psxomrfbhoflycm", + UserAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationUserAssignedManagedIdentity("fb90f267-8872-431a-a76a-a1cec5d3c4d2", "ed060aa2-71ff-4d3f-99c4-a9138356fdec") + { + Scope = "zop", + }, + ServiceAccountTokenAudience = "ejbklrbxgjaqleoycgpje", + X509CertificateSecretRef = "afwizrystfslkfqd", + }) + { + ClientIdPrefix = "kkljsdxdirfhwxtkavldekeqhv", + Host = "nyhnxqnbspstctl", + Protocol = BrokerProtocolType.Mqtt, + KeepAliveSeconds = 0, + Retain = MqttRetainType.Keep, + MaxInflightMessages = 0, + Qos = 1, + SessionExpirySeconds = 0, + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + TrustedCaCertificateConfigMapRef = "tectjjvukvelsreihwadh", + }, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowEndpointName, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_DataflowEndpointGet() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "resource-name123"; + IotOperationsDataflowEndpointResource result = await collection.GetAsync(dataflowEndpointName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_DataflowEndpointListByResourceGroup() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowEndpointResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation and iterate over the result + await foreach (IotOperationsDataflowEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_DataflowEndpointGet() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "resource-name123"; + bool result = await collection.ExistsAsync(dataflowEndpointName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_DataflowEndpointGet() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowEndpointResource + IotOperationsDataflowEndpointCollection collection = iotOperationsInstance.GetIotOperationsDataflowEndpoints(); + + // invoke the operation + string dataflowEndpointName = "resource-name123"; + NullableResponse response = await collection.GetIfExistsAsync(dataflowEndpointName); + IotOperationsDataflowEndpointResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowEndpointResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowEndpointResource.cs new file mode 100644 index 00000000000000..28a4166b63eb5b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowEndpointResource.cs @@ -0,0 +1,642 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsDataflowEndpointResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_DataflowEndpointGet() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowEndpointResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + IotOperationsDataflowEndpointResource result = await iotOperationsDataflowEndpoint.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DataflowEndpointDelete() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowEndpointResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + await iotOperationsDataflowEndpoint.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowEndpointCreateOrUpdateADLSv2() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_ADLSv2.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "adlsv2-endpoint"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.DataLakeStorage) + { + DataLakeStorageSettings = new DataflowEndpointDataLakeStorage(new DataflowEndpointDataLakeStorageAuthentication(DataLakeStorageAuthMethod.AccessToken) + { + AccessTokenSecretRef = "my-secret", + }, "example.blob.core.windows.net"), + }, + }; + ArmOperation lro = await iotOperationsDataflowEndpoint.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowEndpointCreateOrUpdateADX() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_ADX.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "adx-endpoint"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.DataExplorer) + { + DataExplorerSettings = new DataflowEndpointDataExplorer(new DataflowEndpointDataExplorerAuthentication(DataExplorerAuthMethod.SystemAssignedManagedIdentity), "example-database", "example.westeurope.kusto.windows.net") + { + Batching = new IotOperationsBatchingConfig + { + LatencySeconds = 9312, + MaxMessages = 9028, + }, + }, + }, + }; + ArmOperation lro = await iotOperationsDataflowEndpoint.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowEndpointCreateOrUpdateAIO() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_AIO.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "aio-builtin-broker-endpoint"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.Mqtt) + { + MqttSettings = new DataflowEndpointMqtt(new DataflowEndpointMqttAuthentication(default) + { + ServiceAccountTokenAudience = "aio-internal", + }) + { + Host = "aio-broker:18883", + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + TrustedCaCertificateConfigMapRef = "aio-ca-trust-bundle-test-only", + }, + }, + }, + }; + ArmOperation lro = await iotOperationsDataflowEndpoint.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowEndpointCreateOrUpdateEventGrid() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_EventGrid.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "event-grid-endpoint"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.Mqtt) + { + MqttSettings = new DataflowEndpointMqtt(new DataflowEndpointMqttAuthentication(MqttAuthMethod.SystemAssignedManagedIdentity)) + { + Host = "example.westeurope-1.ts.eventgrid.azure.net:8883", + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }, + }, + }; + ArmOperation lro = await iotOperationsDataflowEndpoint.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowEndpointCreateOrUpdateEventHub() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_EventHub.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "event-hub-endpoint"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.Kafka) + { + KafkaSettings = new DataflowEndpointKafka(new DataflowEndpointKafkaAuthentication(KafkaAuthMethod.SystemAssignedManagedIdentity), "example.servicebus.windows.net:9093") + { + ConsumerGroupId = "aiodataflows", + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }, + }, + }; + ArmOperation lro = await iotOperationsDataflowEndpoint.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowEndpointCreateOrUpdateFabric() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_Fabric.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "fabric-endpoint"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.FabricOneLake) + { + FabricOneLakeSettings = new DataflowEndpointFabricOneLake(new DataflowEndpointFabricOneLakeAuthentication(FabricOneLakeAuthMethod.SystemAssignedManagedIdentity), new DataflowEndpointFabricOneLakeNames("example-lakehouse", "example-workspace"), DataflowEndpointFabricPathType.Tables, "onelake.dfs.fabric.microsoft.com"), + }, + }; + ArmOperation lro = await iotOperationsDataflowEndpoint.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowEndpointCreateOrUpdateKafka() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_Kafka.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "generic-kafka-endpoint"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.Kafka) + { + KafkaSettings = new DataflowEndpointKafka(new DataflowEndpointKafkaAuthentication(KafkaAuthMethod.Sasl) + { + SaslSettings = new DataflowEndpointAuthenticationSasl(DataflowEndpointAuthenticationSaslType.Plain, "my-secret"), + }, "example.kafka.local:9093") + { + ConsumerGroupId = "dataflows", + Batching = new DataflowEndpointKafkaBatching + { + Mode = IotOperationsOperationalMode.Enabled, + LatencyMs = 5, + MaxBytes = 1000000, + MaxMessages = 100000, + }, + CopyMqttProperties = IotOperationsOperationalMode.Enabled, + Compression = DataflowEndpointKafkaCompression.Gzip, + KafkaAcks = DataflowEndpointKafkaAck.All, + PartitionStrategy = DataflowEndpointKafkaPartitionStrategy.Default, + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + TrustedCaCertificateConfigMapRef = "ca-certificates", + }, + CloudEventAttributes = CloudEventAttributeType.Propagate, + }, + }, + }; + ArmOperation lro = await iotOperationsDataflowEndpoint.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowEndpointCreateOrUpdateLocalStorage() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_LocalStorage.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "local-storage-endpoint"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.LocalStorage) + { + LocalStoragePersistentVolumeClaimRef = "example-pvc", + }, + }; + ArmOperation lro = await iotOperationsDataflowEndpoint.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowEndpointCreateOrUpdateMQTT() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_MQTT.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "generic-mqtt-broker-endpoint"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.Mqtt) + { + MqttSettings = new DataflowEndpointMqtt(new DataflowEndpointMqttAuthentication(MqttAuthMethod.X509Certificate) + { + X509CertificateSecretRef = "example-secret", + }) + { + ClientIdPrefix = "factory-gateway", + Host = "example.broker.local:1883", + Protocol = BrokerProtocolType.WebSockets, + KeepAliveSeconds = 60, + Retain = MqttRetainType.Keep, + MaxInflightMessages = 100, + Qos = 1, + SessionExpirySeconds = 3600, + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Disabled, + }, + }, + }, + }; + ArmOperation lro = await iotOperationsDataflowEndpoint.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowEndpointCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/DataflowEndpoint_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowEndpointResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowEndpointResource created on azure + // for more information of creating IotOperationsDataflowEndpointResource, please refer to the document of IotOperationsDataflowEndpointResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowEndpointName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowEndpointResourceId = IotOperationsDataflowEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowEndpointName); + IotOperationsDataflowEndpointResource iotOperationsDataflowEndpoint = client.GetIotOperationsDataflowEndpointResource(iotOperationsDataflowEndpointResourceId); + + // invoke the operation + IotOperationsDataflowEndpointData data = new IotOperationsDataflowEndpointData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowEndpointProperties(DataflowEndpointType.DataExplorer) + { + DataExplorerSettings = new DataflowEndpointDataExplorer(new DataflowEndpointDataExplorerAuthentication(DataExplorerAuthMethod.SystemAssignedManagedIdentity) + { + SystemAssignedManagedIdentityAudience = "psxomrfbhoflycm", + UserAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationUserAssignedManagedIdentity("fb90f267-8872-431a-a76a-a1cec5d3c4d2", "ed060aa2-71ff-4d3f-99c4-a9138356fdec") + { + Scope = "zop", + }, + }, "yqcdpjsifm", "..kusto.windows.net") + { + Batching = new IotOperationsBatchingConfig + { + LatencySeconds = 9312, + MaxMessages = 9028, + }, + }, + DataLakeStorageSettings = new DataflowEndpointDataLakeStorage(new DataflowEndpointDataLakeStorageAuthentication(DataLakeStorageAuthMethod.SystemAssignedManagedIdentity) + { + AccessTokenSecretRef = "sevriyphcvnlrnfudqzejecwa", + SystemAssignedManagedIdentityAudience = "psxomrfbhoflycm", + UserAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationUserAssignedManagedIdentity("fb90f267-8872-431a-a76a-a1cec5d3c4d2", "ed060aa2-71ff-4d3f-99c4-a9138356fdec") + { + Scope = "zop", + }, + }, ".blob.core.windows.net") + { + Batching = new IotOperationsBatchingConfig + { + LatencySeconds = 9312, + MaxMessages = 9028, + }, + }, + FabricOneLakeSettings = new DataflowEndpointFabricOneLake(new DataflowEndpointFabricOneLakeAuthentication(FabricOneLakeAuthMethod.SystemAssignedManagedIdentity) + { + SystemAssignedManagedIdentityAudience = "psxomrfbhoflycm", + UserAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationUserAssignedManagedIdentity("fb90f267-8872-431a-a76a-a1cec5d3c4d2", "ed060aa2-71ff-4d3f-99c4-a9138356fdec") + { + Scope = "zop", + }, + }, new DataflowEndpointFabricOneLakeNames("wpeathi", "nwgmitkbljztgms"), DataflowEndpointFabricPathType.Files, "https://.fabric.microsoft.com") + { + Batching = new IotOperationsBatchingConfig + { + LatencySeconds = 9312, + MaxMessages = 9028, + }, + }, + KafkaSettings = new DataflowEndpointKafka(new DataflowEndpointKafkaAuthentication(KafkaAuthMethod.SystemAssignedManagedIdentity) + { + SystemAssignedManagedIdentityAudience = "psxomrfbhoflycm", + UserAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationUserAssignedManagedIdentity("fb90f267-8872-431a-a76a-a1cec5d3c4d2", "ed060aa2-71ff-4d3f-99c4-a9138356fdec") + { + Scope = "zop", + }, + SaslSettings = new DataflowEndpointAuthenticationSasl(DataflowEndpointAuthenticationSaslType.Plain, "visyxoztqnylvbyokhtmpdkwes"), + X509CertificateSecretRef = "afwizrystfslkfqd", + }, "pwcqfiqclcgneolpewnyavoulbip") + { + ConsumerGroupId = "ukkzcjiyenhxokat", + Batching = new DataflowEndpointKafkaBatching + { + Mode = IotOperationsOperationalMode.Enabled, + LatencyMs = 3679, + MaxBytes = 8887, + MaxMessages = 2174, + }, + CopyMqttProperties = IotOperationsOperationalMode.Enabled, + Compression = DataflowEndpointKafkaCompression.None, + KafkaAcks = DataflowEndpointKafkaAck.Zero, + PartitionStrategy = DataflowEndpointKafkaPartitionStrategy.Default, + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + TrustedCaCertificateConfigMapRef = "tectjjvukvelsreihwadh", + }, + }, + LocalStoragePersistentVolumeClaimRef = "jjwqwvd", + MqttSettings = new DataflowEndpointMqtt(new DataflowEndpointMqttAuthentication(MqttAuthMethod.SystemAssignedManagedIdentity) + { + SystemAssignedManagedIdentityAudience = "psxomrfbhoflycm", + UserAssignedManagedIdentitySettings = new DataflowEndpointAuthenticationUserAssignedManagedIdentity("fb90f267-8872-431a-a76a-a1cec5d3c4d2", "ed060aa2-71ff-4d3f-99c4-a9138356fdec") + { + Scope = "zop", + }, + ServiceAccountTokenAudience = "ejbklrbxgjaqleoycgpje", + X509CertificateSecretRef = "afwizrystfslkfqd", + }) + { + ClientIdPrefix = "kkljsdxdirfhwxtkavldekeqhv", + Host = "nyhnxqnbspstctl", + Protocol = BrokerProtocolType.Mqtt, + KeepAliveSeconds = 0, + Retain = MqttRetainType.Keep, + MaxInflightMessages = 0, + Qos = 1, + SessionExpirySeconds = 0, + Tls = new IotOperationsTlsProperties + { + Mode = IotOperationsOperationalMode.Enabled, + TrustedCaCertificateConfigMapRef = "tectjjvukvelsreihwadh", + }, + }, + }, + }; + ArmOperation lro = await iotOperationsDataflowEndpoint.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowProfileCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowProfileCollection.cs new file mode 100644 index 00000000000000..3e52a720aafa12 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowProfileCollection.cs @@ -0,0 +1,292 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsDataflowProfileCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowProfileCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/DataflowProfile_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowProfileResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowProfileResource + IotOperationsDataflowProfileCollection collection = iotOperationsInstance.GetIotOperationsDataflowProfiles(); + + // invoke the operation + string dataflowProfileName = "resource-name123"; + IotOperationsDataflowProfileData data = new IotOperationsDataflowProfileData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProfileProperties + { + Diagnostics = new ProfileDiagnostics + { + LogsLevel = "rnmwokumdmebpmfxxxzvvjfdywotav", + MetricsPrometheusPort = 7581, + }, + InstanceCount = 14, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowProfileName, data); + IotOperationsDataflowProfileResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowProfileCreateOrUpdateMinimal() + { + // Generated from example definition: 2024-11-01/DataflowProfile_CreateOrUpdate_Minimal.json + // this example is just showing the usage of "DataflowProfileResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowProfileResource + IotOperationsDataflowProfileCollection collection = iotOperationsInstance.GetIotOperationsDataflowProfiles(); + + // invoke the operation + string dataflowProfileName = "aio-dataflowprofile"; + IotOperationsDataflowProfileData data = new IotOperationsDataflowProfileData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProfileProperties + { + InstanceCount = 1, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowProfileName, data); + IotOperationsDataflowProfileResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_DataflowProfileCreateOrUpdateMulti() + { + // Generated from example definition: 2024-11-01/DataflowProfile_CreateOrUpdate_Multi.json + // this example is just showing the usage of "DataflowProfileResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowProfileResource + IotOperationsDataflowProfileCollection collection = iotOperationsInstance.GetIotOperationsDataflowProfiles(); + + // invoke the operation + string dataflowProfileName = "aio-dataflowprofile"; + IotOperationsDataflowProfileData data = new IotOperationsDataflowProfileData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProfileProperties + { + InstanceCount = 3, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataflowProfileName, data); + IotOperationsDataflowProfileResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_DataflowProfileGet() + { + // Generated from example definition: 2024-11-01/DataflowProfile_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowProfileResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowProfileResource + IotOperationsDataflowProfileCollection collection = iotOperationsInstance.GetIotOperationsDataflowProfiles(); + + // invoke the operation + string dataflowProfileName = "resource-name123"; + IotOperationsDataflowProfileResource result = await collection.GetAsync(dataflowProfileName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_DataflowProfileListByResourceGroup() + { + // Generated from example definition: 2024-11-01/DataflowProfile_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowProfileResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowProfileResource + IotOperationsDataflowProfileCollection collection = iotOperationsInstance.GetIotOperationsDataflowProfiles(); + + // invoke the operation and iterate over the result + await foreach (IotOperationsDataflowProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_DataflowProfileGet() + { + // Generated from example definition: 2024-11-01/DataflowProfile_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowProfileResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowProfileResource + IotOperationsDataflowProfileCollection collection = iotOperationsInstance.GetIotOperationsDataflowProfiles(); + + // invoke the operation + string dataflowProfileName = "resource-name123"; + bool result = await collection.ExistsAsync(dataflowProfileName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_DataflowProfileGet() + { + // Generated from example definition: 2024-11-01/DataflowProfile_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowProfileResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // get the collection of this IotOperationsDataflowProfileResource + IotOperationsDataflowProfileCollection collection = iotOperationsInstance.GetIotOperationsDataflowProfiles(); + + // invoke the operation + string dataflowProfileName = "resource-name123"; + NullableResponse response = await collection.GetIfExistsAsync(dataflowProfileName); + IotOperationsDataflowProfileResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowProfileResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowProfileResource.cs new file mode 100644 index 00000000000000..6a247541ccdfa5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowProfileResource.cs @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsDataflowProfileResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_DataflowProfileGet() + { + // Generated from example definition: 2024-11-01/DataflowProfile_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowProfileResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // invoke the operation + IotOperationsDataflowProfileResource result = await iotOperationsDataflowProfile.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DataflowProfileDelete() + { + // Generated from example definition: 2024-11-01/DataflowProfile_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowProfileResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // invoke the operation + await iotOperationsDataflowProfile.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowProfileCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/DataflowProfile_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowProfileResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // invoke the operation + IotOperationsDataflowProfileData data = new IotOperationsDataflowProfileData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProfileProperties + { + Diagnostics = new ProfileDiagnostics + { + LogsLevel = "rnmwokumdmebpmfxxxzvvjfdywotav", + MetricsPrometheusPort = 7581, + }, + InstanceCount = 14, + }, + }; + ArmOperation lro = await iotOperationsDataflowProfile.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowProfileResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowProfileCreateOrUpdateMinimal() + { + // Generated from example definition: 2024-11-01/DataflowProfile_CreateOrUpdate_Minimal.json + // this example is just showing the usage of "DataflowProfileResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "aio-dataflowprofile"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // invoke the operation + IotOperationsDataflowProfileData data = new IotOperationsDataflowProfileData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProfileProperties + { + InstanceCount = 1, + }, + }; + ArmOperation lro = await iotOperationsDataflowProfile.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowProfileResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowProfileCreateOrUpdateMulti() + { + // Generated from example definition: 2024-11-01/DataflowProfile_CreateOrUpdate_Multi.json + // this example is just showing the usage of "DataflowProfileResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowProfileResource created on azure + // for more information of creating IotOperationsDataflowProfileResource, please refer to the document of IotOperationsDataflowProfileResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "aio-dataflowprofile"; + ResourceIdentifier iotOperationsDataflowProfileResourceId = IotOperationsDataflowProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName); + IotOperationsDataflowProfileResource iotOperationsDataflowProfile = client.GetIotOperationsDataflowProfileResource(iotOperationsDataflowProfileResourceId); + + // invoke the operation + IotOperationsDataflowProfileData data = new IotOperationsDataflowProfileData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProfileProperties + { + InstanceCount = 3, + }, + }; + ArmOperation lro = await iotOperationsDataflowProfile.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowProfileResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowResource.cs new file mode 100644 index 00000000000000..399b936a023e35 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsDataflowResource.cs @@ -0,0 +1,476 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsDataflowResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_DataflowGet() + { + // Generated from example definition: 2024-11-01/Dataflow_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowResource created on azure + // for more information of creating IotOperationsDataflowResource, please refer to the document of IotOperationsDataflowResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + string dataflowName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowResourceId = IotOperationsDataflowResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + IotOperationsDataflowResource iotOperationsDataflow = client.GetIotOperationsDataflowResource(iotOperationsDataflowResourceId); + + // invoke the operation + IotOperationsDataflowResource result = await iotOperationsDataflow.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DataflowDelete() + { + // Generated from example definition: 2024-11-01/Dataflow_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowResource created on azure + // for more information of creating IotOperationsDataflowResource, please refer to the document of IotOperationsDataflowResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + string dataflowName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowResourceId = IotOperationsDataflowResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + IotOperationsDataflowResource iotOperationsDataflow = client.GetIotOperationsDataflowResource(iotOperationsDataflowResourceId); + + // invoke the operation + await iotOperationsDataflow.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowCreateOrUpdateComplexContextualization() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_ComplexContextualization.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowResource created on azure + // for more information of creating IotOperationsDataflowResource, please refer to the document of IotOperationsDataflowResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + string dataflowName = "aio-to-adx-contexualized"; + ResourceIdentifier iotOperationsDataflowResourceId = IotOperationsDataflowResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + IotOperationsDataflowResource iotOperationsDataflow = client.GetIotOperationsDataflowResource(iotOperationsDataflowResourceId); + + // invoke the operation + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "source1", +SourceSettings = new DataflowSourceOperationSettings("aio-builtin-broker-endpoint", new string[]{"azure-iot-operations/data/thermostat"}), +}, +new DataflowOperationProperties(DataflowOperationType.BuiltInTransformation) +{ +Name = "transformation1", +BuiltInTransformationSettings = new DataflowBuiltInTransformationSettings +{ +Datasets = {new DataflowBuiltInTransformationDataset("quality", new string[]{"$source.country", "$context.country"}) +{ +Expression = "$1 == $2", +}}, +Map = {new DataflowBuiltInTransformationMap(new string[]{"*"}, "*"), new DataflowBuiltInTransformationMap(new string[]{"$context(quality).*"}, "enriched.*")}, +}, +}, +new DataflowOperationProperties(DataflowOperationType.Destination) +{ +Name = "destination1", +DestinationSettings = new DataflowDestinationOperationSettings("adx-endpoint", "mytable"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await iotOperationsDataflow.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowCreateOrUpdateComplexEventHub() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_ComplexEventHub.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowResource created on azure + // for more information of creating IotOperationsDataflowResource, please refer to the document of IotOperationsDataflowResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + string dataflowName = "aio-to-event-hub-transformed"; + ResourceIdentifier iotOperationsDataflowResourceId = IotOperationsDataflowResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + IotOperationsDataflowResource iotOperationsDataflow = client.GetIotOperationsDataflowResource(iotOperationsDataflowResourceId); + + // invoke the operation + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "source1", +SourceSettings = new DataflowSourceOperationSettings("aio-builtin-broker-endpoint", new string[]{"azure-iot-operations/data/thermostat"}), +}, +new DataflowOperationProperties(DataflowOperationType.BuiltInTransformation) +{ +BuiltInTransformationSettings = new DataflowBuiltInTransformationSettings +{ +Filter = {new DataflowBuiltInTransformationFilter(new string[]{"temperature.Value", "\"Tag 10\".Value"}, "$1 > 9000 && $2 >= 8000")}, +Map = {new DataflowBuiltInTransformationMap(new string[]{"*"}, "*"), new DataflowBuiltInTransformationMap(new string[]{"temperature.Value", "\"Tag 10\".Value"}, "AvgTemp.Value") +{ +Expression = "($1+$2)/2", +}, new DataflowBuiltInTransformationMap(Array.Empty(), "dataflow-processed") +{ +Expression = "true", +}, new DataflowBuiltInTransformationMap(new string[]{"temperature.SourceTimestamp"}, "") +{ +Expression = "", +}, new DataflowBuiltInTransformationMap(new string[]{"\"Tag 10\""}, "pressure") +{ +Expression = "", +}, new DataflowBuiltInTransformationMap(new string[]{"temperature.Value"}, "temperatureF.Value") +{ +Expression = "cToF($1)", +}, new DataflowBuiltInTransformationMap(new string[]{"\"Tag 10\".Value"}, "\"Scale Tag 10\".Value") +{ +Expression = "scale ($1,0,10,0,100)", +}}, +}, +}, +new DataflowOperationProperties(DataflowOperationType.Destination) +{ +Name = "destination1", +DestinationSettings = new DataflowDestinationOperationSettings("event-hub-endpoint", "myuniqueeventhub"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await iotOperationsDataflow.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowCreateOrUpdateFilterToTopic() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_FilterToTopic.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowResource created on azure + // for more information of creating IotOperationsDataflowResource, please refer to the document of IotOperationsDataflowResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + string dataflowName = "mqtt-filter-to-topic"; + ResourceIdentifier iotOperationsDataflowResourceId = IotOperationsDataflowResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + IotOperationsDataflowResource iotOperationsDataflow = client.GetIotOperationsDataflowResource(iotOperationsDataflowResourceId); + + // invoke the operation + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "source1", +SourceSettings = new DataflowSourceOperationSettings("aio-builtin-broker-endpoint", new string[]{"azure-iot-operations/data/thermostat"}), +}, +new DataflowOperationProperties(DataflowOperationType.BuiltInTransformation) +{ +Name = "transformation1", +BuiltInTransformationSettings = new DataflowBuiltInTransformationSettings +{ +Filter = {new DataflowBuiltInTransformationFilter(new string[]{"temperature.Value", "\"Tag 10\".Value"}, "$1 > 9000 && $2 >= 8000") +{ +Type = DataflowFilterType.Filter, +Description = "filter-datapoint", +}}, +Map = {new DataflowBuiltInTransformationMap(new string[]{"*"}, "*") +{ +Type = DataflowMappingType.PassThrough, +}}, +}, +}, +new DataflowOperationProperties(DataflowOperationType.Destination) +{ +Name = "destination1", +DestinationSettings = new DataflowDestinationOperationSettings("aio-builtin-broker-endpoint", "data/filtered/thermostat"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await iotOperationsDataflow.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowResource created on azure + // for more information of creating IotOperationsDataflowResource, please refer to the document of IotOperationsDataflowResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + string dataflowName = "resource-name123"; + ResourceIdentifier iotOperationsDataflowResourceId = IotOperationsDataflowResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + IotOperationsDataflowResource iotOperationsDataflow = client.GetIotOperationsDataflowResource(iotOperationsDataflowResourceId); + + // invoke the operation + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "knnafvkwoeakm", +SourceSettings = new DataflowSourceOperationSettings("iixotodhvhkkfcfyrkoveslqig", new string[]{"chkkpymxhp"}) +{ +AssetRef = "zayyykwmckaocywdkohmu", +SerializationFormat = DataflowSourceSerializationFormat.Json, +SchemaRef = "pknmdzqll", +}, +BuiltInTransformationSettings = new DataflowBuiltInTransformationSettings +{ +SerializationFormat = TransformationSerializationFormat.Delta, +SchemaRef = "mcdc", +Datasets = {new DataflowBuiltInTransformationDataset("qsfqcgxaxnhfumrsdsokwyv", new string[]{"mosffpsslifkq"}) +{ +Description = "Lorem ipsum odor amet, consectetuer adipiscing elit.", +SchemaRef = "n", +Expression = "aatbwomvflemsxialv", +}}, +Filter = {new DataflowBuiltInTransformationFilter(new string[]{"sxmjkbntgb"}, "n") +{ +Type = DataflowFilterType.Filter, +Description = "Lorem ipsum odor amet, consectetuer adipiscing elit.", +}}, +Map = {new DataflowBuiltInTransformationMap(new string[]{"xsbxuk"}, "nvgtmkfl") +{ +Type = DataflowMappingType.NewProperties, +Description = "Lorem ipsum odor amet, consectetuer adipiscing elit.", +Expression = "txoiltogsarwkzalsphvlmt", +}}, +}, +DestinationSettings = new DataflowDestinationOperationSettings("kybkchnzimerguekuvqlqiqdvvrt", "cbrh"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await iotOperationsDataflow.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowCreateOrUpdateSimpleEventGrid() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_SimpleEventGrid.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowResource created on azure + // for more information of creating IotOperationsDataflowResource, please refer to the document of IotOperationsDataflowResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + string dataflowName = "aio-to-event-grid"; + ResourceIdentifier iotOperationsDataflowResourceId = IotOperationsDataflowResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + IotOperationsDataflowResource iotOperationsDataflow = client.GetIotOperationsDataflowResource(iotOperationsDataflowResourceId); + + // invoke the operation + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "source1", +SourceSettings = new DataflowSourceOperationSettings("aio-builtin-broker-endpoint", new string[]{"thermostats/+/telemetry/temperature/#"}), +}, +new DataflowOperationProperties(DataflowOperationType.Destination) +{ +Name = "destination1", +DestinationSettings = new DataflowDestinationOperationSettings("event-grid-endpoint", "factory/telemetry"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await iotOperationsDataflow.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_DataflowCreateOrUpdateSimpleFabric() + { + // Generated from example definition: 2024-11-01/Dataflow_CreateOrUpdate_SimpleFabric.json + // this example is just showing the usage of "DataflowResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsDataflowResource created on azure + // for more information of creating IotOperationsDataflowResource, please refer to the document of IotOperationsDataflowResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "resource-name123"; + string dataflowProfileName = "resource-name123"; + string dataflowName = "aio-to-fabric"; + ResourceIdentifier iotOperationsDataflowResourceId = IotOperationsDataflowResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName, dataflowProfileName, dataflowName); + IotOperationsDataflowResource iotOperationsDataflow = client.GetIotOperationsDataflowResource(iotOperationsDataflowResourceId); + + // invoke the operation + IotOperationsDataflowData data = new IotOperationsDataflowData(new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsDataflowProperties(new DataflowOperationProperties[] + { +new DataflowOperationProperties(DataflowOperationType.Source) +{ +Name = "source1", +SourceSettings = new DataflowSourceOperationSettings("aio-builtin-broker-endpoint", new string[]{"azure-iot-operations/data/thermostat"}), +}, +new DataflowOperationProperties(DataflowOperationType.BuiltInTransformation) +{ +BuiltInTransformationSettings = new DataflowBuiltInTransformationSettings +{ +SerializationFormat = TransformationSerializationFormat.Parquet, +SchemaRef = "aio-sr://exampleNamespace/exmapleParquetSchema:1.0.0", +}, +}, +new DataflowOperationProperties(DataflowOperationType.Destination) +{ +Name = "destination1", +DestinationSettings = new DataflowDestinationOperationSettings("fabric-endpoint", "telemetryTable"), +} + }) + { + Mode = IotOperationsOperationalMode.Enabled, + }, + }; + ArmOperation lro = await iotOperationsDataflow.UpdateAsync(WaitUntil.Completed, data); + IotOperationsDataflowResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsDataflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsInstanceCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsInstanceCollection.cs new file mode 100644 index 00000000000000..8ccae2220ee275 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsInstanceCollection.cs @@ -0,0 +1,205 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsInstanceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_InstanceCreateOrUpdate() + { + // Generated from example definition: 2024-11-01/Instance_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "InstanceResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this IotOperationsInstanceResource + IotOperationsInstanceCollection collection = resourceGroupResource.GetIotOperationsInstances(); + + // invoke the operation + string instanceName = "aio-instance"; + IotOperationsInstanceData data = new IotOperationsInstanceData(new AzureLocation("xvewadyhycrjpu"), new IotOperationsExtendedLocation("qmbrfwcpwwhggszhrdjv", IotOperationsExtendedLocationType.CustomLocation)) + { + Properties = new IotOperationsInstanceProperties(new SchemaRegistryRef(new ResourceIdentifier("/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.DeviceRegistry/schemaRegistries/resource-name123"))) + { + Description = "kpqtgocs", + }, + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = { }, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, instanceName, data); + IotOperationsInstanceResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_InstanceGet() + { + // Generated from example definition: 2024-11-01/Instance_Get_MaximumSet_Gen.json + // this example is just showing the usage of "InstanceResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this IotOperationsInstanceResource + IotOperationsInstanceCollection collection = resourceGroupResource.GetIotOperationsInstances(); + + // invoke the operation + string instanceName = "aio-instance"; + IotOperationsInstanceResource result = await collection.GetAsync(instanceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_InstanceListByResourceGroup() + { + // Generated from example definition: 2024-11-01/Instance_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "InstanceResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this IotOperationsInstanceResource + IotOperationsInstanceCollection collection = resourceGroupResource.GetIotOperationsInstances(); + + // invoke the operation and iterate over the result + await foreach (IotOperationsInstanceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_InstanceGet() + { + // Generated from example definition: 2024-11-01/Instance_Get_MaximumSet_Gen.json + // this example is just showing the usage of "InstanceResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this IotOperationsInstanceResource + IotOperationsInstanceCollection collection = resourceGroupResource.GetIotOperationsInstances(); + + // invoke the operation + string instanceName = "aio-instance"; + bool result = await collection.ExistsAsync(instanceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_InstanceGet() + { + // Generated from example definition: 2024-11-01/Instance_Get_MaximumSet_Gen.json + // this example is just showing the usage of "InstanceResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this IotOperationsInstanceResource + IotOperationsInstanceCollection collection = resourceGroupResource.GetIotOperationsInstances(); + + // invoke the operation + string instanceName = "aio-instance"; + NullableResponse response = await collection.GetIfExistsAsync(instanceName); + IotOperationsInstanceResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsInstanceResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsInstanceResource.cs new file mode 100644 index 00000000000000..00889943d26152 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_IotOperationsInstanceResource.cs @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotOperations.Models; +using Azure.ResourceManager.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_IotOperationsInstanceResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_InstanceGet() + { + // Generated from example definition: 2024-11-01/Instance_Get_MaximumSet_Gen.json + // this example is just showing the usage of "InstanceResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "aio-instance"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // invoke the operation + IotOperationsInstanceResource result = await iotOperationsInstance.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_InstanceDelete() + { + // Generated from example definition: 2024-11-01/Instance_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "InstanceResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "aio-instance"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // invoke the operation + await iotOperationsInstance.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_InstanceUpdate() + { + // Generated from example definition: 2024-11-01/Instance_Update_MaximumSet_Gen.json + // this example is just showing the usage of "InstanceResource_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IotOperationsInstanceResource created on azure + // for more information of creating IotOperationsInstanceResource, please refer to the document of IotOperationsInstanceResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + string resourceGroupName = "rgiotoperations"; + string instanceName = "aio-instance"; + ResourceIdentifier iotOperationsInstanceResourceId = IotOperationsInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instanceName); + IotOperationsInstanceResource iotOperationsInstance = client.GetIotOperationsInstanceResource(iotOperationsInstanceResourceId); + + // invoke the operation + IotOperationsInstancePatch patch = new IotOperationsInstancePatch + { + Tags = { }, + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = { }, + }, + }; + IotOperationsInstanceResource result = await iotOperationsInstance.UpdateAsync(patch); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 00000000000000..07082aafb69105 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotOperations.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIotOperationsInstances_InstanceListBySubscription() + { + // Generated from example definition: 2024-11-01/Instance_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "InstanceResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "F8C729F9-DF9C-4743-848F-96EE433D8E53"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (IotOperationsInstanceResource item in subscriptionResource.GetIotOperationsInstancesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotOperationsInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/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 00000000000000..82e4a999e44b84 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Azure.ResourceManager.IotOperations.csproj @@ -0,0 +1,8 @@ + + + Azure Resource Manager client SDK for Azure resource provider IotOperations. + 1.0.0-beta.1 + azure;management;arm;resource manager;iotoperations + Azure.ResourceManager.IotOperations + + 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 00000000000000..8d05098797aac2 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/ArmIotOperationsModelFactory.cs @@ -0,0 +1,299 @@ +// 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 IotOperationsDataflowEndpointData IotOperationsDataflowEndpointData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IotOperationsDataflowEndpointProperties properties = null, IotOperationsExtendedLocation extendedLocation = null) + { + return new IotOperationsDataflowEndpointData( + 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 IotOperationsDataflowEndpointProperties IotOperationsDataflowEndpointProperties(DataflowEndpointType endpointType = default, DataflowEndpointDataExplorer dataExplorerSettings = null, DataflowEndpointDataLakeStorage dataLakeStorageSettings = null, DataflowEndpointFabricOneLake fabricOneLakeSettings = null, DataflowEndpointKafka kafkaSettings = null, string localStoragePersistentVolumeClaimRef = null, DataflowEndpointMqtt mqttSettings = null, IotOperationsProvisioningState? provisioningState = null) + { + return new IotOperationsDataflowEndpointProperties( + 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 IotOperationsDataflowData IotOperationsDataflowData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IotOperationsDataflowProperties properties = null, IotOperationsExtendedLocation extendedLocation = null) + { + return new IotOperationsDataflowData( + 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 IotOperationsDataflowProperties IotOperationsDataflowProperties(IotOperationsOperationalMode? mode = null, IEnumerable operations = null, IotOperationsProvisioningState? provisioningState = null) + { + operations ??= new List(); + + return new IotOperationsDataflowProperties(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 IotOperationsDataflowProfileData IotOperationsDataflowProfileData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IotOperationsDataflowProfileProperties properties = null, IotOperationsExtendedLocation extendedLocation = null) + { + return new IotOperationsDataflowProfileData( + 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 IotOperationsDataflowProfileProperties IotOperationsDataflowProfileProperties(ProfileDiagnostics diagnostics = null, int? instanceCount = null, IotOperationsProvisioningState? provisioningState = null) + { + return new IotOperationsDataflowProfileProperties(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 IotOperationsBrokerAuthorizationData IotOperationsBrokerAuthorizationData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IotOperationsBrokerAuthorizationProperties properties = null, IotOperationsExtendedLocation extendedLocation = null) + { + return new IotOperationsBrokerAuthorizationData( + 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 IotOperationsBrokerAuthorizationProperties IotOperationsBrokerAuthorizationProperties(BrokerAuthorizationConfig authorizationPolicies = null, IotOperationsProvisioningState? provisioningState = null) + { + return new IotOperationsBrokerAuthorizationProperties(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 IotOperationsBrokerAuthenticationData IotOperationsBrokerAuthenticationData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IotOperationsBrokerAuthenticationProperties properties = null, IotOperationsExtendedLocation extendedLocation = null) + { + return new IotOperationsBrokerAuthenticationData( + 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 IotOperationsBrokerAuthenticationProperties IotOperationsBrokerAuthenticationProperties(IEnumerable authenticationMethods = null, IotOperationsProvisioningState? provisioningState = null) + { + authenticationMethods ??= new List(); + + return new IotOperationsBrokerAuthenticationProperties(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 IotOperationsBrokerListenerData IotOperationsBrokerListenerData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IotOperationsBrokerListenerProperties properties = null, IotOperationsExtendedLocation extendedLocation = null) + { + return new IotOperationsBrokerListenerData( + 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 IotOperationsBrokerListenerProperties IotOperationsBrokerListenerProperties(string serviceName = null, IEnumerable ports = null, BlockerListenerServiceType? serviceType = null, IotOperationsProvisioningState? provisioningState = null) + { + ports ??= new List(); + + return new IotOperationsBrokerListenerProperties(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 IotOperationsBrokerData IotOperationsBrokerData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IotOperationsBrokerProperties properties = null, IotOperationsExtendedLocation extendedLocation = null) + { + return new IotOperationsBrokerData( + 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 IotOperationsBrokerProperties IotOperationsBrokerProperties(BrokerAdvancedSettings advanced = null, BrokerCardinality cardinality = null, BrokerDiagnostics diagnostics = null, DiskBackedMessageBuffer diskBackedMessageBuffer = null, IotOperationsOperationalMode? generateResourceLimitsCpu = null, BrokerMemoryProfile? memoryProfile = null, IotOperationsProvisioningState? provisioningState = null) + { + return new IotOperationsBrokerProperties( + 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 IotOperationsInstanceData IotOperationsInstanceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, IotOperationsInstanceProperties properties = null, IotOperationsExtendedLocation extendedLocation = null, ManagedServiceIdentity identity = null) + { + tags ??= new Dictionary(); + + return new IotOperationsInstanceData( + 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. + /// A new instance for mocking. + public static IotOperationsInstanceProperties IotOperationsInstanceProperties(string description = null, IotOperationsProvisioningState? provisioningState = null, string version = null, ResourceIdentifier schemaRegistryRefResourceId = null) + { + return new IotOperationsInstanceProperties(description, provisioningState, version, schemaRegistryRefResourceId != null ? new SchemaRegistryRef(schemaRegistryRefResourceId, serializedAdditionalRawData: null) : null, serializedAdditionalRawData: null); + } + } +} 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 00000000000000..76652d25809254 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Extensions/IotOperationsExtensions.cs @@ -0,0 +1,352 @@ +// 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.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)); + } + + /// + /// 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 IotOperationsInstanceResource GetIotOperationsInstanceResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIotOperationsArmClient(client).GetIotOperationsInstanceResource(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 IotOperationsBrokerResource GetIotOperationsBrokerResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIotOperationsArmClient(client).GetIotOperationsBrokerResource(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 IotOperationsBrokerListenerResource GetIotOperationsBrokerListenerResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIotOperationsArmClient(client).GetIotOperationsBrokerListenerResource(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 IotOperationsBrokerAuthenticationResource GetIotOperationsBrokerAuthenticationResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIotOperationsArmClient(client).GetIotOperationsBrokerAuthenticationResource(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 IotOperationsBrokerAuthorizationResource GetIotOperationsBrokerAuthorizationResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIotOperationsArmClient(client).GetIotOperationsBrokerAuthorizationResource(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 IotOperationsDataflowProfileResource GetIotOperationsDataflowProfileResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIotOperationsArmClient(client).GetIotOperationsDataflowProfileResource(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 IotOperationsDataflowResource GetIotOperationsDataflowResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIotOperationsArmClient(client).GetIotOperationsDataflowResource(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 IotOperationsDataflowEndpointResource GetIotOperationsDataflowEndpointResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableIotOperationsArmClient(client).GetIotOperationsDataflowEndpointResource(id); + } + + /// + /// Gets a collection of IotOperationsInstanceResources 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 IotOperationsInstanceResources and their operations over a IotOperationsInstanceResource. + public static IotOperationsInstanceCollection GetIotOperationsInstances(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableIotOperationsResourceGroupResource(resourceGroupResource).GetIotOperationsInstances(); + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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> GetIotOperationsInstanceAsync(this ResourceGroupResource resourceGroupResource, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableIotOperationsResourceGroupResource(resourceGroupResource).GetIotOperationsInstanceAsync(instanceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 GetIotOperationsInstance(this ResourceGroupResource resourceGroupResource, string instanceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableIotOperationsResourceGroupResource(resourceGroupResource).GetIotOperationsInstance(instanceName, cancellationToken); + } + + /// + /// List InstanceResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.IoTOperations/instances + /// + /// + /// Operation Id + /// InstanceResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 GetIotOperationsInstancesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableIotOperationsSubscriptionResource(subscriptionResource).GetIotOperationsInstancesAsync(cancellationToken); + } + + /// + /// List InstanceResource resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.IoTOperations/instances + /// + /// + /// Operation Id + /// InstanceResource_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 GetIotOperationsInstances(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableIotOperationsSubscriptionResource(subscriptionResource).GetIotOperationsInstances(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 00000000000000..2c16a64d1b88d5 --- /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 IotOperationsInstanceResource GetIotOperationsInstanceResource(ResourceIdentifier id) + { + IotOperationsInstanceResource.ValidateResourceId(id); + return new IotOperationsInstanceResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual IotOperationsBrokerResource GetIotOperationsBrokerResource(ResourceIdentifier id) + { + IotOperationsBrokerResource.ValidateResourceId(id); + return new IotOperationsBrokerResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual IotOperationsBrokerListenerResource GetIotOperationsBrokerListenerResource(ResourceIdentifier id) + { + IotOperationsBrokerListenerResource.ValidateResourceId(id); + return new IotOperationsBrokerListenerResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual IotOperationsBrokerAuthenticationResource GetIotOperationsBrokerAuthenticationResource(ResourceIdentifier id) + { + IotOperationsBrokerAuthenticationResource.ValidateResourceId(id); + return new IotOperationsBrokerAuthenticationResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual IotOperationsBrokerAuthorizationResource GetIotOperationsBrokerAuthorizationResource(ResourceIdentifier id) + { + IotOperationsBrokerAuthorizationResource.ValidateResourceId(id); + return new IotOperationsBrokerAuthorizationResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual IotOperationsDataflowProfileResource GetIotOperationsDataflowProfileResource(ResourceIdentifier id) + { + IotOperationsDataflowProfileResource.ValidateResourceId(id); + return new IotOperationsDataflowProfileResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual IotOperationsDataflowResource GetIotOperationsDataflowResource(ResourceIdentifier id) + { + IotOperationsDataflowResource.ValidateResourceId(id); + return new IotOperationsDataflowResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual IotOperationsDataflowEndpointResource GetIotOperationsDataflowEndpointResource(ResourceIdentifier id) + { + IotOperationsDataflowEndpointResource.ValidateResourceId(id); + return new IotOperationsDataflowEndpointResource(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 00000000000000..c61784d10f4ab8 --- /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 IotOperationsInstanceResources in the ResourceGroupResource. + /// An object representing collection of IotOperationsInstanceResources and their operations over a IotOperationsInstanceResource. + public virtual IotOperationsInstanceCollection GetIotOperationsInstances() + { + return GetCachedClient(client => new IotOperationsInstanceCollection(client, Id)); + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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> GetIotOperationsInstanceAsync(string instanceName, CancellationToken cancellationToken = default) + { + return await GetIotOperationsInstances().GetAsync(instanceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 GetIotOperationsInstance(string instanceName, CancellationToken cancellationToken = default) + { + return GetIotOperationsInstances().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 00000000000000..af819a8e6e37d6 --- /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 _iotOperationsInstanceInstanceClientDiagnostics; + private InstanceRestOperations _iotOperationsInstanceInstanceRestClient; + + /// 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 IotOperationsInstanceInstanceClientDiagnostics => _iotOperationsInstanceInstanceClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.IotOperations", IotOperationsInstanceResource.ResourceType.Namespace, Diagnostics); + private InstanceRestOperations IotOperationsInstanceInstanceRestClient => _iotOperationsInstanceInstanceRestClient ??= new InstanceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(IotOperationsInstanceResource.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-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetIotOperationsInstancesAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => IotOperationsInstanceInstanceRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => IotOperationsInstanceInstanceRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new IotOperationsInstanceResource(Client, IotOperationsInstanceData.DeserializeIotOperationsInstanceData(e)), IotOperationsInstanceInstanceClientDiagnostics, Pipeline, "MockableIotOperationsSubscriptionResource.GetIotOperationsInstances", "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-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetIotOperationsInstances(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => IotOperationsInstanceInstanceRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => IotOperationsInstanceInstanceRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new IotOperationsInstanceResource(Client, IotOperationsInstanceData.DeserializeIotOperationsInstanceData(e)), IotOperationsInstanceInstanceClientDiagnostics, Pipeline, "MockableIotOperationsSubscriptionResource.GetIotOperationsInstances", "value", "nextLink", cancellationToken); + } + } +} 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 00000000000000..910e7c7cf2cfa0 --- /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 00000000000000..d0904eba20d1d3 --- /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 00000000000000..e869474a76c66f --- /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 00000000000000..37eae5bc037233 --- /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 00000000000000..7622a33bd66ab7 --- /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 00000000000000..a9df9dbd846ce3 --- /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/IotOperationsBrokerAuthenticationCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationCollection.cs new file mode 100644 index 00000000000000..2a905732e2dd61 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationCollection.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 an instance call the GetIotOperationsBrokerAuthentications method from an instance of . + /// + public partial class IotOperationsBrokerAuthenticationCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics; + private readonly BrokerAuthenticationRestOperations _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient; + + /// Initializes a new instance of the class for mocking. + protected IotOperationsBrokerAuthenticationCollection() + { + } + + /// 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 IotOperationsBrokerAuthenticationCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", IotOperationsBrokerAuthenticationResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(IotOperationsBrokerAuthenticationResource.ResourceType, out string iotOperationsBrokerAuthenticationBrokerAuthenticationApiVersion); + _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient = new BrokerAuthenticationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsBrokerAuthenticationBrokerAuthenticationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != IotOperationsBrokerResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, IotOperationsBrokerResource.ResourceType), nameof(id)); + } + + /// + /// Create a BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthenticationResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerAuthenticationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerAuthenticationOperationSource(Client), _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 + /// BrokerAuthenticationResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerAuthenticationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authenticationName, nameof(authenticationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authenticationName, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerAuthenticationOperationSource(Client), _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 + /// BrokerAuthenticationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationCollection.Get"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 IotOperationsBrokerAuthenticationResource(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 + /// BrokerAuthenticationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationCollection.Get"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 IotOperationsBrokerAuthenticationResource(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-11-01 + /// + /// + /// 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) => _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new IotOperationsBrokerAuthenticationResource(Client, IotOperationsBrokerAuthenticationData.DeserializeIotOperationsBrokerAuthenticationData(e)), _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics, Pipeline, "IotOperationsBrokerAuthenticationCollection.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-11-01 + /// + /// + /// 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) => _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new IotOperationsBrokerAuthenticationResource(Client, IotOperationsBrokerAuthenticationData.DeserializeIotOperationsBrokerAuthenticationData(e)), _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics, Pipeline, "IotOperationsBrokerAuthenticationCollection.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 + /// BrokerAuthenticationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationCollection.Exists"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 + /// BrokerAuthenticationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationCollection.Exists"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 + /// BrokerAuthenticationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 IotOperationsBrokerAuthenticationResource(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 + /// BrokerAuthenticationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationCollection.GetIfExists"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 IotOperationsBrokerAuthenticationResource(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/IotOperationsBrokerAuthenticationData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationData.Serialization.cs new file mode 100644 index 00000000000000..8a1754aefa7450 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationData.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; +using Azure.ResourceManager.IotOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IotOperations +{ + public partial class IotOperationsBrokerAuthenticationData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsBrokerAuthenticationData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + } + + IotOperationsBrokerAuthenticationData 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(IotOperationsBrokerAuthenticationData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsBrokerAuthenticationData(document.RootElement, options); + } + + internal static IotOperationsBrokerAuthenticationData DeserializeIotOperationsBrokerAuthenticationData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsBrokerAuthenticationProperties properties = default; + IotOperationsExtendedLocation 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 = IotOperationsBrokerAuthenticationProperties.DeserializeIotOperationsBrokerAuthenticationProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = IotOperationsExtendedLocation.DeserializeIotOperationsExtendedLocation(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 IotOperationsBrokerAuthenticationData( + 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(IotOperationsBrokerAuthenticationData)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsBrokerAuthenticationData 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 DeserializeIotOperationsBrokerAuthenticationData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsBrokerAuthenticationData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationData.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationData.cs new file mode 100644 index 00000000000000..5a03c6da91625b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationData.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 IotOperationsBrokerAuthentication data model. + /// Instance broker authentication resource + /// + public partial class IotOperationsBrokerAuthenticationData : 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 IotOperationsBrokerAuthenticationData(IotOperationsExtendedLocation 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 IotOperationsBrokerAuthenticationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IotOperationsBrokerAuthenticationProperties properties, IotOperationsExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsBrokerAuthenticationData() + { + } + + /// The resource-specific properties for this resource. + public IotOperationsBrokerAuthenticationProperties Properties { get; set; } + /// Edge location of the resource. + public IotOperationsExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationResource.Serialization.cs new file mode 100644 index 00000000000000..79a4be181b38a8 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationResource.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 IotOperationsBrokerAuthenticationResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + IotOperationsBrokerAuthenticationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + IotOperationsBrokerAuthenticationData 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/IotOperationsBrokerAuthenticationResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationResource.cs new file mode 100644 index 00000000000000..2cb2a50a008657 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthenticationResource.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 an IotOperationsBrokerAuthentication 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 GetIotOperationsBrokerAuthenticationResource method. + /// Otherwise you can get one from its parent resource using the GetIotOperationsBrokerAuthentication method. + /// + public partial class IotOperationsBrokerAuthenticationResource : 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 _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics; + private readonly BrokerAuthenticationRestOperations _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient; + private readonly IotOperationsBrokerAuthenticationData _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 IotOperationsBrokerAuthenticationResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal IotOperationsBrokerAuthenticationResource(ArmClient client, IotOperationsBrokerAuthenticationData 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 IotOperationsBrokerAuthenticationResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string iotOperationsBrokerAuthenticationBrokerAuthenticationApiVersion); + _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient = new BrokerAuthenticationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsBrokerAuthenticationBrokerAuthenticationApiVersion); +#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 IotOperationsBrokerAuthenticationData 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 + /// BrokerAuthenticationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationResource.Get"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 IotOperationsBrokerAuthenticationResource(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 + /// BrokerAuthenticationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationResource.Get"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 IotOperationsBrokerAuthenticationResource(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 + /// BrokerAuthenticationResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationResource.Delete"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(_iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 + /// BrokerAuthenticationResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationResource.Delete"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IotOperationsArmOperation(_iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 + /// BrokerAuthenticationResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerAuthenticationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationResource.Update"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerAuthenticationOperationSource(Client), _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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 + /// BrokerAuthenticationResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerAuthenticationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics.CreateScope("IotOperationsBrokerAuthenticationResource.Update"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerAuthenticationOperationSource(Client), _iotOperationsBrokerAuthenticationBrokerAuthenticationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthenticationBrokerAuthenticationRestClient.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/IotOperationsBrokerAuthorizationCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationCollection.cs new file mode 100644 index 00000000000000..93e0d25c6b5f60 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationCollection.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 an instance call the GetIotOperationsBrokerAuthorizations method from an instance of . + /// + public partial class IotOperationsBrokerAuthorizationCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics; + private readonly BrokerAuthorizationRestOperations _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient; + + /// Initializes a new instance of the class for mocking. + protected IotOperationsBrokerAuthorizationCollection() + { + } + + /// 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 IotOperationsBrokerAuthorizationCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", IotOperationsBrokerAuthorizationResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(IotOperationsBrokerAuthorizationResource.ResourceType, out string iotOperationsBrokerAuthorizationBrokerAuthorizationApiVersion); + _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient = new BrokerAuthorizationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsBrokerAuthorizationBrokerAuthorizationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != IotOperationsBrokerResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, IotOperationsBrokerResource.ResourceType), nameof(id)); + } + + /// + /// Create a BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorizationResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerAuthorizationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerAuthorizationOperationSource(Client), _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 + /// BrokerAuthorizationResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerAuthorizationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationName, nameof(authorizationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationName, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerAuthorizationOperationSource(Client), _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 + /// BrokerAuthorizationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationCollection.Get"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 IotOperationsBrokerAuthorizationResource(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 + /// BrokerAuthorizationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationCollection.Get"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 IotOperationsBrokerAuthorizationResource(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-11-01 + /// + /// + /// 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) => _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new IotOperationsBrokerAuthorizationResource(Client, IotOperationsBrokerAuthorizationData.DeserializeIotOperationsBrokerAuthorizationData(e)), _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics, Pipeline, "IotOperationsBrokerAuthorizationCollection.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-11-01 + /// + /// + /// 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) => _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new IotOperationsBrokerAuthorizationResource(Client, IotOperationsBrokerAuthorizationData.DeserializeIotOperationsBrokerAuthorizationData(e)), _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics, Pipeline, "IotOperationsBrokerAuthorizationCollection.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 + /// BrokerAuthorizationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationCollection.Exists"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 + /// BrokerAuthorizationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationCollection.Exists"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 + /// BrokerAuthorizationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 IotOperationsBrokerAuthorizationResource(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 + /// BrokerAuthorizationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationCollection.GetIfExists"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 IotOperationsBrokerAuthorizationResource(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/IotOperationsBrokerAuthorizationData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationData.Serialization.cs new file mode 100644 index 00000000000000..4a57b7baa2ac04 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationData.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; +using Azure.ResourceManager.IotOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IotOperations +{ + public partial class IotOperationsBrokerAuthorizationData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsBrokerAuthorizationData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + } + + IotOperationsBrokerAuthorizationData 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(IotOperationsBrokerAuthorizationData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsBrokerAuthorizationData(document.RootElement, options); + } + + internal static IotOperationsBrokerAuthorizationData DeserializeIotOperationsBrokerAuthorizationData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsBrokerAuthorizationProperties properties = default; + IotOperationsExtendedLocation 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 = IotOperationsBrokerAuthorizationProperties.DeserializeIotOperationsBrokerAuthorizationProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = IotOperationsExtendedLocation.DeserializeIotOperationsExtendedLocation(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 IotOperationsBrokerAuthorizationData( + 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(IotOperationsBrokerAuthorizationData)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsBrokerAuthorizationData 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 DeserializeIotOperationsBrokerAuthorizationData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsBrokerAuthorizationData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationData.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationData.cs new file mode 100644 index 00000000000000..fdd9187c31d916 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationData.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 IotOperationsBrokerAuthorization data model. + /// Instance broker authorizations resource + /// + public partial class IotOperationsBrokerAuthorizationData : 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 IotOperationsBrokerAuthorizationData(IotOperationsExtendedLocation 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 IotOperationsBrokerAuthorizationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IotOperationsBrokerAuthorizationProperties properties, IotOperationsExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsBrokerAuthorizationData() + { + } + + /// The resource-specific properties for this resource. + public IotOperationsBrokerAuthorizationProperties Properties { get; set; } + /// Edge location of the resource. + public IotOperationsExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationResource.Serialization.cs new file mode 100644 index 00000000000000..0190e21e4771eb --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationResource.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 IotOperationsBrokerAuthorizationResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + IotOperationsBrokerAuthorizationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + IotOperationsBrokerAuthorizationData 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/IotOperationsBrokerAuthorizationResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationResource.cs new file mode 100644 index 00000000000000..54adbeb1236572 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerAuthorizationResource.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 an IotOperationsBrokerAuthorization 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 GetIotOperationsBrokerAuthorizationResource method. + /// Otherwise you can get one from its parent resource using the GetIotOperationsBrokerAuthorization method. + /// + public partial class IotOperationsBrokerAuthorizationResource : 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 _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics; + private readonly BrokerAuthorizationRestOperations _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient; + private readonly IotOperationsBrokerAuthorizationData _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 IotOperationsBrokerAuthorizationResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal IotOperationsBrokerAuthorizationResource(ArmClient client, IotOperationsBrokerAuthorizationData 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 IotOperationsBrokerAuthorizationResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string iotOperationsBrokerAuthorizationBrokerAuthorizationApiVersion); + _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient = new BrokerAuthorizationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsBrokerAuthorizationBrokerAuthorizationApiVersion); +#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 IotOperationsBrokerAuthorizationData 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 + /// BrokerAuthorizationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationResource.Get"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 IotOperationsBrokerAuthorizationResource(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 + /// BrokerAuthorizationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationResource.Get"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 IotOperationsBrokerAuthorizationResource(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 + /// BrokerAuthorizationResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationResource.Delete"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(_iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 + /// BrokerAuthorizationResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationResource.Delete"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IotOperationsArmOperation(_iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 + /// BrokerAuthorizationResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerAuthorizationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationResource.Update"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerAuthorizationOperationSource(Client), _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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 + /// BrokerAuthorizationResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerAuthorizationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics.CreateScope("IotOperationsBrokerAuthorizationResource.Update"); + scope.Start(); + try + { + var response = _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerAuthorizationOperationSource(Client), _iotOperationsBrokerAuthorizationBrokerAuthorizationClientDiagnostics, Pipeline, _iotOperationsBrokerAuthorizationBrokerAuthorizationRestClient.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/IotOperationsBrokerCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerCollection.cs new file mode 100644 index 00000000000000..5331bfff92f507 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerCollection.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 an instance call the GetIotOperationsBrokers method from an instance of . + /// + public partial class IotOperationsBrokerCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _iotOperationsBrokerBrokerClientDiagnostics; + private readonly BrokerRestOperations _iotOperationsBrokerBrokerRestClient; + + /// Initializes a new instance of the class for mocking. + protected IotOperationsBrokerCollection() + { + } + + /// 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 IotOperationsBrokerCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsBrokerBrokerClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", IotOperationsBrokerResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(IotOperationsBrokerResource.ResourceType, out string iotOperationsBrokerBrokerApiVersion); + _iotOperationsBrokerBrokerRestClient = new BrokerRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsBrokerBrokerApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != IotOperationsInstanceResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, IotOperationsInstanceResource.ResourceType), nameof(id)); + } + + /// + /// Create a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// BrokerResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerBrokerRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerOperationSource(Client), _iotOperationsBrokerBrokerClientDiagnostics, Pipeline, _iotOperationsBrokerBrokerRestClient.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 + /// BrokerResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(brokerName, nameof(brokerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _iotOperationsBrokerBrokerRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerOperationSource(Client), _iotOperationsBrokerBrokerClientDiagnostics, Pipeline, _iotOperationsBrokerBrokerRestClient.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 + /// BrokerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerCollection.Get"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerBrokerRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsBrokerResource(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 + /// BrokerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerCollection.Get"); + scope.Start(); + try + { + var response = _iotOperationsBrokerBrokerRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsBrokerResource(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-11-01 + /// + /// + /// 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) => _iotOperationsBrokerBrokerRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsBrokerBrokerRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new IotOperationsBrokerResource(Client, IotOperationsBrokerData.DeserializeIotOperationsBrokerData(e)), _iotOperationsBrokerBrokerClientDiagnostics, Pipeline, "IotOperationsBrokerCollection.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-11-01 + /// + /// + /// 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) => _iotOperationsBrokerBrokerRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsBrokerBrokerRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new IotOperationsBrokerResource(Client, IotOperationsBrokerData.DeserializeIotOperationsBrokerData(e)), _iotOperationsBrokerBrokerClientDiagnostics, Pipeline, "IotOperationsBrokerCollection.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 + /// BrokerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerCollection.Exists"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerBrokerRestClient.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 + /// BrokerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerCollection.Exists"); + scope.Start(); + try + { + var response = _iotOperationsBrokerBrokerRestClient.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 + /// BrokerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerBrokerRestClient.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 IotOperationsBrokerResource(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 + /// BrokerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerCollection.GetIfExists"); + scope.Start(); + try + { + var response = _iotOperationsBrokerBrokerRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, brokerName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new IotOperationsBrokerResource(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/IotOperationsBrokerData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerData.Serialization.cs new file mode 100644 index 00000000000000..a6ce0b6dfcacea --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerData.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; +using Azure.ResourceManager.IotOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IotOperations +{ + public partial class IotOperationsBrokerData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsBrokerData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + } + + IotOperationsBrokerData 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(IotOperationsBrokerData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsBrokerData(document.RootElement, options); + } + + internal static IotOperationsBrokerData DeserializeIotOperationsBrokerData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsBrokerProperties properties = default; + IotOperationsExtendedLocation 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 = IotOperationsBrokerProperties.DeserializeIotOperationsBrokerProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = IotOperationsExtendedLocation.DeserializeIotOperationsExtendedLocation(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 IotOperationsBrokerData( + 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(IotOperationsBrokerData)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsBrokerData 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 DeserializeIotOperationsBrokerData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsBrokerData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerData.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerData.cs new file mode 100644 index 00000000000000..8aecda74c08b6c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerData.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 IotOperationsBroker data model. + /// Instance broker resource + /// + public partial class IotOperationsBrokerData : 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 IotOperationsBrokerData(IotOperationsExtendedLocation 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 IotOperationsBrokerData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IotOperationsBrokerProperties properties, IotOperationsExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsBrokerData() + { + } + + /// The resource-specific properties for this resource. + public IotOperationsBrokerProperties Properties { get; set; } + /// Edge location of the resource. + public IotOperationsExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerCollection.cs new file mode 100644 index 00000000000000..c68e6df73e8334 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerCollection.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 an instance call the GetIotOperationsBrokerListeners method from an instance of . + /// + public partial class IotOperationsBrokerListenerCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _iotOperationsBrokerListenerBrokerListenerClientDiagnostics; + private readonly BrokerListenerRestOperations _iotOperationsBrokerListenerBrokerListenerRestClient; + + /// Initializes a new instance of the class for mocking. + protected IotOperationsBrokerListenerCollection() + { + } + + /// 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 IotOperationsBrokerListenerCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsBrokerListenerBrokerListenerClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", IotOperationsBrokerListenerResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(IotOperationsBrokerListenerResource.ResourceType, out string iotOperationsBrokerListenerBrokerListenerApiVersion); + _iotOperationsBrokerListenerBrokerListenerRestClient = new BrokerListenerRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsBrokerListenerBrokerListenerApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != IotOperationsBrokerResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, IotOperationsBrokerResource.ResourceType), nameof(id)); + } + + /// + /// Create a BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListenerResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerListenerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerListenerBrokerListenerRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerListenerOperationSource(Client), _iotOperationsBrokerListenerBrokerListenerClientDiagnostics, Pipeline, _iotOperationsBrokerListenerBrokerListenerRestClient.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 + /// BrokerListenerResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerListenerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(listenerName, nameof(listenerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _iotOperationsBrokerListenerBrokerListenerRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, listenerName, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerListenerOperationSource(Client), _iotOperationsBrokerListenerBrokerListenerClientDiagnostics, Pipeline, _iotOperationsBrokerListenerBrokerListenerRestClient.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 + /// BrokerListenerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerCollection.Get"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerListenerBrokerListenerRestClient.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 IotOperationsBrokerListenerResource(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 + /// BrokerListenerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerCollection.Get"); + scope.Start(); + try + { + var response = _iotOperationsBrokerListenerBrokerListenerRestClient.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 IotOperationsBrokerListenerResource(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-11-01 + /// + /// + /// 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) => _iotOperationsBrokerListenerBrokerListenerRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsBrokerListenerBrokerListenerRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new IotOperationsBrokerListenerResource(Client, IotOperationsBrokerListenerData.DeserializeIotOperationsBrokerListenerData(e)), _iotOperationsBrokerListenerBrokerListenerClientDiagnostics, Pipeline, "IotOperationsBrokerListenerCollection.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-11-01 + /// + /// + /// 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) => _iotOperationsBrokerListenerBrokerListenerRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsBrokerListenerBrokerListenerRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new IotOperationsBrokerListenerResource(Client, IotOperationsBrokerListenerData.DeserializeIotOperationsBrokerListenerData(e)), _iotOperationsBrokerListenerBrokerListenerClientDiagnostics, Pipeline, "IotOperationsBrokerListenerCollection.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 + /// BrokerListenerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerCollection.Exists"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerListenerBrokerListenerRestClient.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 + /// BrokerListenerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerCollection.Exists"); + scope.Start(); + try + { + var response = _iotOperationsBrokerListenerBrokerListenerRestClient.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 + /// BrokerListenerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerListenerBrokerListenerRestClient.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 IotOperationsBrokerListenerResource(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 + /// BrokerListenerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerCollection.GetIfExists"); + scope.Start(); + try + { + var response = _iotOperationsBrokerListenerBrokerListenerRestClient.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 IotOperationsBrokerListenerResource(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/IotOperationsBrokerListenerData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerData.Serialization.cs new file mode 100644 index 00000000000000..dff373ab2cdf06 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerData.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; +using Azure.ResourceManager.IotOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IotOperations +{ + public partial class IotOperationsBrokerListenerData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsBrokerListenerData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + } + + IotOperationsBrokerListenerData 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(IotOperationsBrokerListenerData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsBrokerListenerData(document.RootElement, options); + } + + internal static IotOperationsBrokerListenerData DeserializeIotOperationsBrokerListenerData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsBrokerListenerProperties properties = default; + IotOperationsExtendedLocation 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 = IotOperationsBrokerListenerProperties.DeserializeIotOperationsBrokerListenerProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = IotOperationsExtendedLocation.DeserializeIotOperationsExtendedLocation(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 IotOperationsBrokerListenerData( + 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(IotOperationsBrokerListenerData)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsBrokerListenerData 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 DeserializeIotOperationsBrokerListenerData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsBrokerListenerData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerData.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerData.cs new file mode 100644 index 00000000000000..a04649ae93bb66 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerData.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 IotOperationsBrokerListener data model. + /// Instance broker resource + /// + public partial class IotOperationsBrokerListenerData : 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 IotOperationsBrokerListenerData(IotOperationsExtendedLocation 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 IotOperationsBrokerListenerData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IotOperationsBrokerListenerProperties properties, IotOperationsExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsBrokerListenerData() + { + } + + /// The resource-specific properties for this resource. + public IotOperationsBrokerListenerProperties Properties { get; set; } + /// Edge location of the resource. + public IotOperationsExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerResource.Serialization.cs new file mode 100644 index 00000000000000..7c173670a6097a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerResource.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 IotOperationsBrokerListenerResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + IotOperationsBrokerListenerData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + IotOperationsBrokerListenerData 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/IotOperationsBrokerListenerResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerResource.cs new file mode 100644 index 00000000000000..4f9676032a2c11 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerListenerResource.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 an IotOperationsBrokerListener 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 GetIotOperationsBrokerListenerResource method. + /// Otherwise you can get one from its parent resource using the GetIotOperationsBrokerListener method. + /// + public partial class IotOperationsBrokerListenerResource : 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 _iotOperationsBrokerListenerBrokerListenerClientDiagnostics; + private readonly BrokerListenerRestOperations _iotOperationsBrokerListenerBrokerListenerRestClient; + private readonly IotOperationsBrokerListenerData _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 IotOperationsBrokerListenerResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal IotOperationsBrokerListenerResource(ArmClient client, IotOperationsBrokerListenerData 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 IotOperationsBrokerListenerResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsBrokerListenerBrokerListenerClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string iotOperationsBrokerListenerBrokerListenerApiVersion); + _iotOperationsBrokerListenerBrokerListenerRestClient = new BrokerListenerRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsBrokerListenerBrokerListenerApiVersion); +#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 IotOperationsBrokerListenerData 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 + /// BrokerListenerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerResource.Get"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerListenerBrokerListenerRestClient.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 IotOperationsBrokerListenerResource(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 + /// BrokerListenerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerResource.Get"); + scope.Start(); + try + { + var response = _iotOperationsBrokerListenerBrokerListenerRestClient.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 IotOperationsBrokerListenerResource(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 + /// BrokerListenerResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerResource.Delete"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerListenerBrokerListenerRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(_iotOperationsBrokerListenerBrokerListenerClientDiagnostics, Pipeline, _iotOperationsBrokerListenerBrokerListenerRestClient.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 + /// BrokerListenerResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerResource.Delete"); + scope.Start(); + try + { + var response = _iotOperationsBrokerListenerBrokerListenerRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IotOperationsArmOperation(_iotOperationsBrokerListenerBrokerListenerClientDiagnostics, Pipeline, _iotOperationsBrokerListenerBrokerListenerRestClient.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 + /// BrokerListenerResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerListenerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerResource.Update"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerListenerBrokerListenerRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerListenerOperationSource(Client), _iotOperationsBrokerListenerBrokerListenerClientDiagnostics, Pipeline, _iotOperationsBrokerListenerBrokerListenerRestClient.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 + /// BrokerListenerResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerListenerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerListenerBrokerListenerClientDiagnostics.CreateScope("IotOperationsBrokerListenerResource.Update"); + scope.Start(); + try + { + var response = _iotOperationsBrokerListenerBrokerListenerRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerListenerOperationSource(Client), _iotOperationsBrokerListenerBrokerListenerClientDiagnostics, Pipeline, _iotOperationsBrokerListenerBrokerListenerRestClient.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/IotOperationsBrokerResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerResource.Serialization.cs new file mode 100644 index 00000000000000..62d3be809ff384 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerResource.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 IotOperationsBrokerResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + IotOperationsBrokerData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + IotOperationsBrokerData 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/IotOperationsBrokerResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerResource.cs new file mode 100644 index 00000000000000..21c066d6a4fd20 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsBrokerResource.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 an IotOperationsBroker 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 GetIotOperationsBrokerResource method. + /// Otherwise you can get one from its parent resource using the GetIotOperationsBroker method. + /// + public partial class IotOperationsBrokerResource : 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 _iotOperationsBrokerBrokerClientDiagnostics; + private readonly BrokerRestOperations _iotOperationsBrokerBrokerRestClient; + private readonly IotOperationsBrokerData _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 IotOperationsBrokerResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal IotOperationsBrokerResource(ArmClient client, IotOperationsBrokerData 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 IotOperationsBrokerResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsBrokerBrokerClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string iotOperationsBrokerBrokerApiVersion); + _iotOperationsBrokerBrokerRestClient = new BrokerRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsBrokerBrokerApiVersion); +#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 IotOperationsBrokerData 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 IotOperationsBrokerListenerResources in the IotOperationsBroker. + /// An object representing collection of IotOperationsBrokerListenerResources and their operations over a IotOperationsBrokerListenerResource. + public virtual IotOperationsBrokerListenerCollection GetIotOperationsBrokerListeners() + { + return GetCachedClient(client => new IotOperationsBrokerListenerCollection(client, Id)); + } + + /// + /// Get a BrokerListenerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/listeners/{listenerName} + /// + /// + /// Operation Id + /// BrokerListenerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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> GetIotOperationsBrokerListenerAsync(string listenerName, CancellationToken cancellationToken = default) + { + return await GetIotOperationsBrokerListeners().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 + /// BrokerListenerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 GetIotOperationsBrokerListener(string listenerName, CancellationToken cancellationToken = default) + { + return GetIotOperationsBrokerListeners().Get(listenerName, cancellationToken); + } + + /// Gets a collection of IotOperationsBrokerAuthenticationResources in the IotOperationsBroker. + /// An object representing collection of IotOperationsBrokerAuthenticationResources and their operations over a IotOperationsBrokerAuthenticationResource. + public virtual IotOperationsBrokerAuthenticationCollection GetIotOperationsBrokerAuthentications() + { + return GetCachedClient(client => new IotOperationsBrokerAuthenticationCollection(client, Id)); + } + + /// + /// Get a BrokerAuthenticationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authentications/{authenticationName} + /// + /// + /// Operation Id + /// BrokerAuthenticationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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> GetIotOperationsBrokerAuthenticationAsync(string authenticationName, CancellationToken cancellationToken = default) + { + return await GetIotOperationsBrokerAuthentications().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 + /// BrokerAuthenticationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 GetIotOperationsBrokerAuthentication(string authenticationName, CancellationToken cancellationToken = default) + { + return GetIotOperationsBrokerAuthentications().Get(authenticationName, cancellationToken); + } + + /// Gets a collection of IotOperationsBrokerAuthorizationResources in the IotOperationsBroker. + /// An object representing collection of IotOperationsBrokerAuthorizationResources and their operations over a IotOperationsBrokerAuthorizationResource. + public virtual IotOperationsBrokerAuthorizationCollection GetIotOperationsBrokerAuthorizations() + { + return GetCachedClient(client => new IotOperationsBrokerAuthorizationCollection(client, Id)); + } + + /// + /// Get a BrokerAuthorizationResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName}/authorizations/{authorizationName} + /// + /// + /// Operation Id + /// BrokerAuthorizationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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> GetIotOperationsBrokerAuthorizationAsync(string authorizationName, CancellationToken cancellationToken = default) + { + return await GetIotOperationsBrokerAuthorizations().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 + /// BrokerAuthorizationResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 GetIotOperationsBrokerAuthorization(string authorizationName, CancellationToken cancellationToken = default) + { + return GetIotOperationsBrokerAuthorizations().Get(authorizationName, cancellationToken); + } + + /// + /// Get a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// BrokerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerResource.Get"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerBrokerRestClient.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 IotOperationsBrokerResource(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 + /// BrokerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerResource.Get"); + scope.Start(); + try + { + var response = _iotOperationsBrokerBrokerRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsBrokerResource(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 + /// BrokerResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerResource.Delete"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerBrokerRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(_iotOperationsBrokerBrokerClientDiagnostics, Pipeline, _iotOperationsBrokerBrokerRestClient.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 + /// BrokerResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerResource.Delete"); + scope.Start(); + try + { + var response = _iotOperationsBrokerBrokerRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IotOperationsArmOperation(_iotOperationsBrokerBrokerClientDiagnostics, Pipeline, _iotOperationsBrokerBrokerRestClient.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 + /// BrokerResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerResource.Update"); + scope.Start(); + try + { + var response = await _iotOperationsBrokerBrokerRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerOperationSource(Client), _iotOperationsBrokerBrokerClientDiagnostics, Pipeline, _iotOperationsBrokerBrokerRestClient.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 + /// BrokerResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsBrokerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsBrokerBrokerClientDiagnostics.CreateScope("IotOperationsBrokerResource.Update"); + scope.Start(); + try + { + var response = _iotOperationsBrokerBrokerRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsBrokerOperationSource(Client), _iotOperationsBrokerBrokerClientDiagnostics, Pipeline, _iotOperationsBrokerBrokerRestClient.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/IotOperationsDataflowCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowCollection.cs new file mode 100644 index 00000000000000..ea521ae9658eb8 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowCollection.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 an instance call the GetIotOperationsDataflows method from an instance of . + /// + public partial class IotOperationsDataflowCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _iotOperationsDataflowDataflowClientDiagnostics; + private readonly DataflowRestOperations _iotOperationsDataflowDataflowRestClient; + + /// Initializes a new instance of the class for mocking. + protected IotOperationsDataflowCollection() + { + } + + /// 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 IotOperationsDataflowCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsDataflowDataflowClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", IotOperationsDataflowResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(IotOperationsDataflowResource.ResourceType, out string iotOperationsDataflowDataflowApiVersion); + _iotOperationsDataflowDataflowRestClient = new DataflowRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsDataflowDataflowApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != IotOperationsDataflowProfileResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, IotOperationsDataflowProfileResource.ResourceType), nameof(id)); + } + + /// + /// Create a DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// DataflowResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowDataflowRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowOperationSource(Client), _iotOperationsDataflowDataflowClientDiagnostics, Pipeline, _iotOperationsDataflowDataflowRestClient.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 + /// DataflowResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowName, nameof(dataflowName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _iotOperationsDataflowDataflowRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, dataflowName, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowOperationSource(Client), _iotOperationsDataflowDataflowClientDiagnostics, Pipeline, _iotOperationsDataflowDataflowRestClient.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 + /// DataflowResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowCollection.Get"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowDataflowRestClient.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 IotOperationsDataflowResource(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 + /// DataflowResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowCollection.Get"); + scope.Start(); + try + { + var response = _iotOperationsDataflowDataflowRestClient.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 IotOperationsDataflowResource(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-11-01 + /// + /// + /// 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) => _iotOperationsDataflowDataflowRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsDataflowDataflowRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new IotOperationsDataflowResource(Client, IotOperationsDataflowData.DeserializeIotOperationsDataflowData(e)), _iotOperationsDataflowDataflowClientDiagnostics, Pipeline, "IotOperationsDataflowCollection.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-11-01 + /// + /// + /// 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) => _iotOperationsDataflowDataflowRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsDataflowDataflowRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new IotOperationsDataflowResource(Client, IotOperationsDataflowData.DeserializeIotOperationsDataflowData(e)), _iotOperationsDataflowDataflowClientDiagnostics, Pipeline, "IotOperationsDataflowCollection.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 + /// DataflowResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowCollection.Exists"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowDataflowRestClient.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 + /// DataflowResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowCollection.Exists"); + scope.Start(); + try + { + var response = _iotOperationsDataflowDataflowRestClient.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 + /// DataflowResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowDataflowRestClient.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 IotOperationsDataflowResource(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 + /// DataflowResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowCollection.GetIfExists"); + scope.Start(); + try + { + var response = _iotOperationsDataflowDataflowRestClient.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 IotOperationsDataflowResource(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/IotOperationsDataflowData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowData.Serialization.cs new file mode 100644 index 00000000000000..3f49118f12b866 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowData.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; +using Azure.ResourceManager.IotOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IotOperations +{ + public partial class IotOperationsDataflowData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsDataflowData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + } + + IotOperationsDataflowData 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(IotOperationsDataflowData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsDataflowData(document.RootElement, options); + } + + internal static IotOperationsDataflowData DeserializeIotOperationsDataflowData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsDataflowProperties properties = default; + IotOperationsExtendedLocation 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 = IotOperationsDataflowProperties.DeserializeIotOperationsDataflowProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = IotOperationsExtendedLocation.DeserializeIotOperationsExtendedLocation(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 IotOperationsDataflowData( + 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(IotOperationsDataflowData)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsDataflowData 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 DeserializeIotOperationsDataflowData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsDataflowData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowData.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowData.cs new file mode 100644 index 00000000000000..abd28844e81758 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowData.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 IotOperationsDataflow data model. + /// Instance dataflowProfile dataflow resource + /// + public partial class IotOperationsDataflowData : 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 IotOperationsDataflowData(IotOperationsExtendedLocation 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 IotOperationsDataflowData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IotOperationsDataflowProperties properties, IotOperationsExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsDataflowData() + { + } + + /// The resource-specific properties for this resource. + public IotOperationsDataflowProperties Properties { get; set; } + /// Edge location of the resource. + public IotOperationsExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointCollection.cs new file mode 100644 index 00000000000000..79d1d438bc3f71 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointCollection.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 an instance call the GetIotOperationsDataflowEndpoints method from an instance of . + /// + public partial class IotOperationsDataflowEndpointCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics; + private readonly DataflowEndpointRestOperations _iotOperationsDataflowEndpointDataflowEndpointRestClient; + + /// Initializes a new instance of the class for mocking. + protected IotOperationsDataflowEndpointCollection() + { + } + + /// 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 IotOperationsDataflowEndpointCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", IotOperationsDataflowEndpointResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(IotOperationsDataflowEndpointResource.ResourceType, out string iotOperationsDataflowEndpointDataflowEndpointApiVersion); + _iotOperationsDataflowEndpointDataflowEndpointRestClient = new DataflowEndpointRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsDataflowEndpointDataflowEndpointApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != IotOperationsInstanceResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, IotOperationsInstanceResource.ResourceType), nameof(id)); + } + + /// + /// Create a DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpointResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowEndpointData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowEndpointDataflowEndpointRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowEndpointOperationSource(Client), _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics, Pipeline, _iotOperationsDataflowEndpointDataflowEndpointRestClient.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 + /// DataflowEndpointResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowEndpointData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowEndpointName, nameof(dataflowEndpointName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _iotOperationsDataflowEndpointDataflowEndpointRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowEndpointOperationSource(Client), _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics, Pipeline, _iotOperationsDataflowEndpointDataflowEndpointRestClient.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 + /// DataflowEndpointResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointCollection.Get"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowEndpointDataflowEndpointRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsDataflowEndpointResource(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 + /// DataflowEndpointResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointCollection.Get"); + scope.Start(); + try + { + var response = _iotOperationsDataflowEndpointDataflowEndpointRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsDataflowEndpointResource(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-11-01 + /// + /// + /// 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) => _iotOperationsDataflowEndpointDataflowEndpointRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsDataflowEndpointDataflowEndpointRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new IotOperationsDataflowEndpointResource(Client, IotOperationsDataflowEndpointData.DeserializeIotOperationsDataflowEndpointData(e)), _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics, Pipeline, "IotOperationsDataflowEndpointCollection.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-11-01 + /// + /// + /// 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) => _iotOperationsDataflowEndpointDataflowEndpointRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsDataflowEndpointDataflowEndpointRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new IotOperationsDataflowEndpointResource(Client, IotOperationsDataflowEndpointData.DeserializeIotOperationsDataflowEndpointData(e)), _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics, Pipeline, "IotOperationsDataflowEndpointCollection.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 + /// DataflowEndpointResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointCollection.Exists"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowEndpointDataflowEndpointRestClient.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 + /// DataflowEndpointResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointCollection.Exists"); + scope.Start(); + try + { + var response = _iotOperationsDataflowEndpointDataflowEndpointRestClient.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 + /// DataflowEndpointResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowEndpointDataflowEndpointRestClient.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 IotOperationsDataflowEndpointResource(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 + /// DataflowEndpointResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointCollection.GetIfExists"); + scope.Start(); + try + { + var response = _iotOperationsDataflowEndpointDataflowEndpointRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowEndpointName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new IotOperationsDataflowEndpointResource(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/IotOperationsDataflowEndpointData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointData.Serialization.cs new file mode 100644 index 00000000000000..cd3778eba67680 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointData.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; +using Azure.ResourceManager.IotOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IotOperations +{ + public partial class IotOperationsDataflowEndpointData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsDataflowEndpointData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + } + + IotOperationsDataflowEndpointData 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(IotOperationsDataflowEndpointData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsDataflowEndpointData(document.RootElement, options); + } + + internal static IotOperationsDataflowEndpointData DeserializeIotOperationsDataflowEndpointData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsDataflowEndpointProperties properties = default; + IotOperationsExtendedLocation 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 = IotOperationsDataflowEndpointProperties.DeserializeIotOperationsDataflowEndpointProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = IotOperationsExtendedLocation.DeserializeIotOperationsExtendedLocation(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 IotOperationsDataflowEndpointData( + 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(IotOperationsDataflowEndpointData)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsDataflowEndpointData 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 DeserializeIotOperationsDataflowEndpointData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsDataflowEndpointData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointData.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointData.cs new file mode 100644 index 00000000000000..172ce3cefd8a76 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointData.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 IotOperationsDataflowEndpoint data model. + /// Instance dataflowEndpoint resource + /// + public partial class IotOperationsDataflowEndpointData : 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 IotOperationsDataflowEndpointData(IotOperationsExtendedLocation 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 IotOperationsDataflowEndpointData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IotOperationsDataflowEndpointProperties properties, IotOperationsExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsDataflowEndpointData() + { + } + + /// The resource-specific properties for this resource. + public IotOperationsDataflowEndpointProperties Properties { get; set; } + /// Edge location of the resource. + public IotOperationsExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointResource.Serialization.cs new file mode 100644 index 00000000000000..134a9923576c27 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointResource.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 IotOperationsDataflowEndpointResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + IotOperationsDataflowEndpointData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + IotOperationsDataflowEndpointData 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/IotOperationsDataflowEndpointResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointResource.cs new file mode 100644 index 00000000000000..ec4dc201e2ef1b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowEndpointResource.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 an IotOperationsDataflowEndpoint 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 GetIotOperationsDataflowEndpointResource method. + /// Otherwise you can get one from its parent resource using the GetIotOperationsDataflowEndpoint method. + /// + public partial class IotOperationsDataflowEndpointResource : 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 _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics; + private readonly DataflowEndpointRestOperations _iotOperationsDataflowEndpointDataflowEndpointRestClient; + private readonly IotOperationsDataflowEndpointData _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 IotOperationsDataflowEndpointResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal IotOperationsDataflowEndpointResource(ArmClient client, IotOperationsDataflowEndpointData 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 IotOperationsDataflowEndpointResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string iotOperationsDataflowEndpointDataflowEndpointApiVersion); + _iotOperationsDataflowEndpointDataflowEndpointRestClient = new DataflowEndpointRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsDataflowEndpointDataflowEndpointApiVersion); +#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 IotOperationsDataflowEndpointData 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 + /// DataflowEndpointResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointResource.Get"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowEndpointDataflowEndpointRestClient.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 IotOperationsDataflowEndpointResource(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 + /// DataflowEndpointResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointResource.Get"); + scope.Start(); + try + { + var response = _iotOperationsDataflowEndpointDataflowEndpointRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsDataflowEndpointResource(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 + /// DataflowEndpointResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointResource.Delete"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowEndpointDataflowEndpointRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(_iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics, Pipeline, _iotOperationsDataflowEndpointDataflowEndpointRestClient.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 + /// DataflowEndpointResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointResource.Delete"); + scope.Start(); + try + { + var response = _iotOperationsDataflowEndpointDataflowEndpointRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IotOperationsArmOperation(_iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics, Pipeline, _iotOperationsDataflowEndpointDataflowEndpointRestClient.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 + /// DataflowEndpointResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowEndpointData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointResource.Update"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowEndpointDataflowEndpointRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowEndpointOperationSource(Client), _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics, Pipeline, _iotOperationsDataflowEndpointDataflowEndpointRestClient.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 + /// DataflowEndpointResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowEndpointData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics.CreateScope("IotOperationsDataflowEndpointResource.Update"); + scope.Start(); + try + { + var response = _iotOperationsDataflowEndpointDataflowEndpointRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowEndpointOperationSource(Client), _iotOperationsDataflowEndpointDataflowEndpointClientDiagnostics, Pipeline, _iotOperationsDataflowEndpointDataflowEndpointRestClient.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/IotOperationsDataflowProfileCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileCollection.cs new file mode 100644 index 00000000000000..1fe882d1747284 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileCollection.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 an instance call the GetIotOperationsDataflowProfiles method from an instance of . + /// + public partial class IotOperationsDataflowProfileCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _iotOperationsDataflowProfileDataflowProfileClientDiagnostics; + private readonly DataflowProfileRestOperations _iotOperationsDataflowProfileDataflowProfileRestClient; + + /// Initializes a new instance of the class for mocking. + protected IotOperationsDataflowProfileCollection() + { + } + + /// 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 IotOperationsDataflowProfileCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsDataflowProfileDataflowProfileClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", IotOperationsDataflowProfileResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(IotOperationsDataflowProfileResource.ResourceType, out string iotOperationsDataflowProfileDataflowProfileApiVersion); + _iotOperationsDataflowProfileDataflowProfileRestClient = new DataflowProfileRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsDataflowProfileDataflowProfileApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != IotOperationsInstanceResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, IotOperationsInstanceResource.ResourceType), nameof(id)); + } + + /// + /// Create a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfileResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowProfileDataflowProfileRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowProfileOperationSource(Client), _iotOperationsDataflowProfileDataflowProfileClientDiagnostics, Pipeline, _iotOperationsDataflowProfileDataflowProfileRestClient.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 + /// DataflowProfileResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(dataflowProfileName, nameof(dataflowProfileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _iotOperationsDataflowProfileDataflowProfileRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowProfileOperationSource(Client), _iotOperationsDataflowProfileDataflowProfileClientDiagnostics, Pipeline, _iotOperationsDataflowProfileDataflowProfileRestClient.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 + /// DataflowProfileResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileCollection.Get"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowProfileDataflowProfileRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsDataflowProfileResource(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 + /// DataflowProfileResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileCollection.Get"); + scope.Start(); + try + { + var response = _iotOperationsDataflowProfileDataflowProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsDataflowProfileResource(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-11-01 + /// + /// + /// 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) => _iotOperationsDataflowProfileDataflowProfileRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsDataflowProfileDataflowProfileRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new IotOperationsDataflowProfileResource(Client, IotOperationsDataflowProfileData.DeserializeIotOperationsDataflowProfileData(e)), _iotOperationsDataflowProfileDataflowProfileClientDiagnostics, Pipeline, "IotOperationsDataflowProfileCollection.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-11-01 + /// + /// + /// 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) => _iotOperationsDataflowProfileDataflowProfileRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsDataflowProfileDataflowProfileRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new IotOperationsDataflowProfileResource(Client, IotOperationsDataflowProfileData.DeserializeIotOperationsDataflowProfileData(e)), _iotOperationsDataflowProfileDataflowProfileClientDiagnostics, Pipeline, "IotOperationsDataflowProfileCollection.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 + /// DataflowProfileResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileCollection.Exists"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowProfileDataflowProfileRestClient.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 + /// DataflowProfileResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileCollection.Exists"); + scope.Start(); + try + { + var response = _iotOperationsDataflowProfileDataflowProfileRestClient.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 + /// DataflowProfileResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowProfileDataflowProfileRestClient.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 IotOperationsDataflowProfileResource(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 + /// DataflowProfileResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileCollection.GetIfExists"); + scope.Start(); + try + { + var response = _iotOperationsDataflowProfileDataflowProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dataflowProfileName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new IotOperationsDataflowProfileResource(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/IotOperationsDataflowProfileData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileData.Serialization.cs new file mode 100644 index 00000000000000..1fc72c2b82f6d0 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileData.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; +using Azure.ResourceManager.IotOperations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IotOperations +{ + public partial class IotOperationsDataflowProfileData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsDataflowProfileData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + writer.WritePropertyName("extendedLocation"u8); + writer.WriteObjectValue(ExtendedLocation, options); + } + + IotOperationsDataflowProfileData 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(IotOperationsDataflowProfileData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsDataflowProfileData(document.RootElement, options); + } + + internal static IotOperationsDataflowProfileData DeserializeIotOperationsDataflowProfileData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsDataflowProfileProperties properties = default; + IotOperationsExtendedLocation 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 = IotOperationsDataflowProfileProperties.DeserializeIotOperationsDataflowProfileProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = IotOperationsExtendedLocation.DeserializeIotOperationsExtendedLocation(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 IotOperationsDataflowProfileData( + 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(IotOperationsDataflowProfileData)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsDataflowProfileData 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 DeserializeIotOperationsDataflowProfileData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsDataflowProfileData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileData.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileData.cs new file mode 100644 index 00000000000000..48f5678689d883 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileData.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 IotOperationsDataflowProfile data model. + /// Instance dataflowProfile resource + /// + public partial class IotOperationsDataflowProfileData : 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 IotOperationsDataflowProfileData(IotOperationsExtendedLocation 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 IotOperationsDataflowProfileData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IotOperationsDataflowProfileProperties properties, IotOperationsExtendedLocation extendedLocation, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ExtendedLocation = extendedLocation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsDataflowProfileData() + { + } + + /// The resource-specific properties for this resource. + public IotOperationsDataflowProfileProperties Properties { get; set; } + /// Edge location of the resource. + public IotOperationsExtendedLocation ExtendedLocation { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileResource.Serialization.cs new file mode 100644 index 00000000000000..250a017a1b7ec7 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileResource.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 IotOperationsDataflowProfileResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + IotOperationsDataflowProfileData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + IotOperationsDataflowProfileData 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/IotOperationsDataflowProfileResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileResource.cs new file mode 100644 index 00000000000000..291abc4283b7fa --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowProfileResource.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 an IotOperationsDataflowProfile 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 GetIotOperationsDataflowProfileResource method. + /// Otherwise you can get one from its parent resource using the GetIotOperationsDataflowProfile method. + /// + public partial class IotOperationsDataflowProfileResource : 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 _iotOperationsDataflowProfileDataflowProfileClientDiagnostics; + private readonly DataflowProfileRestOperations _iotOperationsDataflowProfileDataflowProfileRestClient; + private readonly IotOperationsDataflowProfileData _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 IotOperationsDataflowProfileResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal IotOperationsDataflowProfileResource(ArmClient client, IotOperationsDataflowProfileData 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 IotOperationsDataflowProfileResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsDataflowProfileDataflowProfileClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string iotOperationsDataflowProfileDataflowProfileApiVersion); + _iotOperationsDataflowProfileDataflowProfileRestClient = new DataflowProfileRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsDataflowProfileDataflowProfileApiVersion); +#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 IotOperationsDataflowProfileData 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 IotOperationsDataflowResources in the IotOperationsDataflowProfile. + /// An object representing collection of IotOperationsDataflowResources and their operations over a IotOperationsDataflowResource. + public virtual IotOperationsDataflowCollection GetIotOperationsDataflows() + { + return GetCachedClient(client => new IotOperationsDataflowCollection(client, Id)); + } + + /// + /// Get a DataflowResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName}/dataflows/{dataflowName} + /// + /// + /// Operation Id + /// DataflowResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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> GetIotOperationsDataflowAsync(string dataflowName, CancellationToken cancellationToken = default) + { + return await GetIotOperationsDataflows().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 + /// DataflowResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 GetIotOperationsDataflow(string dataflowName, CancellationToken cancellationToken = default) + { + return GetIotOperationsDataflows().Get(dataflowName, cancellationToken); + } + + /// + /// Get a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfileResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileResource.Get"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowProfileDataflowProfileRestClient.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 IotOperationsDataflowProfileResource(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 + /// DataflowProfileResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileResource.Get"); + scope.Start(); + try + { + var response = _iotOperationsDataflowProfileDataflowProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsDataflowProfileResource(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 + /// DataflowProfileResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileResource.Delete"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowProfileDataflowProfileRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(_iotOperationsDataflowProfileDataflowProfileClientDiagnostics, Pipeline, _iotOperationsDataflowProfileDataflowProfileRestClient.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 + /// DataflowProfileResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileResource.Delete"); + scope.Start(); + try + { + var response = _iotOperationsDataflowProfileDataflowProfileRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IotOperationsArmOperation(_iotOperationsDataflowProfileDataflowProfileClientDiagnostics, Pipeline, _iotOperationsDataflowProfileDataflowProfileRestClient.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 + /// DataflowProfileResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileResource.Update"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowProfileDataflowProfileRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowProfileOperationSource(Client), _iotOperationsDataflowProfileDataflowProfileClientDiagnostics, Pipeline, _iotOperationsDataflowProfileDataflowProfileRestClient.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 + /// DataflowProfileResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowProfileDataflowProfileClientDiagnostics.CreateScope("IotOperationsDataflowProfileResource.Update"); + scope.Start(); + try + { + var response = _iotOperationsDataflowProfileDataflowProfileRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowProfileOperationSource(Client), _iotOperationsDataflowProfileDataflowProfileClientDiagnostics, Pipeline, _iotOperationsDataflowProfileDataflowProfileRestClient.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/IotOperationsDataflowResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowResource.Serialization.cs new file mode 100644 index 00000000000000..9aba6ab29bc67f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowResource.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 IotOperationsDataflowResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + IotOperationsDataflowData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + IotOperationsDataflowData 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/IotOperationsDataflowResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowResource.cs new file mode 100644 index 00000000000000..779f4114c9f131 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsDataflowResource.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 an IotOperationsDataflow 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 GetIotOperationsDataflowResource method. + /// Otherwise you can get one from its parent resource using the GetIotOperationsDataflow method. + /// + public partial class IotOperationsDataflowResource : 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 _iotOperationsDataflowDataflowClientDiagnostics; + private readonly DataflowRestOperations _iotOperationsDataflowDataflowRestClient; + private readonly IotOperationsDataflowData _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 IotOperationsDataflowResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal IotOperationsDataflowResource(ArmClient client, IotOperationsDataflowData 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 IotOperationsDataflowResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsDataflowDataflowClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string iotOperationsDataflowDataflowApiVersion); + _iotOperationsDataflowDataflowRestClient = new DataflowRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsDataflowDataflowApiVersion); +#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 IotOperationsDataflowData 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 + /// DataflowResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowResource.Get"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowDataflowRestClient.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 IotOperationsDataflowResource(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 + /// DataflowResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowResource.Get"); + scope.Start(); + try + { + var response = _iotOperationsDataflowDataflowRestClient.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 IotOperationsDataflowResource(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 + /// DataflowResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowResource.Delete"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowDataflowRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(_iotOperationsDataflowDataflowClientDiagnostics, Pipeline, _iotOperationsDataflowDataflowRestClient.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 + /// DataflowResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowResource.Delete"); + scope.Start(); + try + { + var response = _iotOperationsDataflowDataflowRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new IotOperationsArmOperation(_iotOperationsDataflowDataflowClientDiagnostics, Pipeline, _iotOperationsDataflowDataflowRestClient.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 + /// DataflowResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowResource.Update"); + scope.Start(); + try + { + var response = await _iotOperationsDataflowDataflowRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowOperationSource(Client), _iotOperationsDataflowDataflowClientDiagnostics, Pipeline, _iotOperationsDataflowDataflowRestClient.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 + /// DataflowResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsDataflowData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsDataflowDataflowClientDiagnostics.CreateScope("IotOperationsDataflowResource.Update"); + scope.Start(); + try + { + var response = _iotOperationsDataflowDataflowRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsDataflowOperationSource(Client), _iotOperationsDataflowDataflowClientDiagnostics, Pipeline, _iotOperationsDataflowDataflowRestClient.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/IotOperationsInstanceCollection.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceCollection.cs new file mode 100644 index 00000000000000..31af78f0ebba0b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceCollection.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 GetIotOperationsInstances method from an instance of . + /// + public partial class IotOperationsInstanceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _iotOperationsInstanceInstanceClientDiagnostics; + private readonly InstanceRestOperations _iotOperationsInstanceInstanceRestClient; + + /// Initializes a new instance of the class for mocking. + protected IotOperationsInstanceCollection() + { + } + + /// 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 IotOperationsInstanceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsInstanceInstanceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", IotOperationsInstanceResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(IotOperationsInstanceResource.ResourceType, out string iotOperationsInstanceInstanceApiVersion); + _iotOperationsInstanceInstanceRestClient = new InstanceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsInstanceInstanceApiVersion); +#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 + /// InstanceResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsInstanceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _iotOperationsInstanceInstanceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, instanceName, data, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(new IotOperationsInstanceOperationSource(Client), _iotOperationsInstanceInstanceClientDiagnostics, Pipeline, _iotOperationsInstanceInstanceRestClient.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 + /// InstanceResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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, IotOperationsInstanceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(instanceName, nameof(instanceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _iotOperationsInstanceInstanceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, instanceName, data, cancellationToken); + var operation = new IotOperationsArmOperation(new IotOperationsInstanceOperationSource(Client), _iotOperationsInstanceInstanceClientDiagnostics, Pipeline, _iotOperationsInstanceInstanceRestClient.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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceCollection.Get"); + scope.Start(); + try + { + var response = await _iotOperationsInstanceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, instanceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsInstanceResource(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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceCollection.Get"); + scope.Start(); + try + { + var response = _iotOperationsInstanceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, instanceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsInstanceResource(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-11-01 + /// + /// + /// 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) => _iotOperationsInstanceInstanceRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsInstanceInstanceRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new IotOperationsInstanceResource(Client, IotOperationsInstanceData.DeserializeIotOperationsInstanceData(e)), _iotOperationsInstanceInstanceClientDiagnostics, Pipeline, "IotOperationsInstanceCollection.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-11-01 + /// + /// + /// 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) => _iotOperationsInstanceInstanceRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _iotOperationsInstanceInstanceRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new IotOperationsInstanceResource(Client, IotOperationsInstanceData.DeserializeIotOperationsInstanceData(e)), _iotOperationsInstanceInstanceClientDiagnostics, Pipeline, "IotOperationsInstanceCollection.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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceCollection.Exists"); + scope.Start(); + try + { + var response = await _iotOperationsInstanceInstanceRestClient.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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceCollection.Exists"); + scope.Start(); + try + { + var response = _iotOperationsInstanceInstanceRestClient.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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _iotOperationsInstanceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, instanceName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new IotOperationsInstanceResource(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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _iotOperationsInstanceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, instanceName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new IotOperationsInstanceResource(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/IotOperationsInstanceData.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceData.Serialization.cs new file mode 100644 index 00000000000000..542579816b417e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceData.Serialization.cs @@ -0,0 +1,205 @@ +// 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 IotOperationsInstanceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsInstanceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + 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); + } + } + + IotOperationsInstanceData 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(IotOperationsInstanceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsInstanceData(document.RootElement, options); + } + + internal static IotOperationsInstanceData DeserializeIotOperationsInstanceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsInstanceProperties properties = default; + IotOperationsExtendedLocation 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 = IotOperationsInstanceProperties.DeserializeIotOperationsInstanceProperties(property.Value, options); + continue; + } + if (property.NameEquals("extendedLocation"u8)) + { + extendedLocation = IotOperationsExtendedLocation.DeserializeIotOperationsExtendedLocation(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 IotOperationsInstanceData( + 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(IotOperationsInstanceData)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsInstanceData 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 DeserializeIotOperationsInstanceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsInstanceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceData.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceData.cs new file mode 100644 index 00000000000000..0404cfc0c24f53 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceData.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 IotOperationsInstance data model. + /// A Instance resource is a logical container for a set of child resources. + /// + public partial class IotOperationsInstanceData : 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 IotOperationsInstanceData(AzureLocation location, IotOperationsExtendedLocation 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 IotOperationsInstanceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, IotOperationsInstanceProperties properties, IotOperationsExtendedLocation 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 IotOperationsInstanceData() + { + } + + /// The resource-specific properties for this resource. + public IotOperationsInstanceProperties Properties { get; set; } + /// Edge location of the resource. + public IotOperationsExtendedLocation 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/IotOperationsInstanceResource.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceResource.Serialization.cs new file mode 100644 index 00000000000000..8ee31f10212f51 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceResource.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 IotOperationsInstanceResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + IotOperationsInstanceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + IotOperationsInstanceData 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/IotOperationsInstanceResource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceResource.cs new file mode 100644 index 00000000000000..eb00248a5e7827 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/IotOperationsInstanceResource.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 IotOperationsInstance 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 GetIotOperationsInstanceResource method. + /// Otherwise you can get one from its parent resource using the GetIotOperationsInstance method. + /// + public partial class IotOperationsInstanceResource : 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 _iotOperationsInstanceInstanceClientDiagnostics; + private readonly InstanceRestOperations _iotOperationsInstanceInstanceRestClient; + private readonly IotOperationsInstanceData _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 IotOperationsInstanceResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal IotOperationsInstanceResource(ArmClient client, IotOperationsInstanceData 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 IotOperationsInstanceResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _iotOperationsInstanceInstanceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.IotOperations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string iotOperationsInstanceInstanceApiVersion); + _iotOperationsInstanceInstanceRestClient = new InstanceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, iotOperationsInstanceInstanceApiVersion); +#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 IotOperationsInstanceData 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 IotOperationsBrokerResources in the IotOperationsInstance. + /// An object representing collection of IotOperationsBrokerResources and their operations over a IotOperationsBrokerResource. + public virtual IotOperationsBrokerCollection GetIotOperationsBrokers() + { + return GetCachedClient(client => new IotOperationsBrokerCollection(client, Id)); + } + + /// + /// Get a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// BrokerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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> GetIotOperationsBrokerAsync(string brokerName, CancellationToken cancellationToken = default) + { + return await GetIotOperationsBrokers().GetAsync(brokerName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a BrokerResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/brokers/{brokerName} + /// + /// + /// Operation Id + /// BrokerResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 GetIotOperationsBroker(string brokerName, CancellationToken cancellationToken = default) + { + return GetIotOperationsBrokers().Get(brokerName, cancellationToken); + } + + /// Gets a collection of IotOperationsDataflowProfileResources in the IotOperationsInstance. + /// An object representing collection of IotOperationsDataflowProfileResources and their operations over a IotOperationsDataflowProfileResource. + public virtual IotOperationsDataflowProfileCollection GetIotOperationsDataflowProfiles() + { + return GetCachedClient(client => new IotOperationsDataflowProfileCollection(client, Id)); + } + + /// + /// Get a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfileResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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> GetIotOperationsDataflowProfileAsync(string dataflowProfileName, CancellationToken cancellationToken = default) + { + return await GetIotOperationsDataflowProfiles().GetAsync(dataflowProfileName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a DataflowProfileResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowProfiles/{dataflowProfileName} + /// + /// + /// Operation Id + /// DataflowProfileResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 GetIotOperationsDataflowProfile(string dataflowProfileName, CancellationToken cancellationToken = default) + { + return GetIotOperationsDataflowProfiles().Get(dataflowProfileName, cancellationToken); + } + + /// Gets a collection of IotOperationsDataflowEndpointResources in the IotOperationsInstance. + /// An object representing collection of IotOperationsDataflowEndpointResources and their operations over a IotOperationsDataflowEndpointResource. + public virtual IotOperationsDataflowEndpointCollection GetIotOperationsDataflowEndpoints() + { + return GetCachedClient(client => new IotOperationsDataflowEndpointCollection(client, Id)); + } + + /// + /// Get a DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpointResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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> GetIotOperationsDataflowEndpointAsync(string dataflowEndpointName, CancellationToken cancellationToken = default) + { + return await GetIotOperationsDataflowEndpoints().GetAsync(dataflowEndpointName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a DataflowEndpointResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName}/dataflowEndpoints/{dataflowEndpointName} + /// + /// + /// Operation Id + /// DataflowEndpointResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 GetIotOperationsDataflowEndpoint(string dataflowEndpointName, CancellationToken cancellationToken = default) + { + return GetIotOperationsDataflowEndpoints().Get(dataflowEndpointName, cancellationToken); + } + + /// + /// Get a InstanceResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IoTOperations/instances/{instanceName} + /// + /// + /// Operation Id + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.Get"); + scope.Start(); + try + { + var response = await _iotOperationsInstanceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsInstanceResource(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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.Get"); + scope.Start(); + try + { + var response = _iotOperationsInstanceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new IotOperationsInstanceResource(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 + /// InstanceResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.Delete"); + scope.Start(); + try + { + var response = await _iotOperationsInstanceInstanceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new IotOperationsArmOperation(_iotOperationsInstanceInstanceClientDiagnostics, Pipeline, _iotOperationsInstanceInstanceRestClient.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 + /// InstanceResource_Delete + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.Delete"); + scope.Start(); + try + { + var response = _iotOperationsInstanceInstanceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new IotOperationsArmOperation(_iotOperationsInstanceInstanceClientDiagnostics, Pipeline, _iotOperationsInstanceInstanceRestClient.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 + /// InstanceResource_Update + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(IotOperationsInstancePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.Update"); + scope.Start(); + try + { + var response = await _iotOperationsInstanceInstanceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new IotOperationsInstanceResource(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 + /// InstanceResource_Update + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(IotOperationsInstancePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.Update"); + scope.Start(); + try + { + var response = _iotOperationsInstanceInstanceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + return Response.FromValue(new IotOperationsInstanceResource(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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.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 _iotOperationsInstanceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new IotOperationsInstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new IotOperationsInstancePatch(); + 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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.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 = _iotOperationsInstanceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new IotOperationsInstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new IotOperationsInstancePatch(); + 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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.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 _iotOperationsInstanceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new IotOperationsInstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new IotOperationsInstancePatch(); + 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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.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 = _iotOperationsInstanceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new IotOperationsInstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new IotOperationsInstancePatch(); + 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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.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 _iotOperationsInstanceInstanceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new IotOperationsInstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new IotOperationsInstancePatch(); + 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 + /// InstanceResource_Get + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// 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 = _iotOperationsInstanceInstanceClientDiagnostics.CreateScope("IotOperationsInstanceResource.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 = _iotOperationsInstanceInstanceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new IotOperationsInstanceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new IotOperationsInstancePatch(); + 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/LongRunningOperation/IotOperationsArmOperation.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsArmOperation.cs new file mode 100644 index 00000000000000..76eb16afee48ba --- /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 00000000000000..ecfddb26d15960 --- /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/LongRunningOperation/IotOperationsBrokerAuthenticationOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerAuthenticationOperationSource.cs new file mode 100644 index 00000000000000..c14ba0d9215878 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerAuthenticationOperationSource.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 IotOperationsBrokerAuthenticationOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal IotOperationsBrokerAuthenticationOperationSource(ArmClient client) + { + _client = client; + } + + IotOperationsBrokerAuthenticationResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = IotOperationsBrokerAuthenticationData.DeserializeIotOperationsBrokerAuthenticationData(document.RootElement); + return new IotOperationsBrokerAuthenticationResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = IotOperationsBrokerAuthenticationData.DeserializeIotOperationsBrokerAuthenticationData(document.RootElement); + return new IotOperationsBrokerAuthenticationResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerAuthorizationOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerAuthorizationOperationSource.cs new file mode 100644 index 00000000000000..1902b4f8d295b3 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerAuthorizationOperationSource.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 IotOperationsBrokerAuthorizationOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal IotOperationsBrokerAuthorizationOperationSource(ArmClient client) + { + _client = client; + } + + IotOperationsBrokerAuthorizationResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = IotOperationsBrokerAuthorizationData.DeserializeIotOperationsBrokerAuthorizationData(document.RootElement); + return new IotOperationsBrokerAuthorizationResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = IotOperationsBrokerAuthorizationData.DeserializeIotOperationsBrokerAuthorizationData(document.RootElement); + return new IotOperationsBrokerAuthorizationResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerListenerOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerListenerOperationSource.cs new file mode 100644 index 00000000000000..a9816e0d9ad527 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerListenerOperationSource.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 IotOperationsBrokerListenerOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal IotOperationsBrokerListenerOperationSource(ArmClient client) + { + _client = client; + } + + IotOperationsBrokerListenerResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = IotOperationsBrokerListenerData.DeserializeIotOperationsBrokerListenerData(document.RootElement); + return new IotOperationsBrokerListenerResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = IotOperationsBrokerListenerData.DeserializeIotOperationsBrokerListenerData(document.RootElement); + return new IotOperationsBrokerListenerResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerOperationSource.cs new file mode 100644 index 00000000000000..ee053d696ac5dd --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsBrokerOperationSource.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 IotOperationsBrokerOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal IotOperationsBrokerOperationSource(ArmClient client) + { + _client = client; + } + + IotOperationsBrokerResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = IotOperationsBrokerData.DeserializeIotOperationsBrokerData(document.RootElement); + return new IotOperationsBrokerResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = IotOperationsBrokerData.DeserializeIotOperationsBrokerData(document.RootElement); + return new IotOperationsBrokerResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowEndpointOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowEndpointOperationSource.cs new file mode 100644 index 00000000000000..3ce58ca9a9cdeb --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowEndpointOperationSource.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 IotOperationsDataflowEndpointOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal IotOperationsDataflowEndpointOperationSource(ArmClient client) + { + _client = client; + } + + IotOperationsDataflowEndpointResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = IotOperationsDataflowEndpointData.DeserializeIotOperationsDataflowEndpointData(document.RootElement); + return new IotOperationsDataflowEndpointResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = IotOperationsDataflowEndpointData.DeserializeIotOperationsDataflowEndpointData(document.RootElement); + return new IotOperationsDataflowEndpointResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowOperationSource.cs new file mode 100644 index 00000000000000..237f20f0ef1cff --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowOperationSource.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 IotOperationsDataflowOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal IotOperationsDataflowOperationSource(ArmClient client) + { + _client = client; + } + + IotOperationsDataflowResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = IotOperationsDataflowData.DeserializeIotOperationsDataflowData(document.RootElement); + return new IotOperationsDataflowResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = IotOperationsDataflowData.DeserializeIotOperationsDataflowData(document.RootElement); + return new IotOperationsDataflowResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowProfileOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowProfileOperationSource.cs new file mode 100644 index 00000000000000..1b49a4d68e5e82 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsDataflowProfileOperationSource.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 IotOperationsDataflowProfileOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal IotOperationsDataflowProfileOperationSource(ArmClient client) + { + _client = client; + } + + IotOperationsDataflowProfileResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = IotOperationsDataflowProfileData.DeserializeIotOperationsDataflowProfileData(document.RootElement); + return new IotOperationsDataflowProfileResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = IotOperationsDataflowProfileData.DeserializeIotOperationsDataflowProfileData(document.RootElement); + return new IotOperationsDataflowProfileResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsInstanceOperationSource.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsInstanceOperationSource.cs new file mode 100644 index 00000000000000..62418aa7bcdb8b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/LongRunningOperation/IotOperationsInstanceOperationSource.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 IotOperationsInstanceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal IotOperationsInstanceOperationSource(ArmClient client) + { + _client = client; + } + + IotOperationsInstanceResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = IotOperationsInstanceData.DeserializeIotOperationsInstanceData(document.RootElement); + return new IotOperationsInstanceResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = IotOperationsInstanceData.DeserializeIotOperationsInstanceData(document.RootElement); + return new IotOperationsInstanceResource(_client, data); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BlockerListenerServiceType.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BlockerListenerServiceType.cs new file mode 100644 index 00000000000000..d94787a6930cf3 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BlockerListenerServiceType.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 BlockerListenerServiceType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public BlockerListenerServiceType(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 BlockerListenerServiceType ClusterIP { get; } = new BlockerListenerServiceType(ClusterIPValue); + /// Load Balancer Service. + public static BlockerListenerServiceType LoadBalancer { get; } = new BlockerListenerServiceType(LoadBalancerValue); + /// Node Port Service. + public static BlockerListenerServiceType NodePort { get; } = new BlockerListenerServiceType(NodePortValue); + /// Determines if two values are the same. + public static bool operator ==(BlockerListenerServiceType left, BlockerListenerServiceType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(BlockerListenerServiceType left, BlockerListenerServiceType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator BlockerListenerServiceType(string value) => new BlockerListenerServiceType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is BlockerListenerServiceType other && Equals(other); + /// + public bool Equals(BlockerListenerServiceType 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/BrokerAdvancedSettings.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAdvancedSettings.Serialization.cs new file mode 100644 index 00000000000000..c09de310ee2d6b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAdvancedSettings.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 BrokerAdvancedSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAdvancedSettings)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + BrokerAdvancedSettings 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(BrokerAdvancedSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAdvancedSettings(document.RootElement, options); + } + + internal static BrokerAdvancedSettings DeserializeBrokerAdvancedSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrokerClientConfig clients = default; + IotOperationsOperationalMode? encryptInternalTraffic = default; + CertManagerCertConfig 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 = BrokerClientConfig.DeserializeBrokerClientConfig(property.Value, options); + continue; + } + if (property.NameEquals("encryptInternalTraffic"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + encryptInternalTraffic = new IotOperationsOperationalMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("internalCerts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + internalCerts = CertManagerCertConfig.DeserializeCertManagerCertConfig(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerAdvancedSettings(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(BrokerAdvancedSettings)} does not support writing '{options.Format}' format."); + } + } + + BrokerAdvancedSettings 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 DeserializeBrokerAdvancedSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAdvancedSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAdvancedSettings.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAdvancedSettings.cs new file mode 100644 index 00000000000000..35a5069ce688f1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAdvancedSettings.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 BrokerAdvancedSettings + { + /// + /// 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 BrokerAdvancedSettings() + { + } + + /// 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 BrokerAdvancedSettings(BrokerClientConfig clients, IotOperationsOperationalMode? encryptInternalTraffic, CertManagerCertConfig internalCerts, IDictionary serializedAdditionalRawData) + { + Clients = clients; + EncryptInternalTraffic = encryptInternalTraffic; + InternalCerts = internalCerts; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Configurations related to All Clients. + public BrokerClientConfig Clients { get; set; } + /// The setting to enable or disable encryption of internal Traffic. + public IotOperationsOperationalMode? EncryptInternalTraffic { get; set; } + /// Certificate rotation and private key configuration. + public CertManagerCertConfig InternalCerts { 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 00000000000000..f4c44714395d79 --- /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 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/BrokerAuthenticationResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthenticationResourceListResult.Serialization.cs new file mode 100644 index 00000000000000..dc43d1d261c6b7 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthenticationResourceListResult.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 +{ + internal partial class BrokerAuthenticationResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticationResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + 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(IotOperationsBrokerAuthenticationData.DeserializeIotOperationsBrokerAuthenticationData(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 00000000000000..490f6de6423e77 --- /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 00000000000000..8aff2d3d95d38c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthenticatorCustomAuth.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 BrokerAuthenticatorCustomAuth : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorCustomAuth)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..566f55bde393f1 --- /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 00000000000000..045f8bec53986e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthenticatorMethodCustom.Serialization.cs @@ -0,0 +1,178 @@ +// 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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodCustom)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..7f83250cb593d2 --- /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 00000000000000..9ddfcd18fb7950 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthenticatorMethodSat.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodSat)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..d6445de8f25b32 --- /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 00000000000000..8eb30c57f94595 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthenticatorMethodX509.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 BrokerAuthenticatorMethodX509 : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodX509)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..5157f1ffb56d2c --- /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 00000000000000..673865431e915d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthenticatorMethodX509Attributes.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 BrokerAuthenticatorMethodX509Attributes : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethodX509Attributes)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..8a10d92bf426fe --- /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 00000000000000..e2a8de2ac8a6cd --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthenticatorMethods.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 BrokerAuthenticatorMethods : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthenticatorMethods)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..da2e4179d2d8db --- /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/BrokerAuthorizationConfig.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationConfig.Serialization.cs new file mode 100644 index 00000000000000..80f23b170635e5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationConfig.Serialization.cs @@ -0,0 +1,158 @@ +// 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 BrokerAuthorizationConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthorizationConfig)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + BrokerAuthorizationConfig 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(BrokerAuthorizationConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthorizationConfig(document.RootElement, options); + } + + internal static BrokerAuthorizationConfig DeserializeBrokerAuthorizationConfig(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsOperationalMode? 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 IotOperationsOperationalMode(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(BrokerAuthorizationRule.DeserializeBrokerAuthorizationRule(item, options)); + } + rules = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerAuthorizationConfig(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(BrokerAuthorizationConfig)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthorizationConfig 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 DeserializeBrokerAuthorizationConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthorizationConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationConfig.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationConfig.cs new file mode 100644 index 00000000000000..eb18fe4d4b4fda --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationConfig.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 BrokerAuthorizationConfig + { + /// + /// 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 BrokerAuthorizationConfig() + { + 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 BrokerAuthorizationConfig(IotOperationsOperationalMode? cache, IList rules, IDictionary serializedAdditionalRawData) + { + Cache = cache; + Rules = rules; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Enable caching of the authorization rules. + public IotOperationsOperationalMode? 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/BrokerAuthorizationResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationResourceListResult.Serialization.cs new file mode 100644 index 00000000000000..d3ffbb498f3036 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationResourceListResult.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 +{ + internal partial class BrokerAuthorizationResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthorizationResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + 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(IotOperationsBrokerAuthorizationData.DeserializeIotOperationsBrokerAuthorizationData(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 00000000000000..dd5e8858db80d4 --- /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/BrokerAuthorizationRule.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationRule.Serialization.cs new file mode 100644 index 00000000000000..f6c2fac8908635 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationRule.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 BrokerAuthorizationRule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerAuthorizationRule)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + BrokerAuthorizationRule 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(BrokerAuthorizationRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerAuthorizationRule(document.RootElement, options); + } + + internal static BrokerAuthorizationRule DeserializeBrokerAuthorizationRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList brokerResources = default; + PrincipalConfig 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 = PrincipalConfig.DeserializePrincipalConfig(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 BrokerAuthorizationRule(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(BrokerAuthorizationRule)} does not support writing '{options.Format}' format."); + } + } + + BrokerAuthorizationRule 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 DeserializeBrokerAuthorizationRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerAuthorizationRule)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationRule.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationRule.cs new file mode 100644 index 00000000000000..9fb432abb78a98 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerAuthorizationRule.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 BrokerAuthorizationRule + { + /// + /// 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 BrokerAuthorizationRule(IEnumerable brokerResources, PrincipalConfig 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 BrokerAuthorizationRule(IList brokerResources, PrincipalConfig principals, IList stateStoreResources, IDictionary serializedAdditionalRawData) + { + BrokerResources = brokerResources; + Principals = principals; + StateStoreResources = stateStoreResources; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerAuthorizationRule() + { + } + + /// Give access to Broker methods and topics. + public IList BrokerResources { get; } + /// Give access to clients based on the following properties. + public PrincipalConfig Principals { get; set; } + /// Give access to state store resources. + public IList StateStoreResources { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerBackendChain.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerBackendChain.Serialization.cs new file mode 100644 index 00000000000000..48c08606cced29 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerBackendChain.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 BrokerBackendChain : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerBackendChain)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + BrokerBackendChain 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(BrokerBackendChain)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerBackendChain(document.RootElement, options); + } + + internal static BrokerBackendChain DeserializeBrokerBackendChain(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 BrokerBackendChain(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(BrokerBackendChain)} does not support writing '{options.Format}' format."); + } + } + + BrokerBackendChain 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 DeserializeBrokerBackendChain(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerBackendChain)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerBackendChain.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerBackendChain.cs new file mode 100644 index 00000000000000..baaf6d24062d21 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerBackendChain.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 BrokerBackendChain + { + /// + /// 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 BrokerBackendChain(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 BrokerBackendChain(int partitions, int redundancyFactor, int? workers, IDictionary serializedAdditionalRawData) + { + Partitions = partitions; + RedundancyFactor = redundancyFactor; + Workers = workers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerBackendChain() + { + } + + /// 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/BrokerCardinality.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerCardinality.Serialization.cs new file mode 100644 index 00000000000000..52f5c57d001b37 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerCardinality.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 BrokerCardinality : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerCardinality)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + BrokerCardinality 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(BrokerCardinality)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerCardinality(document.RootElement, options); + } + + internal static BrokerCardinality DeserializeBrokerCardinality(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrokerBackendChain backendChain = default; + BrokerFrontend frontend = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("backendChain"u8)) + { + backendChain = BrokerBackendChain.DeserializeBrokerBackendChain(property.Value, options); + continue; + } + if (property.NameEquals("frontend"u8)) + { + frontend = BrokerFrontend.DeserializeBrokerFrontend(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrokerCardinality(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(BrokerCardinality)} does not support writing '{options.Format}' format."); + } + } + + BrokerCardinality 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 DeserializeBrokerCardinality(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerCardinality)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerCardinality.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerCardinality.cs new file mode 100644 index 00000000000000..b23711cf287a91 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerCardinality.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 BrokerCardinality + { + /// + /// 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 BrokerCardinality(BrokerBackendChain backendChain, BrokerFrontend 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 BrokerCardinality(BrokerBackendChain backendChain, BrokerFrontend frontend, IDictionary serializedAdditionalRawData) + { + BackendChain = backendChain; + Frontend = frontend; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerCardinality() + { + } + + /// The backend broker desired properties. + public BrokerBackendChain BackendChain { get; set; } + /// The frontend desired properties. + public BrokerFrontend Frontend { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerClientConfig.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerClientConfig.Serialization.cs new file mode 100644 index 00000000000000..de259286c1e093 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerClientConfig.Serialization.cs @@ -0,0 +1,215 @@ +// 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 BrokerClientConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerClientConfig)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + BrokerClientConfig 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(BrokerClientConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerClientConfig(document.RootElement, options); + } + + internal static BrokerClientConfig DeserializeBrokerClientConfig(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 BrokerClientConfig( + 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(BrokerClientConfig)} does not support writing '{options.Format}' format."); + } + } + + BrokerClientConfig 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 DeserializeBrokerClientConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerClientConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerClientConfig.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerClientConfig.cs new file mode 100644 index 00000000000000..065b32ebb62613 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerClientConfig.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 BrokerClientConfig + { + /// + /// 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 BrokerClientConfig() + { + } + + /// 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 BrokerClientConfig(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/BrokerDiagnosticSelfCheck.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticSelfCheck.Serialization.cs new file mode 100644 index 00000000000000..997161e504181d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticSelfCheck.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 BrokerDiagnosticSelfCheck : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerDiagnosticSelfCheck)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + BrokerDiagnosticSelfCheck 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(BrokerDiagnosticSelfCheck)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerDiagnosticSelfCheck(document.RootElement, options); + } + + internal static BrokerDiagnosticSelfCheck DeserializeBrokerDiagnosticSelfCheck(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsOperationalMode? 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 IotOperationsOperationalMode(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 BrokerDiagnosticSelfCheck(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(BrokerDiagnosticSelfCheck)} does not support writing '{options.Format}' format."); + } + } + + BrokerDiagnosticSelfCheck 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 DeserializeBrokerDiagnosticSelfCheck(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerDiagnosticSelfCheck)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticSelfCheck.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticSelfCheck.cs new file mode 100644 index 00000000000000..32c48926e084f1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticSelfCheck.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 BrokerDiagnosticSelfCheck + { + /// + /// 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 BrokerDiagnosticSelfCheck() + { + } + + /// 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 BrokerDiagnosticSelfCheck(IotOperationsOperationalMode? mode, int? intervalSeconds, int? timeoutSeconds, IDictionary serializedAdditionalRawData) + { + Mode = mode; + IntervalSeconds = intervalSeconds; + TimeoutSeconds = timeoutSeconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The toggle to enable/disable self check. + public IotOperationsOperationalMode? 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/BrokerDiagnosticTraces.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticTraces.Serialization.cs new file mode 100644 index 00000000000000..1001dbff7d706f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticTraces.Serialization.cs @@ -0,0 +1,178 @@ +// 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 BrokerDiagnosticTraces : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerDiagnosticTraces)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + 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 + } + } + } + + BrokerDiagnosticTraces 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(BrokerDiagnosticTraces)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerDiagnosticTraces(document.RootElement, options); + } + + internal static BrokerDiagnosticTraces DeserializeBrokerDiagnosticTraces(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsOperationalMode? mode = default; + int? cacheSizeMegabytes = default; + DiagnosticSelfTracing 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 IotOperationsOperationalMode(property.Value.GetString()); + 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 = DiagnosticSelfTracing.DeserializeDiagnosticSelfTracing(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 BrokerDiagnosticTraces(mode, 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(BrokerDiagnosticTraces)} does not support writing '{options.Format}' format."); + } + } + + BrokerDiagnosticTraces 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 DeserializeBrokerDiagnosticTraces(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerDiagnosticTraces)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticTraces.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticTraces.cs new file mode 100644 index 00000000000000..4b25b5f3d110b3 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnosticTraces.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 Trace properties. + public partial class BrokerDiagnosticTraces + { + /// + /// 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 BrokerDiagnosticTraces() + { + } + + /// Initializes a new instance of . + /// The toggle to enable/disable traces. + /// The cache size in megabytes. + /// The self tracing properties. + /// The span channel capacity. + /// Keeps track of any properties unknown to the library. + internal BrokerDiagnosticTraces(IotOperationsOperationalMode? mode, int? cacheSizeMegabytes, DiagnosticSelfTracing selfTracing, int? spanChannelCapacity, IDictionary serializedAdditionalRawData) + { + Mode = mode; + CacheSizeMegabytes = cacheSizeMegabytes; + SelfTracing = selfTracing; + SpanChannelCapacity = spanChannelCapacity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The toggle to enable/disable traces. + public IotOperationsOperationalMode? Mode { get; set; } + /// The cache size in megabytes. + public int? CacheSizeMegabytes { get; set; } + /// The self tracing properties. + public DiagnosticSelfTracing SelfTracing { get; set; } + /// The span channel capacity. + public int? SpanChannelCapacity { get; set; } + } +} 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 00000000000000..f472d08fa804b9 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnostics.Serialization.cs @@ -0,0 +1,178 @@ +// 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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerDiagnostics)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + IotOperationsMetrics metrics = default; + BrokerDiagnosticSelfCheck selfCheck = default; + BrokerDiagnosticTraces 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 = IotOperationsMetrics.DeserializeIotOperationsMetrics(property.Value, options); + continue; + } + if (property.NameEquals("selfCheck"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + selfCheck = BrokerDiagnosticSelfCheck.DeserializeBrokerDiagnosticSelfCheck(property.Value, options); + continue; + } + if (property.NameEquals("traces"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + traces = BrokerDiagnosticTraces.DeserializeBrokerDiagnosticTraces(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 00000000000000..8469121b894721 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerDiagnostics.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 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, IotOperationsMetrics metrics, BrokerDiagnosticSelfCheck selfCheck, BrokerDiagnosticTraces traces, IDictionary serializedAdditionalRawData) + { + Logs = logs; + Metrics = metrics; + SelfCheck = selfCheck; + Traces = traces; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Diagnostic log settings for the resource. + internal DiagnosticsLogs Logs { get; set; } + /// The log level. Examples - 'debug', 'info', 'warn', 'error', 'trace'. + public string LogsLevel + { + get => Logs is null ? default : Logs.Level; + set + { + if (Logs is null) + Logs = new DiagnosticsLogs(); + Logs.Level = value; + } + } + + /// The metrics settings for the resource. + internal IotOperationsMetrics Metrics { get; set; } + /// The prometheus port to expose the metrics. + public int? MetricsPrometheusPort + { + get => Metrics is null ? default : Metrics.PrometheusPort; + set + { + if (Metrics is null) + Metrics = new IotOperationsMetrics(); + Metrics.PrometheusPort = value; + } + } + + /// The self check properties. + public BrokerDiagnosticSelfCheck SelfCheck { get; set; } + /// The trace properties. + public BrokerDiagnosticTraces Traces { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerFrontend.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerFrontend.Serialization.cs new file mode 100644 index 00000000000000..49bc68ac8872b4 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerFrontend.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 BrokerFrontend : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerFrontend)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + BrokerFrontend 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(BrokerFrontend)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerFrontend(document.RootElement, options); + } + + internal static BrokerFrontend DeserializeBrokerFrontend(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 BrokerFrontend(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(BrokerFrontend)} does not support writing '{options.Format}' format."); + } + } + + BrokerFrontend 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 DeserializeBrokerFrontend(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerFrontend)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerFrontend.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerFrontend.cs new file mode 100644 index 00000000000000..621e7851074585 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerFrontend.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 BrokerFrontend + { + /// + /// 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 BrokerFrontend(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 BrokerFrontend(int replicas, int? workers, IDictionary serializedAdditionalRawData) + { + Replicas = replicas; + Workers = workers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrokerFrontend() + { + } + + /// 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/BrokerListenerPort.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerListenerPort.Serialization.cs new file mode 100644 index 00000000000000..6d4098c129b36b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerListenerPort.Serialization.cs @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.IotOperations.Models +{ + public partial class BrokerListenerPort : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerListenerPort)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + BrokerListenerPort 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(BrokerListenerPort)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrokerListenerPort(document.RootElement, options); + } + + internal static BrokerListenerPort DeserializeBrokerListenerPort(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 BrokerListenerPort( + 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(BrokerListenerPort)} does not support writing '{options.Format}' format."); + } + } + + BrokerListenerPort 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 DeserializeBrokerListenerPort(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrokerListenerPort)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerListenerPort.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerListenerPort.cs new file mode 100644 index 00000000000000..117a802f8111d3 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerListenerPort.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 BrokerListenerPort + { + /// + /// 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 BrokerListenerPort(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 BrokerListenerPort(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 BrokerListenerPort() + { + } + + /// 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/BrokerListenerResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerListenerResourceListResult.Serialization.cs new file mode 100644 index 00000000000000..f490959735c4d8 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerListenerResourceListResult.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 +{ + internal partial class BrokerListenerResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerListenerResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + 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(IotOperationsBrokerListenerData.DeserializeIotOperationsBrokerListenerData(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 00000000000000..cfabff3b0ef64c --- /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 00000000000000..79d58c27d43f31 --- /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 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/BrokerOperatorValue.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerOperatorValue.cs new file mode 100644 index 00000000000000..4ecabff851b8d3 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerOperatorValue.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 BrokerOperatorValue : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public BrokerOperatorValue(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 BrokerOperatorValue In { get; } = new BrokerOperatorValue(InValue); + /// NotIn operator. + public static BrokerOperatorValue NotIn { get; } = new BrokerOperatorValue(NotInValue); + /// Exists operator. + public static BrokerOperatorValue Exists { get; } = new BrokerOperatorValue(ExistsValue); + /// DoesNotExist operator. + public static BrokerOperatorValue DoesNotExist { get; } = new BrokerOperatorValue(DoesNotExistValue); + /// Determines if two values are the same. + public static bool operator ==(BrokerOperatorValue left, BrokerOperatorValue right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(BrokerOperatorValue left, BrokerOperatorValue right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator BrokerOperatorValue(string value) => new BrokerOperatorValue(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is BrokerOperatorValue other && Equals(other); + /// + public bool Equals(BrokerOperatorValue 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/BrokerProtocolType.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerProtocolType.cs new file mode 100644 index 00000000000000..d120021ddd8158 --- /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 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 00000000000000..3178f23a44bb52 --- /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 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 00000000000000..1268dc5ec9d633 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerResourceListResult.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 +{ + internal partial class BrokerResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + 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(IotOperationsBrokerData.DeserializeIotOperationsBrokerData(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 00000000000000..8b9c8a284ae92b --- /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 00000000000000..e7bb487906293a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/BrokerResourceRule.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 BrokerResourceRule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrokerResourceRule)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..6bb64d25fa8925 --- /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/CertManagerCertConfig.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/CertManagerCertConfig.Serialization.cs new file mode 100644 index 00000000000000..7154d060438702 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/CertManagerCertConfig.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 CertManagerCertConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertManagerCertConfig)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + CertManagerCertConfig 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(CertManagerCertConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCertManagerCertConfig(document.RootElement, options); + } + + internal static CertManagerCertConfig DeserializeCertManagerCertConfig(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 CertManagerCertConfig(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(CertManagerCertConfig)} does not support writing '{options.Format}' format."); + } + } + + CertManagerCertConfig 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 DeserializeCertManagerCertConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CertManagerCertConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/CertManagerCertConfig.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/CertManagerCertConfig.cs new file mode 100644 index 00000000000000..0fce36ef4b6886 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/CertManagerCertConfig.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 CertManagerCertConfig + { + /// + /// 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 CertManagerCertConfig(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 CertManagerCertConfig(string duration, string renewBefore, CertManagerPrivateKey privateKey, IDictionary serializedAdditionalRawData) + { + Duration = duration; + RenewBefore = renewBefore; + PrivateKey = privateKey; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CertManagerCertConfig() + { + } + + /// 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 00000000000000..ea8be1a2ee0c0e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/CertManagerCertificateSpec.Serialization.cs @@ -0,0 +1,196 @@ +// 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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertManagerCertificateSpec)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..72e6e3d2ee80fd --- /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 00000000000000..324d892c4d4ff4 --- /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 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 00000000000000..3beebfc817541a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/CertManagerIssuerRef.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 CertManagerIssuerRef : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertManagerIssuerRef)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..a4bebbc9067a03 --- /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 00000000000000..e6dfd3deeca9da --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/CertManagerPrivateKey.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 CertManagerPrivateKey : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertManagerPrivateKey)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..8b47bdaa6136be --- /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/CloudEventAttributeType.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/CloudEventAttributeType.cs new file mode 100644 index 00000000000000..36316dd74dd734 --- /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 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/DataExplorerAuthMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataExplorerAuthMethod.cs new file mode 100644 index 00000000000000..d494a04ab05c8a --- /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 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 00000000000000..70b1b1583ca6f5 --- /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 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 00000000000000..fa2391f34c4097 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowBuiltInTransformationDataset.Serialization.cs @@ -0,0 +1,183 @@ +// 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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationDataset)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..7ad875930df3cc --- /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 00000000000000..c289c2bec612d6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowBuiltInTransformationFilter.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 DataflowBuiltInTransformationFilter : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationFilter)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + } + DataflowFilterType? 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 DataflowFilterType(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 00000000000000..72ea32123f36b8 --- /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(DataflowFilterType? 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 DataflowFilterType? 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 00000000000000..b2fc5983b5760a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowBuiltInTransformationMap.Serialization.cs @@ -0,0 +1,187 @@ +// 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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationMap)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..35b97d6282bbbe --- /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 00000000000000..f2df3200ed1e04 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowBuiltInTransformationSettings.Serialization.cs @@ -0,0 +1,225 @@ +// 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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowBuiltInTransformationSettings)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..052a855c7a14d1 --- /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 00000000000000..0a51f54dda4dd6 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowDestinationOperationSettings.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 DataflowDestinationOperationSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowDestinationOperationSettings)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..4ffa39c18f3c5b --- /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 00000000000000..7cc6f06e2131f5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointAuthenticationAccessToken.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 DataflowEndpointAuthenticationAccessToken : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationAccessToken)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..6aefe1c51b9d55 --- /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 00000000000000..071e24f8068b62 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointAuthenticationSasl.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 DataflowEndpointAuthenticationSasl : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationSasl)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..43294794934889 --- /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 00000000000000..2085fb5bb40bf6 --- /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 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 00000000000000..b71fe15b786752 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointAuthenticationServiceAccountToken.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 DataflowEndpointAuthenticationServiceAccountToken : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationServiceAccountToken)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..4beb7de6161935 --- /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 00000000000000..64c0684a49f00a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointAuthenticationSystemAssignedManagedIdentity.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 DataflowEndpointAuthenticationSystemAssignedManagedIdentity : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationSystemAssignedManagedIdentity)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..363687e7efbdcc --- /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 00000000000000..fca2d5be8d2d06 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointAuthenticationUserAssignedManagedIdentity.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 DataflowEndpointAuthenticationUserAssignedManagedIdentity : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationUserAssignedManagedIdentity)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..6ed43fc2cab870 --- /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 00000000000000..192e6ffd985b7e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointAuthenticationX509.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 DataflowEndpointAuthenticationX509 : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointAuthenticationX509)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..3006690008caf9 --- /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 00000000000000..98fb0d03e87e6a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointDataExplorer.Serialization.cs @@ -0,0 +1,157 @@ +// 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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointDataExplorer)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + IotOperationsBatchingConfig 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 = IotOperationsBatchingConfig.DeserializeIotOperationsBatchingConfig(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 00000000000000..fc8ea2a23c5b42 --- /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, IotOperationsBatchingConfig 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 IotOperationsBatchingConfig 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 00000000000000..7d848f1a9750c0 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointDataExplorerAuthentication.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 DataflowEndpointDataExplorerAuthentication : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointDataExplorerAuthentication)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..31e06aad1f71a6 --- /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 00000000000000..7ac2fd20c31fea --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointDataLakeStorage.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 DataflowEndpointDataLakeStorage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointDataLakeStorage)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + IotOperationsBatchingConfig 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 = IotOperationsBatchingConfig.DeserializeIotOperationsBatchingConfig(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 00000000000000..431a60bbbdf58b --- /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, IotOperationsBatchingConfig 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 IotOperationsBatchingConfig 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 00000000000000..f7efc9e33f95bf --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointDataLakeStorageAuthentication.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 DataflowEndpointDataLakeStorageAuthentication : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointDataLakeStorageAuthentication)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..4866f138eb743a --- /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 00000000000000..f1a4c40cc3111c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointFabricOneLake.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 DataflowEndpointFabricOneLake : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLake)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + IotOperationsBatchingConfig 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 = IotOperationsBatchingConfig.DeserializeIotOperationsBatchingConfig(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 00000000000000..1f8339ff226ea0 --- /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, IotOperationsBatchingConfig 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 IotOperationsBatchingConfig 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 00000000000000..1e9d0123012dfd --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointFabricOneLakeAuthentication.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 DataflowEndpointFabricOneLakeAuthentication : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLakeAuthentication)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..3fc4e605e9b531 --- /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 00000000000000..dccf62229bd164 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointFabricOneLakeNames.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 DataflowEndpointFabricOneLakeNames : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointFabricOneLakeNames)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..6ffd0118b08571 --- /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 00000000000000..996b7056b1c072 --- /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 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 00000000000000..0e0f55b6c75e0b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointKafka.Serialization.cs @@ -0,0 +1,261 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointKafka)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + IotOperationsOperationalMode? copyMqttProperties = default; + DataflowEndpointKafkaCompression? compression = default; + DataflowEndpointKafkaAck? kafkaAcks = default; + DataflowEndpointKafkaPartitionStrategy? partitionStrategy = default; + IotOperationsTlsProperties 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 IotOperationsOperationalMode(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 = IotOperationsTlsProperties.DeserializeIotOperationsTlsProperties(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 00000000000000..5d026f50d60216 --- /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, IotOperationsOperationalMode? copyMqttProperties, DataflowEndpointKafkaCompression? compression, DataflowEndpointKafkaAck? kafkaAcks, DataflowEndpointKafkaPartitionStrategy? partitionStrategy, IotOperationsTlsProperties 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 IotOperationsOperationalMode? 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 IotOperationsTlsProperties 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 00000000000000..0df576557ae15a --- /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 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 00000000000000..ffb03b2233dcf9 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointKafkaAuthentication.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 DataflowEndpointKafkaAuthentication : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointKafkaAuthentication)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..a2432c7c1f1107 --- /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 00000000000000..f28171d30f020a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointKafkaBatching.Serialization.cs @@ -0,0 +1,178 @@ +// 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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointKafkaBatching)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + } + IotOperationsOperationalMode? 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 IotOperationsOperationalMode(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 00000000000000..9a2266943cade5 --- /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(IotOperationsOperationalMode? mode, int? latencyMs, int? maxBytes, int? maxMessages, IDictionary serializedAdditionalRawData) + { + Mode = mode; + LatencyMs = latencyMs; + MaxBytes = maxBytes; + MaxMessages = maxMessages; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Mode for batching. + public IotOperationsOperationalMode? 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 00000000000000..a7721b76402708 --- /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 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 00000000000000..4d47a8c150ba24 --- /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 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 00000000000000..9e11e443c72702 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointLocalStorage.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 DataflowEndpointLocalStorage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointLocalStorage)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..0fe18edad6b11a --- /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 00000000000000..65fc2094fd5e2e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointMqtt.Serialization.cs @@ -0,0 +1,280 @@ +// 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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointMqtt)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + IotOperationsTlsProperties 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 = IotOperationsTlsProperties.DeserializeIotOperationsTlsProperties(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 00000000000000..da476dfa14fc0e --- /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-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-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, IotOperationsTlsProperties 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-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 IotOperationsTlsProperties 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 00000000000000..da315233586667 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointMqttAuthentication.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 DataflowEndpointMqttAuthentication : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointMqttAuthentication)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..70e1168b1489f8 --- /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-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-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/DataflowEndpointResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointResourceListResult.Serialization.cs new file mode 100644 index 00000000000000..4b46aaa59a0a04 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointResourceListResult.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 +{ + internal partial class DataflowEndpointResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowEndpointResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + 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(IotOperationsDataflowEndpointData.DeserializeIotOperationsDataflowEndpointData(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 00000000000000..1f962deae25f3b --- /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/DataflowEndpointType.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointType.cs new file mode 100644 index 00000000000000..cf2f76bbb3ba1f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowEndpointType.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 DataflowEndpointType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataflowEndpointType(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 DataflowEndpointType DataExplorer { get; } = new DataflowEndpointType(DataExplorerValue); + /// Azure Data Lake Type. + public static DataflowEndpointType DataLakeStorage { get; } = new DataflowEndpointType(DataLakeStorageValue); + /// Microsoft Fabric Type. + public static DataflowEndpointType FabricOneLake { get; } = new DataflowEndpointType(FabricOneLakeValue); + /// Kafka Type. + public static DataflowEndpointType Kafka { get; } = new DataflowEndpointType(KafkaValue); + /// Local Storage Type. + public static DataflowEndpointType LocalStorage { get; } = new DataflowEndpointType(LocalStorageValue); + /// Broker Type. + public static DataflowEndpointType Mqtt { get; } = new DataflowEndpointType(MqttValue); + /// Determines if two values are the same. + public static bool operator ==(DataflowEndpointType left, DataflowEndpointType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataflowEndpointType left, DataflowEndpointType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DataflowEndpointType(string value) => new DataflowEndpointType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataflowEndpointType other && Equals(other); + /// + public bool Equals(DataflowEndpointType 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/DataflowFilterType.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowFilterType.cs new file mode 100644 index 00000000000000..3280bee9d192c7 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowFilterType.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 DataflowFilterType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataflowFilterType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FilterValue = "Filter"; + + /// Filter type. + public static DataflowFilterType Filter { get; } = new DataflowFilterType(FilterValue); + /// Determines if two values are the same. + public static bool operator ==(DataflowFilterType left, DataflowFilterType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataflowFilterType left, DataflowFilterType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DataflowFilterType(string value) => new DataflowFilterType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataflowFilterType other && Equals(other); + /// + public bool Equals(DataflowFilterType 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/DataflowMappingType.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowMappingType.cs new file mode 100644 index 00000000000000..0028d8ac544fea --- /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 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/DataflowOperationProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowOperationProperties.Serialization.cs new file mode 100644 index 00000000000000..41bb4ebee8692b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowOperationProperties.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 DataflowOperationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowOperationProperties)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + DataflowOperationProperties 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(DataflowOperationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataflowOperationProperties(document.RootElement, options); + } + + internal static DataflowOperationProperties DeserializeDataflowOperationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowOperationType 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 DataflowOperationType(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 DataflowOperationProperties( + 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(DataflowOperationProperties)} does not support writing '{options.Format}' format."); + } + } + + DataflowOperationProperties 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 DeserializeDataflowOperationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataflowOperationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowOperationProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowOperationProperties.cs new file mode 100644 index 00000000000000..a8561b0ff64048 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowOperationProperties.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 DataflowOperationProperties + { + /// + /// 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 DataflowOperationProperties(DataflowOperationType 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 DataflowOperationProperties(DataflowOperationType 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 DataflowOperationProperties() + { + } + + /// Type of operation. + public DataflowOperationType 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/DataflowOperationType.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowOperationType.cs new file mode 100644 index 00000000000000..7662886a417d52 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowOperationType.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 DataflowOperationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataflowOperationType(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 DataflowOperationType Source { get; } = new DataflowOperationType(SourceValue); + /// Dataflow Destination Operation. + public static DataflowOperationType Destination { get; } = new DataflowOperationType(DestinationValue); + /// Dataflow BuiltIn Transformation Operation. + public static DataflowOperationType BuiltInTransformation { get; } = new DataflowOperationType(BuiltInTransformationValue); + /// Determines if two values are the same. + public static bool operator ==(DataflowOperationType left, DataflowOperationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataflowOperationType left, DataflowOperationType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DataflowOperationType(string value) => new DataflowOperationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataflowOperationType other && Equals(other); + /// + public bool Equals(DataflowOperationType 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/DataflowProfileResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowProfileResourceListResult.Serialization.cs new file mode 100644 index 00000000000000..cb98cf5c708525 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowProfileResourceListResult.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 +{ + internal partial class DataflowProfileResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowProfileResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + 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(IotOperationsDataflowProfileData.DeserializeIotOperationsDataflowProfileData(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 00000000000000..7cd1f46d44cd55 --- /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/DataflowResourceListResult.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowResourceListResult.Serialization.cs new file mode 100644 index 00000000000000..baefa40cd68e73 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowResourceListResult.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 +{ + internal partial class DataflowResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + 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(IotOperationsDataflowData.DeserializeIotOperationsDataflowData(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 00000000000000..c354c4b17576f3 --- /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 00000000000000..fc55b1cc404cbf --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowSourceOperationSettings.Serialization.cs @@ -0,0 +1,187 @@ +// 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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataflowSourceOperationSettings)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + DataflowSourceSerializationFormat? 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 DataflowSourceSerializationFormat(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 00000000000000..62015b71167105 --- /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, DataflowSourceSerializationFormat? 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 DataflowSourceSerializationFormat? 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/DataflowSourceSerializationFormat.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowSourceSerializationFormat.cs new file mode 100644 index 00000000000000..24aa4ba2ba4c20 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DataflowSourceSerializationFormat.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 DataflowSourceSerializationFormat : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataflowSourceSerializationFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string JsonValue = "Json"; + + /// JSON Format. + public static DataflowSourceSerializationFormat Json { get; } = new DataflowSourceSerializationFormat(JsonValue); + /// Determines if two values are the same. + public static bool operator ==(DataflowSourceSerializationFormat left, DataflowSourceSerializationFormat right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataflowSourceSerializationFormat left, DataflowSourceSerializationFormat right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DataflowSourceSerializationFormat(string value) => new DataflowSourceSerializationFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataflowSourceSerializationFormat other && Equals(other); + /// + public bool Equals(DataflowSourceSerializationFormat 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/DiagnosticSelfTracing.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DiagnosticSelfTracing.Serialization.cs new file mode 100644 index 00000000000000..c4e5de6d132541 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DiagnosticSelfTracing.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 DiagnosticSelfTracing : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DiagnosticSelfTracing)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + DiagnosticSelfTracing 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(DiagnosticSelfTracing)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDiagnosticSelfTracing(document.RootElement, options); + } + + internal static DiagnosticSelfTracing DeserializeDiagnosticSelfTracing(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsOperationalMode? 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 IotOperationsOperationalMode(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 DiagnosticSelfTracing(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(DiagnosticSelfTracing)} does not support writing '{options.Format}' format."); + } + } + + DiagnosticSelfTracing 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 DeserializeDiagnosticSelfTracing(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DiagnosticSelfTracing)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DiagnosticSelfTracing.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DiagnosticSelfTracing.cs new file mode 100644 index 00000000000000..f9affe6eaa191f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DiagnosticSelfTracing.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 DiagnosticSelfTracing + { + /// + /// 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 DiagnosticSelfTracing() + { + } + + /// 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 DiagnosticSelfTracing(IotOperationsOperationalMode? mode, int? intervalSeconds, IDictionary serializedAdditionalRawData) + { + Mode = mode; + IntervalSeconds = intervalSeconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The toggle to enable/disable self tracing. + public IotOperationsOperationalMode? Mode { get; set; } + /// The self tracing interval. + public int? IntervalSeconds { get; set; } + } +} 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 00000000000000..9ba39763c3484a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DiagnosticsLogs.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 DiagnosticsLogs : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DiagnosticsLogs)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + } + string level = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + 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(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 00000000000000..c9c5df76560071 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DiagnosticsLogs.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 +{ + /// Diagnostic Log properties. + internal 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 log level. Examples - 'debug', 'info', 'warn', 'error', 'trace'. + /// Keeps track of any properties unknown to the library. + internal DiagnosticsLogs(string level, IDictionary serializedAdditionalRawData) + { + Level = level; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// 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 00000000000000..afef033cd3075a --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/DiskBackedMessageBuffer.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 DiskBackedMessageBuffer : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DiskBackedMessageBuffer)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..397e07f090bbfc --- /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/FabricOneLakeAuthMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/FabricOneLakeAuthMethod.cs new file mode 100644 index 00000000000000..775238b10f5390 --- /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 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/GenerateResourceLimits.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/GenerateResourceLimits.Serialization.cs new file mode 100644 index 00000000000000..dbf60920daa8c5 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/GenerateResourceLimits.Serialization.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GenerateResourceLimits)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + } + IotOperationsOperationalMode? 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 IotOperationsOperationalMode(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 00000000000000..429b203649e575 --- /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(IotOperationsOperationalMode? cpu, IDictionary serializedAdditionalRawData) + { + Cpu = cpu; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The toggle to enable/disable cpu resource limits. + public IotOperationsOperationalMode? Cpu { 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 00000000000000..cfbe5f5b78c478 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/InstanceResourceListResult.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 +{ + internal partial class InstanceResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InstanceResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + 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(IotOperationsInstanceData.DeserializeIotOperationsInstanceData(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 00000000000000..52f45bbdf23b1b --- /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/IotOperationsBatchingConfig.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBatchingConfig.Serialization.cs new file mode 100644 index 00000000000000..c2cf840fdb2287 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBatchingConfig.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 IotOperationsBatchingConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsBatchingConfig)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsBatchingConfig 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(IotOperationsBatchingConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsBatchingConfig(document.RootElement, options); + } + + internal static IotOperationsBatchingConfig DeserializeIotOperationsBatchingConfig(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 IotOperationsBatchingConfig(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(IotOperationsBatchingConfig)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsBatchingConfig 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 DeserializeIotOperationsBatchingConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsBatchingConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBatchingConfig.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBatchingConfig.cs new file mode 100644 index 00000000000000..0b054a83564c7c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBatchingConfig.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 IotOperationsBatchingConfig + { + /// + /// 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 IotOperationsBatchingConfig() + { + } + + /// 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 IotOperationsBatchingConfig(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/IotOperationsBrokerAuthenticationProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthenticationProperties.Serialization.cs new file mode 100644 index 00000000000000..3f26cfe783af78 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthenticationProperties.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 IotOperationsBrokerAuthenticationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsBrokerAuthenticationProperties)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsBrokerAuthenticationProperties 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(IotOperationsBrokerAuthenticationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsBrokerAuthenticationProperties(document.RootElement, options); + } + + internal static IotOperationsBrokerAuthenticationProperties DeserializeIotOperationsBrokerAuthenticationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList authenticationMethods = default; + IotOperationsProvisioningState? 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 IotOperationsProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IotOperationsBrokerAuthenticationProperties(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(IotOperationsBrokerAuthenticationProperties)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsBrokerAuthenticationProperties 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 DeserializeIotOperationsBrokerAuthenticationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsBrokerAuthenticationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthenticationProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthenticationProperties.cs new file mode 100644 index 00000000000000..641ebc82bb8cac --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthenticationProperties.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 IotOperationsBrokerAuthenticationProperties + { + /// + /// 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 IotOperationsBrokerAuthenticationProperties(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 IotOperationsBrokerAuthenticationProperties(IList authenticationMethods, IotOperationsProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + AuthenticationMethods = authenticationMethods; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsBrokerAuthenticationProperties() + { + } + + /// 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 IotOperationsProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthorizationProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthorizationProperties.Serialization.cs new file mode 100644 index 00000000000000..48583a5467a304 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthorizationProperties.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 IotOperationsBrokerAuthorizationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsBrokerAuthorizationProperties)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsBrokerAuthorizationProperties 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(IotOperationsBrokerAuthorizationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsBrokerAuthorizationProperties(document.RootElement, options); + } + + internal static IotOperationsBrokerAuthorizationProperties DeserializeIotOperationsBrokerAuthorizationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrokerAuthorizationConfig authorizationPolicies = default; + IotOperationsProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("authorizationPolicies"u8)) + { + authorizationPolicies = BrokerAuthorizationConfig.DeserializeBrokerAuthorizationConfig(property.Value, options); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new IotOperationsProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IotOperationsBrokerAuthorizationProperties(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(IotOperationsBrokerAuthorizationProperties)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsBrokerAuthorizationProperties 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 DeserializeIotOperationsBrokerAuthorizationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsBrokerAuthorizationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthorizationProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthorizationProperties.cs new file mode 100644 index 00000000000000..40ff0898b82004 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerAuthorizationProperties.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 IotOperationsBrokerAuthorizationProperties + { + /// + /// 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 IotOperationsBrokerAuthorizationProperties(BrokerAuthorizationConfig 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 IotOperationsBrokerAuthorizationProperties(BrokerAuthorizationConfig authorizationPolicies, IotOperationsProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + AuthorizationPolicies = authorizationPolicies; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsBrokerAuthorizationProperties() + { + } + + /// The list of authorization policies supported by the Authorization Resource. + public BrokerAuthorizationConfig AuthorizationPolicies { get; set; } + /// The status of the last operation. + public IotOperationsProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerListenerProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerListenerProperties.Serialization.cs new file mode 100644 index 00000000000000..27b7965ee76ea9 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerListenerProperties.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 IotOperationsBrokerListenerProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsBrokerListenerProperties)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsBrokerListenerProperties 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(IotOperationsBrokerListenerProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsBrokerListenerProperties(document.RootElement, options); + } + + internal static IotOperationsBrokerListenerProperties DeserializeIotOperationsBrokerListenerProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string serviceName = default; + IList ports = default; + BlockerListenerServiceType? serviceType = default; + IotOperationsProvisioningState? 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(BrokerListenerPort.DeserializeBrokerListenerPort(item, options)); + } + ports = array; + continue; + } + if (property.NameEquals("serviceType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + serviceType = new BlockerListenerServiceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new IotOperationsProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IotOperationsBrokerListenerProperties(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(IotOperationsBrokerListenerProperties)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsBrokerListenerProperties 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 DeserializeIotOperationsBrokerListenerProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsBrokerListenerProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerListenerProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerListenerProperties.cs new file mode 100644 index 00000000000000..360cbbb3f74436 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerListenerProperties.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 IotOperationsBrokerListenerProperties + { + /// + /// 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 IotOperationsBrokerListenerProperties(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 IotOperationsBrokerListenerProperties(string serviceName, IList ports, BlockerListenerServiceType? serviceType, IotOperationsProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + ServiceName = serviceName; + Ports = ports; + ServiceType = serviceType; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsBrokerListenerProperties() + { + } + + /// 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 BlockerListenerServiceType? ServiceType { get; set; } + /// The status of the last operation. + public IotOperationsProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerProperties.Serialization.cs new file mode 100644 index 00000000000000..3b2c22f2cc171b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerProperties.Serialization.cs @@ -0,0 +1,231 @@ +// 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 IotOperationsBrokerProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsBrokerProperties)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsBrokerProperties 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(IotOperationsBrokerProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsBrokerProperties(document.RootElement, options); + } + + internal static IotOperationsBrokerProperties DeserializeIotOperationsBrokerProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrokerAdvancedSettings advanced = default; + BrokerCardinality cardinality = default; + BrokerDiagnostics diagnostics = default; + DiskBackedMessageBuffer diskBackedMessageBuffer = default; + GenerateResourceLimits generateResourceLimits = default; + BrokerMemoryProfile? memoryProfile = default; + IotOperationsProvisioningState? 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 = BrokerAdvancedSettings.DeserializeBrokerAdvancedSettings(property.Value, options); + continue; + } + if (property.NameEquals("cardinality"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + cardinality = BrokerCardinality.DeserializeBrokerCardinality(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 IotOperationsProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IotOperationsBrokerProperties( + 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(IotOperationsBrokerProperties)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsBrokerProperties 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 DeserializeIotOperationsBrokerProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsBrokerProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerProperties.cs new file mode 100644 index 00000000000000..895aa85c0e2ab3 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsBrokerProperties.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 IotOperationsBrokerProperties + { + /// + /// 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 IotOperationsBrokerProperties() + { + } + + /// 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 IotOperationsBrokerProperties(BrokerAdvancedSettings advanced, BrokerCardinality cardinality, BrokerDiagnostics diagnostics, DiskBackedMessageBuffer diskBackedMessageBuffer, GenerateResourceLimits generateResourceLimits, BrokerMemoryProfile? memoryProfile, IotOperationsProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + Advanced = advanced; + Cardinality = cardinality; + Diagnostics = diagnostics; + DiskBackedMessageBuffer = diskBackedMessageBuffer; + GenerateResourceLimits = generateResourceLimits; + MemoryProfile = memoryProfile; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Advanced settings of Broker. + public BrokerAdvancedSettings Advanced { get; set; } + /// The cardinality details of the broker. + public BrokerCardinality 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 IotOperationsOperationalMode? 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 IotOperationsProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowEndpointProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowEndpointProperties.Serialization.cs new file mode 100644 index 00000000000000..c11fb03493a376 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowEndpointProperties.Serialization.cs @@ -0,0 +1,240 @@ +// 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 IotOperationsDataflowEndpointProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsDataflowEndpointProperties)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsDataflowEndpointProperties 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(IotOperationsDataflowEndpointProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsDataflowEndpointProperties(document.RootElement, options); + } + + internal static IotOperationsDataflowEndpointProperties DeserializeIotOperationsDataflowEndpointProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataflowEndpointType endpointType = default; + DataflowEndpointDataExplorer dataExplorerSettings = default; + DataflowEndpointDataLakeStorage dataLakeStorageSettings = default; + DataflowEndpointFabricOneLake fabricOneLakeSettings = default; + DataflowEndpointKafka kafkaSettings = default; + DataflowEndpointLocalStorage localStorageSettings = default; + DataflowEndpointMqtt mqttSettings = default; + IotOperationsProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("endpointType"u8)) + { + endpointType = new DataflowEndpointType(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 IotOperationsProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IotOperationsDataflowEndpointProperties( + 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(IotOperationsDataflowEndpointProperties)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsDataflowEndpointProperties 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 DeserializeIotOperationsDataflowEndpointProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsDataflowEndpointProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowEndpointProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowEndpointProperties.cs new file mode 100644 index 00000000000000..dec808ba0d3b1b --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowEndpointProperties.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 IotOperationsDataflowEndpointProperties + { + /// + /// 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 IotOperationsDataflowEndpointProperties(DataflowEndpointType 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 IotOperationsDataflowEndpointProperties(DataflowEndpointType endpointType, DataflowEndpointDataExplorer dataExplorerSettings, DataflowEndpointDataLakeStorage dataLakeStorageSettings, DataflowEndpointFabricOneLake fabricOneLakeSettings, DataflowEndpointKafka kafkaSettings, DataflowEndpointLocalStorage localStorageSettings, DataflowEndpointMqtt mqttSettings, IotOperationsProvisioningState? 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 IotOperationsDataflowEndpointProperties() + { + } + + /// Endpoint Type. + public DataflowEndpointType 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 IotOperationsProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProfileProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProfileProperties.Serialization.cs new file mode 100644 index 00000000000000..8d11519060edcf --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProfileProperties.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 IotOperationsDataflowProfileProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsDataflowProfileProperties)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsDataflowProfileProperties 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(IotOperationsDataflowProfileProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsDataflowProfileProperties(document.RootElement, options); + } + + internal static IotOperationsDataflowProfileProperties DeserializeIotOperationsDataflowProfileProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProfileDiagnostics diagnostics = default; + int? instanceCount = default; + IotOperationsProvisioningState? 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 IotOperationsProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IotOperationsDataflowProfileProperties(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(IotOperationsDataflowProfileProperties)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsDataflowProfileProperties 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 DeserializeIotOperationsDataflowProfileProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsDataflowProfileProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProfileProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProfileProperties.cs new file mode 100644 index 00000000000000..e0fa6cb0d827ca --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProfileProperties.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 IotOperationsDataflowProfileProperties + { + /// + /// 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 IotOperationsDataflowProfileProperties() + { + } + + /// 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 IotOperationsDataflowProfileProperties(ProfileDiagnostics diagnostics, int? instanceCount, IotOperationsProvisioningState? 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 IotOperationsProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProperties.Serialization.cs new file mode 100644 index 00000000000000..9ab53970edc469 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProperties.Serialization.cs @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.IotOperations.Models +{ + public partial class IotOperationsDataflowProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsDataflowProperties)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsDataflowProperties 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(IotOperationsDataflowProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsDataflowProperties(document.RootElement, options); + } + + internal static IotOperationsDataflowProperties DeserializeIotOperationsDataflowProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsOperationalMode? mode = default; + IList operations = default; + IotOperationsProvisioningState? 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 IotOperationsOperationalMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("operations"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DataflowOperationProperties.DeserializeDataflowOperationProperties(item, options)); + } + operations = array; + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new IotOperationsProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IotOperationsDataflowProperties(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(IotOperationsDataflowProperties)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsDataflowProperties 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 DeserializeIotOperationsDataflowProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsDataflowProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProperties.cs new file mode 100644 index 00000000000000..194d29e2d52782 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsDataflowProperties.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 IotOperationsDataflowProperties + { + /// + /// 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 IotOperationsDataflowProperties(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 IotOperationsDataflowProperties(IotOperationsOperationalMode? mode, IList operations, IotOperationsProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + Mode = mode; + Operations = operations; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsDataflowProperties() + { + } + + /// Mode for Dataflow. Optional; defaults to Enabled. + public IotOperationsOperationalMode? 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 IotOperationsProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocation.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocation.Serialization.cs new file mode 100644 index 00000000000000..b2d1984db12308 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocation.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 IotOperationsExtendedLocation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsExtendedLocation)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsExtendedLocation 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(IotOperationsExtendedLocation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsExtendedLocation(document.RootElement, options); + } + + internal static IotOperationsExtendedLocation DeserializeIotOperationsExtendedLocation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IotOperationsExtendedLocationType 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 IotOperationsExtendedLocationType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IotOperationsExtendedLocation(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(IotOperationsExtendedLocation)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsExtendedLocation 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 DeserializeIotOperationsExtendedLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsExtendedLocation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocation.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocation.cs new file mode 100644 index 00000000000000..25458631a1b8d7 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocation.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 IotOperationsExtendedLocation + { + /// + /// 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 IotOperationsExtendedLocation(string name, IotOperationsExtendedLocationType 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 IotOperationsExtendedLocation(string name, IotOperationsExtendedLocationType type, IDictionary serializedAdditionalRawData) + { + Name = name; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsExtendedLocation() + { + } + + /// The name of the extended location. + public string Name { get; set; } + /// Type of ExtendedLocation. + public IotOperationsExtendedLocationType Type { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocationType.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocationType.cs new file mode 100644 index 00000000000000..bdd20c1e83e207 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsExtendedLocationType.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 IotOperationsExtendedLocationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public IotOperationsExtendedLocationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CustomLocationValue = "CustomLocation"; + + /// CustomLocation type. + public static IotOperationsExtendedLocationType CustomLocation { get; } = new IotOperationsExtendedLocationType(CustomLocationValue); + /// Determines if two values are the same. + public static bool operator ==(IotOperationsExtendedLocationType left, IotOperationsExtendedLocationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(IotOperationsExtendedLocationType left, IotOperationsExtendedLocationType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator IotOperationsExtendedLocationType(string value) => new IotOperationsExtendedLocationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is IotOperationsExtendedLocationType other && Equals(other); + /// + public bool Equals(IotOperationsExtendedLocationType 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/IotOperationsInstancePatch.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstancePatch.Serialization.cs new file mode 100644 index 00000000000000..8dc58170b97170 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstancePatch.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; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.IotOperations.Models +{ + public partial class IotOperationsInstancePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsInstancePatch)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsInstancePatch 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(IotOperationsInstancePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsInstancePatch(document.RootElement, options); + } + + internal static IotOperationsInstancePatch DeserializeIotOperationsInstancePatch(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 IotOperationsInstancePatch(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(IotOperationsInstancePatch)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsInstancePatch 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 DeserializeIotOperationsInstancePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsInstancePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstancePatch.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstancePatch.cs new file mode 100644 index 00000000000000..bc054f2b694cea --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstancePatch.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 IotOperationsInstancePatch + { + /// + /// 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 IotOperationsInstancePatch() + { + 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 IotOperationsInstancePatch(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/IotOperationsInstanceProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstanceProperties.Serialization.cs new file mode 100644 index 00000000000000..e003faf6325ac2 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstanceProperties.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 IotOperationsInstanceProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsInstanceProperties)} does not support writing '{format}' format."); + } + + 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("schemaRegistryRef"u8); + writer.WriteObjectValue(SchemaRegistryRef, 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 + } + } + } + + IotOperationsInstanceProperties 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(IotOperationsInstanceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsInstanceProperties(document.RootElement, options); + } + + internal static IotOperationsInstanceProperties DeserializeIotOperationsInstanceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + IotOperationsProvisioningState? provisioningState = default; + string version = default; + SchemaRegistryRef schemaRegistryRef = 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 IotOperationsProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("schemaRegistryRef"u8)) + { + schemaRegistryRef = SchemaRegistryRef.DeserializeSchemaRegistryRef(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IotOperationsInstanceProperties(description, provisioningState, version, schemaRegistryRef, 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(IotOperationsInstanceProperties)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsInstanceProperties 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 DeserializeIotOperationsInstanceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsInstanceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstanceProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstanceProperties.cs new file mode 100644 index 00000000000000..da45d642b4d5ea --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsInstanceProperties.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; +using Azure.Core; + +namespace Azure.ResourceManager.IotOperations.Models +{ + /// The properties of the Instance resource. + public partial class IotOperationsInstanceProperties + { + /// + /// 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 IotOperationsInstanceProperties(SchemaRegistryRef schemaRegistryRef) + { + Argument.AssertNotNull(schemaRegistryRef, nameof(schemaRegistryRef)); + + SchemaRegistryRef = schemaRegistryRef; + } + + /// 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. + /// Keeps track of any properties unknown to the library. + internal IotOperationsInstanceProperties(string description, IotOperationsProvisioningState? provisioningState, string version, SchemaRegistryRef schemaRegistryRef, IDictionary serializedAdditionalRawData) + { + Description = description; + ProvisioningState = provisioningState; + Version = version; + SchemaRegistryRef = schemaRegistryRef; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IotOperationsInstanceProperties() + { + } + + /// Detailed description of the Instance. + public string Description { get; set; } + /// The status of the last operation. + public IotOperationsProvisioningState? ProvisioningState { get; } + /// The Azure IoT Operations version. + public string Version { get; } + /// The reference to the Schema Registry for this AIO Instance. + internal SchemaRegistryRef SchemaRegistryRef { get; set; } + /// The resource ID of the Schema Registry. + public ResourceIdentifier SchemaRegistryRefResourceId + { + get => SchemaRegistryRef is null ? default : SchemaRegistryRef.ResourceId; + set => SchemaRegistryRef = new SchemaRegistryRef(value); + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsMetrics.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsMetrics.Serialization.cs new file mode 100644 index 00000000000000..570fa41b6ae6ed --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsMetrics.Serialization.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.IotOperations.Models +{ + internal partial class IotOperationsMetrics : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsMetrics)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsMetrics 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(IotOperationsMetrics)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsMetrics(document.RootElement, options); + } + + internal static IotOperationsMetrics DeserializeIotOperationsMetrics(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? prometheusPort = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + 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 IotOperationsMetrics(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(IotOperationsMetrics)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsMetrics 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 DeserializeIotOperationsMetrics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsMetrics)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsMetrics.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsMetrics.cs new file mode 100644 index 00000000000000..a99b608c0e158e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsMetrics.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 +{ + /// Diagnostic Metrics properties. + internal partial class IotOperationsMetrics + { + /// + /// 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 IotOperationsMetrics() + { + } + + /// Initializes a new instance of . + /// The prometheus port to expose the metrics. + /// Keeps track of any properties unknown to the library. + internal IotOperationsMetrics(int? prometheusPort, IDictionary serializedAdditionalRawData) + { + PrometheusPort = prometheusPort; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The prometheus port to expose the metrics. + public int? PrometheusPort { get; set; } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsOperationalMode.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsOperationalMode.cs new file mode 100644 index 00000000000000..191a20fabb9d7e --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsOperationalMode.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 IotOperationsOperationalMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public IotOperationsOperationalMode(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 IotOperationsOperationalMode Enabled { get; } = new IotOperationsOperationalMode(EnabledValue); + /// Disabled is equivalent to False. + public static IotOperationsOperationalMode Disabled { get; } = new IotOperationsOperationalMode(DisabledValue); + /// Determines if two values are the same. + public static bool operator ==(IotOperationsOperationalMode left, IotOperationsOperationalMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(IotOperationsOperationalMode left, IotOperationsOperationalMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator IotOperationsOperationalMode(string value) => new IotOperationsOperationalMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is IotOperationsOperationalMode other && Equals(other); + /// + public bool Equals(IotOperationsOperationalMode 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/IotOperationsProvisioningState.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsProvisioningState.cs new file mode 100644 index 00000000000000..6dc37692d956c8 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsProvisioningState.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 IotOperationsProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public IotOperationsProvisioningState(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 IotOperationsProvisioningState Succeeded { get; } = new IotOperationsProvisioningState(SucceededValue); + /// Resource creation failed. + public static IotOperationsProvisioningState Failed { get; } = new IotOperationsProvisioningState(FailedValue); + /// Resource creation was canceled. + public static IotOperationsProvisioningState Canceled { get; } = new IotOperationsProvisioningState(CanceledValue); + /// Resource is getting provisioned. + public static IotOperationsProvisioningState Provisioning { get; } = new IotOperationsProvisioningState(ProvisioningValue); + /// Resource is Updating. + public static IotOperationsProvisioningState Updating { get; } = new IotOperationsProvisioningState(UpdatingValue); + /// Resource is Deleting. + public static IotOperationsProvisioningState Deleting { get; } = new IotOperationsProvisioningState(DeletingValue); + /// Resource has been Accepted. + public static IotOperationsProvisioningState Accepted { get; } = new IotOperationsProvisioningState(AcceptedValue); + /// Determines if two values are the same. + public static bool operator ==(IotOperationsProvisioningState left, IotOperationsProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(IotOperationsProvisioningState left, IotOperationsProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator IotOperationsProvisioningState(string value) => new IotOperationsProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is IotOperationsProvisioningState other && Equals(other); + /// + public bool Equals(IotOperationsProvisioningState 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/IotOperationsTlsProperties.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsTlsProperties.Serialization.cs new file mode 100644 index 00000000000000..b3a0a05963ec36 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsTlsProperties.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 IotOperationsTlsProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IotOperationsTlsProperties)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + IotOperationsTlsProperties 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(IotOperationsTlsProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIotOperationsTlsProperties(document.RootElement, options); + } + + internal static IotOperationsTlsProperties DeserializeIotOperationsTlsProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IotOperationsOperationalMode? 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 IotOperationsOperationalMode(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 IotOperationsTlsProperties(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(IotOperationsTlsProperties)} does not support writing '{options.Format}' format."); + } + } + + IotOperationsTlsProperties 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 DeserializeIotOperationsTlsProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IotOperationsTlsProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsTlsProperties.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsTlsProperties.cs new file mode 100644 index 00000000000000..8e3a30e634f3bb --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/IotOperationsTlsProperties.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 IotOperationsTlsProperties + { + /// + /// 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 IotOperationsTlsProperties() + { + } + + /// Initializes a new instance of . + /// Mode for TLS. + /// Trusted CA certificate config map. + /// Keeps track of any properties unknown to the library. + internal IotOperationsTlsProperties(IotOperationsOperationalMode? mode, string trustedCaCertificateConfigMapRef, IDictionary serializedAdditionalRawData) + { + Mode = mode; + TrustedCaCertificateConfigMapRef = trustedCaCertificateConfigMapRef; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Mode for TLS. + public IotOperationsOperationalMode? Mode { get; set; } + /// Trusted CA certificate config map. + public string TrustedCaCertificateConfigMapRef { 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 00000000000000..7176568103fc07 --- /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 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 00000000000000..aa31b027907310 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/KubernetesReference.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 KubernetesReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KubernetesReference)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..0bb01b50cca0db --- /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/LocalKubernetesReference.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/LocalKubernetesReference.Serialization.cs new file mode 100644 index 00000000000000..b4359b4fd3be62 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/LocalKubernetesReference.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 LocalKubernetesReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocalKubernetesReference)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..427f8b07e32f45 --- /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/MqttAuthMethod.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/MqttAuthMethod.cs new file mode 100644 index 00000000000000..65784118d0aeb3 --- /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 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 00000000000000..8245f97a4190df --- /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 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/PrincipalConfig.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/PrincipalConfig.Serialization.cs new file mode 100644 index 00000000000000..78062eb1e28c9d --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/PrincipalConfig.Serialization.cs @@ -0,0 +1,216 @@ +// 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 PrincipalConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PrincipalConfig)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + PrincipalConfig 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(PrincipalConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrincipalConfig(document.RootElement, options); + } + + internal static PrincipalConfig DeserializePrincipalConfig(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 PrincipalConfig(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(PrincipalConfig)} does not support writing '{options.Format}' format."); + } + } + + PrincipalConfig 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 DeserializePrincipalConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PrincipalConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/PrincipalConfig.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/PrincipalConfig.cs new file mode 100644 index 00000000000000..c03ac9733c7f0f --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/PrincipalConfig.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 PrincipalConfig + { + /// + /// 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 PrincipalConfig() + { + 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 PrincipalConfig(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 00000000000000..f6e7c239c612cb --- /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 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 00000000000000..3f599341a777dc --- /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 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 00000000000000..29c1dbe705e733 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/ProfileDiagnostics.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 ProfileDiagnostics : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProfileDiagnostics)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + IotOperationsMetrics 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 = IotOperationsMetrics.DeserializeIotOperationsMetrics(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 00000000000000..419d60d1f56582 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/ProfileDiagnostics.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 +{ + /// 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, IotOperationsMetrics metrics, IDictionary serializedAdditionalRawData) + { + Logs = logs; + Metrics = metrics; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Diagnostic log settings for the resource. + internal DiagnosticsLogs Logs { get; set; } + /// The log level. Examples - 'debug', 'info', 'warn', 'error', 'trace'. + public string LogsLevel + { + get => Logs is null ? default : Logs.Level; + set + { + if (Logs is null) + Logs = new DiagnosticsLogs(); + Logs.Level = value; + } + } + + /// The metrics settings for the resource. + internal IotOperationsMetrics Metrics { get; set; } + /// The prometheus port to expose the metrics. + public int? MetricsPrometheusPort + { + get => Metrics is null ? default : Metrics.PrometheusPort; + set + { + if (Metrics is null) + Metrics = new IotOperationsMetrics(); + Metrics.PrometheusPort = 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 00000000000000..0e10760f6e3b8c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/SanForCert.Serialization.cs @@ -0,0 +1,154 @@ +// 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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SanForCert)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..4fba0f7414de13 --- /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/SchemaRegistryRef.Serialization.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/SchemaRegistryRef.Serialization.cs new file mode 100644 index 00000000000000..ed3d365dba62f1 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/SchemaRegistryRef.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 +{ + public partial class SchemaRegistryRef : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SchemaRegistryRef)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + 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 + } + } + } + + SchemaRegistryRef 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(SchemaRegistryRef)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSchemaRegistryRef(document.RootElement, options); + } + + internal static SchemaRegistryRef DeserializeSchemaRegistryRef(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier resourceId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceId"u8)) + { + resourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SchemaRegistryRef(resourceId, 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(SchemaRegistryRef)} does not support writing '{options.Format}' format."); + } + } + + SchemaRegistryRef 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 DeserializeSchemaRegistryRef(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SchemaRegistryRef)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/SchemaRegistryRef.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/SchemaRegistryRef.cs new file mode 100644 index 00000000000000..0aecdae69564f9 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/SchemaRegistryRef.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 Azure.Core; + +namespace Azure.ResourceManager.IotOperations.Models +{ + /// The reference to the Schema Registry for this AIO Instance. + public partial class SchemaRegistryRef + { + /// + /// 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 resource ID of the Schema Registry. + /// is null. + public SchemaRegistryRef(ResourceIdentifier resourceId) + { + Argument.AssertNotNull(resourceId, nameof(resourceId)); + + ResourceId = resourceId; + } + + /// Initializes a new instance of . + /// The resource ID of the Schema Registry. + /// Keeps track of any properties unknown to the library. + internal SchemaRegistryRef(ResourceIdentifier resourceId, IDictionary serializedAdditionalRawData) + { + ResourceId = resourceId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SchemaRegistryRef() + { + } + + /// The resource ID of the Schema Registry. + public ResourceIdentifier ResourceId { get; set; } + } +} 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 00000000000000..b8c575ce8aa54a --- /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 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 00000000000000..0c281767ca150a --- /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 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 00000000000000..50a435619abc57 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/StateStoreResourceRule.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 StateStoreResourceRule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StateStoreResourceRule)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..e142cfebcab0a8 --- /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 00000000000000..b0d4e18801c413 --- /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 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 00000000000000..ff5331fdf1c037 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/SubscriberQueueLimit.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 SubscriberQueueLimit : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubscriberQueueLimit)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..7101ae6dc05867 --- /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 00000000000000..80fabd732e17cb --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/TlsCertMethod.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 TlsCertMethod : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TlsCertMethod)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..5141fbf2e675ce --- /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 00000000000000..ea6f191d0dcb17 --- /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 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/TransformationSerializationFormat.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/TransformationSerializationFormat.cs new file mode 100644 index 00000000000000..0f0bc84168ca60 --- /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 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 00000000000000..3ca5c42a061572 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/VolumeClaimResourceRequirements.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 VolumeClaimResourceRequirements : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VolumeClaimResourceRequirements)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..ee277898596ab8 --- /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 00000000000000..2b6f4ed45c1b77 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/VolumeClaimSpec.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; + +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) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VolumeClaimSpec)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..3a4b0932fb28b7 --- /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 00000000000000..ea5e8c8532874c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/VolumeClaimSpecSelector.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 VolumeClaimSpecSelector : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VolumeClaimSpecSelector)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..71d8c20b1197e5 --- /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 00000000000000..c0dcc9bef09fce --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/VolumeClaimSpecSelectorMatchExpressions.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 VolumeClaimSpecSelectorMatchExpressions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VolumeClaimSpecSelectorMatchExpressions)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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; + BrokerOperatorValue @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 BrokerOperatorValue(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 00000000000000..f408fe9469314a --- /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, BrokerOperatorValue @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, BrokerOperatorValue @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 BrokerOperatorValue 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 00000000000000..ef4e3e542c4b9c --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Generated/Models/X509ManualCertificate.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 X509ManualCertificate : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(X509ManualCertificate)} does not support writing '{format}' format."); + } + + 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 + } + } + } + + 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 00000000000000..2fe5eea93e9c29 --- /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 00000000000000..6e409eacdadfdf --- /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 00000000000000..0ed588b48af7d6 --- /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. + /// Service host. + /// 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-11-01"; + _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: + { + IotOperationsBrokerAuthenticationData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = IotOperationsBrokerAuthenticationData.DeserializeIotOperationsBrokerAuthenticationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsBrokerAuthenticationData)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: + { + IotOperationsBrokerAuthenticationData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = IotOperationsBrokerAuthenticationData.DeserializeIotOperationsBrokerAuthenticationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsBrokerAuthenticationData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authenticationName, IotOperationsBrokerAuthenticationData 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, IotOperationsBrokerAuthenticationData 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, IotOperationsBrokerAuthenticationData 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, IotOperationsBrokerAuthenticationData 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 00000000000000..37500f6e8f54cf --- /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. + /// Service host. + /// 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-11-01"; + _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: + { + IotOperationsBrokerAuthorizationData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = IotOperationsBrokerAuthorizationData.DeserializeIotOperationsBrokerAuthorizationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsBrokerAuthorizationData)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: + { + IotOperationsBrokerAuthorizationData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = IotOperationsBrokerAuthorizationData.DeserializeIotOperationsBrokerAuthorizationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsBrokerAuthorizationData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string authorizationName, IotOperationsBrokerAuthorizationData 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, IotOperationsBrokerAuthorizationData 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, IotOperationsBrokerAuthorizationData 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, IotOperationsBrokerAuthorizationData 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 00000000000000..97dc2c199e2ad2 --- /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. + /// Service host. + /// 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-11-01"; + _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: + { + IotOperationsBrokerListenerData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = IotOperationsBrokerListenerData.DeserializeIotOperationsBrokerListenerData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsBrokerListenerData)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: + { + IotOperationsBrokerListenerData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = IotOperationsBrokerListenerData.DeserializeIotOperationsBrokerListenerData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsBrokerListenerData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, string listenerName, IotOperationsBrokerListenerData 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, IotOperationsBrokerListenerData 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, IotOperationsBrokerListenerData 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, IotOperationsBrokerListenerData 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 00000000000000..c496a2daf0c2c9 --- /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. + /// Service host. + /// 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-11-01"; + _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: + { + IotOperationsBrokerData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = IotOperationsBrokerData.DeserializeIotOperationsBrokerData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsBrokerData)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: + { + IotOperationsBrokerData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = IotOperationsBrokerData.DeserializeIotOperationsBrokerData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsBrokerData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string brokerName, IotOperationsBrokerData 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, IotOperationsBrokerData 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, IotOperationsBrokerData 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, IotOperationsBrokerData 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 00000000000000..df99293a5e0cea --- /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. + /// Service host. + /// 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-11-01"; + _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: + { + IotOperationsDataflowEndpointData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = IotOperationsDataflowEndpointData.DeserializeIotOperationsDataflowEndpointData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsDataflowEndpointData)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: + { + IotOperationsDataflowEndpointData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = IotOperationsDataflowEndpointData.DeserializeIotOperationsDataflowEndpointData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsDataflowEndpointData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowEndpointName, IotOperationsDataflowEndpointData 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, IotOperationsDataflowEndpointData 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, IotOperationsDataflowEndpointData 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, IotOperationsDataflowEndpointData 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 00000000000000..80408fb8d64bb2 --- /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. + /// Service host. + /// 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-11-01"; + _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: + { + IotOperationsDataflowProfileData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = IotOperationsDataflowProfileData.DeserializeIotOperationsDataflowProfileData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsDataflowProfileData)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: + { + IotOperationsDataflowProfileData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = IotOperationsDataflowProfileData.DeserializeIotOperationsDataflowProfileData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsDataflowProfileData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName, IotOperationsDataflowProfileData 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, IotOperationsDataflowProfileData 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, IotOperationsDataflowProfileData 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, IotOperationsDataflowProfileData 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 00000000000000..53c2adb9aa3cb4 --- /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. + /// Service host. + /// 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-11-01"; + _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: + { + IotOperationsDataflowData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = IotOperationsDataflowData.DeserializeIotOperationsDataflowData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsDataflowData)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: + { + IotOperationsDataflowData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = IotOperationsDataflowData.DeserializeIotOperationsDataflowData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsDataflowData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, string dataflowProfileName, string dataflowName, IotOperationsDataflowData 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, IotOperationsDataflowData 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, IotOperationsDataflowData 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, IotOperationsDataflowData 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 00000000000000..bf2157a0760f62 --- /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. + /// Service host. + /// 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-11-01"; + _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: + { + IotOperationsInstanceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = IotOperationsInstanceData.DeserializeIotOperationsInstanceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsInstanceData)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: + { + IotOperationsInstanceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = IotOperationsInstanceData.DeserializeIotOperationsInstanceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((IotOperationsInstanceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string instanceName, IotOperationsInstanceData 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, IotOperationsInstanceData 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, IotOperationsInstanceData 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, IotOperationsInstanceData 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, IotOperationsInstancePatch 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, IotOperationsInstancePatch 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, IotOperationsInstancePatch 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: + { + IotOperationsInstanceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = IotOperationsInstanceData.DeserializeIotOperationsInstanceData(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, IotOperationsInstancePatch 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: + { + IotOperationsInstanceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = IotOperationsInstanceData.DeserializeIotOperationsInstanceData(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/Properties/AssemblyInfo.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/src/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000000..7f805ba36f5b7a --- /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("IotOperations")] 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 00000000000000..0921fa61bbba84 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/tests/Azure.ResourceManager.IotOperations.Tests.csproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/tests/IotOperationsManagementTestBase.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/tests/IotOperationsManagementTestBase.cs new file mode 100644 index 00000000000000..f44f0a747c32cc --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/tests/IotOperationsManagementTestBase.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure; +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.IotOperations.Tests +{ + public class IotOperationsManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected IotOperationsManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected IotOperationsManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + } +} diff --git a/sdk/iotoperations/Azure.ResourceManager.IotOperations/tests/IotOperationsManagementTestEnvironment.cs b/sdk/iotoperations/Azure.ResourceManager.IotOperations/tests/IotOperationsManagementTestEnvironment.cs new file mode 100644 index 00000000000000..aeacf0481ec253 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/tests/IotOperationsManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.IotOperations.Tests +{ + public class IotOperationsManagementTestEnvironment : TestEnvironment + { + } +} 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 00000000000000..1ef1f04ab88fa8 --- /dev/null +++ b/sdk/iotoperations/Azure.ResourceManager.IotOperations/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/iotoperations/IoTOperations.Management +commit: 19e711519c8b63daf19fed198192d93d28748587 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/iotoperations/ci.mgmt.yml b/sdk/iotoperations/ci.mgmt.yml new file mode 100644 index 00000000000000..5a7919d4302bbd --- /dev/null +++ b/sdk/iotoperations/ci.mgmt.yml @@ -0,0 +1,26 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: none + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/iotoperations /ci.mgmt.yml + - sdk/iotoperations /Azure.ResourceManager.IotOperations / + + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: iotoperations + ArtifactName: packages + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.IotOperations + safeName: AzureResourceManagerIotOperations diff --git a/sdk/resourcemanager/ci.mgmt.yml b/sdk/resourcemanager/ci.mgmt.yml index 960151044171ea..f28c28a5d39c23 100644 --- a/sdk/resourcemanager/ci.mgmt.yml +++ b/sdk/resourcemanager/ci.mgmt.yml @@ -107,6 +107,7 @@ trigger: - sdk/iot/Azure.ResourceManager.IotFirmwareDefense - sdk/iotcentral/Azure.ResourceManager.IotCentral - sdk/iothub/Azure.ResourceManager.IotHub + - sdk/iotoperations/Azure.ResourceManager.IotOperations - sdk/keyvault/Azure.ResourceManager.KeyVault - sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration - sdk/kusto/Azure.ResourceManager.Kusto @@ -312,6 +313,7 @@ pr: - sdk/iot/Azure.ResourceManager.IotFirmwareDefense - sdk/iotcentral/Azure.ResourceManager.IotCentral - sdk/iothub/Azure.ResourceManager.IotHub + - sdk/iotoperations/Azure.ResourceManager.IotOperations - sdk/keyvault/Azure.ResourceManager.KeyVault - sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration - sdk/kusto/Azure.ResourceManager.Kusto